blue-actor-6315
06/03/2024, 9:24 PMlittle-cartoon-10569
06/03/2024, 9:52 PMblue-actor-6315
06/03/2024, 9:53 PMblue-actor-6315
06/03/2024, 9:53 PMlittle-cartoon-10569
06/03/2024, 9:53 PMblue-actor-6315
06/03/2024, 9:54 PMblue-actor-6315
06/03/2024, 9:54 PM--target
to something random used to just ignore provider changes, for some reason it doesnt work for me this timelittle-cartoon-10569
06/03/2024, 9:56 PMblue-actor-6315
06/03/2024, 9:56 PMlittle-cartoon-10569
06/03/2024, 9:56 PMblue-actor-6315
06/03/2024, 9:57 PMlittle-cartoon-10569
06/03/2024, 9:59 PMlittle-cartoon-10569
06/03/2024, 10:00 PMblue-actor-6315
06/03/2024, 10:15 PMpulumi preview --json
and pulumi stack export
to automate itblue-actor-6315
06/04/2024, 7:57 AMconst { stdout } = await runProcess({
command: 'pulumi',
commandArgs: ['stack', 'export'],
});
const state = JSON.parse(stdout.toString());
const resources: any[] = [];
const { stdout } = await runProcess({
command: 'pulumi',
commandArgs: ['preview', '--json'],
});
const diff = JSON.parse(stdout.toString());
const providerReplaces: { urn: string; newProvider: string }[] = [];
for (const step of diff.steps) {
if (step.op === 'replace' && step.replaceReasons.includes('provider')) {
providerReplaces.push({ urn: step.urn, newProvider: step.newState.provider });
}
}
for (const resource of state.deployment.resources) {
const replacement = providerReplaces.find((r) => r.urn === resource.urn);
if (replacement) {
resource.provider = replacement.newProvider;
}
resources.push(resource);
}
state.deployment.resources = resources;
console.log(JSON.stringify(state));