quiet-laptop-13439
07/11/2022, 10:20 AMable-train-72108
07/11/2022, 7:31 PMwitty-candle-66007
07/11/2022, 7:39 PMpulumi refresh
clears pending operations, so I would think you should be able to use the refresh method on a stack in automation API to do so.little-cartoon-10569
07/11/2022, 9:13 PMquiet-laptop-13439
07/12/2022, 10:24 AM3.35.3
and refresh doesn't modify state via automation api. It doesn't remove pending operations and doesn't reimport running resources, which is pretty annoyingwitty-candle-66007
07/12/2022, 2:58 PMimport * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Create an AWS resource (S3 Bucket)
const bucket = new aws.s3.Bucket("my-bucket", {
versioning: {
enabled: false
}
});
// Export the name of the bucket
export const bucketName = bucket.id;
I have this automation API program:
import { LocalProgramArgs, LocalWorkspace } from "@pulumi/pulumi/automation";
import * as upath from "upath";
const process = require('process');
const args = process.argv.slice(2);
let destroy = false;
if (args.length > 0 && args[0]) {
destroy = args[0] === "destroy";
}
const run = async () => {
// Create our stack using a local program
// in the ../website directory
const args: LocalProgramArgs = {
stackName: "dev",
workDir: upath.joinSafe(__dirname, "..", "bucket"),
};
// create (or select if one already exists) a stack that uses our local program
const stack = await LocalWorkspace.createOrSelectStack(args);
<http://console.info|console.info>("successfully initialized stack");
<http://console.info|console.info>("setting up config");
await stack.setConfig("aws:region", { value: "us-west-2" });
<http://console.info|console.info>("config set");
<http://console.info|console.info>("refreshing stack...");
await stack.refresh({ onOutput: <http://console.info|console.info> });
<http://console.info|console.info>("refresh complete");
if (destroy) {
<http://console.info|console.info>("destroying stack...");
await stack.destroy({onOutput: <http://console.info|console.info>});
<http://console.info|console.info>("stack destroy complete");
process.exit(0);
}
<http://console.info|console.info>("updating stack...");
const upRes = await stack.up({ onOutput: <http://console.info|console.info> });
console.log(`update summary: \n${JSON.stringify(upRes.summary.resourceChanges, null, 4)}`);
};
run();
acoustic-window-73051
07/27/2022, 3:34 PMpulumi stack export | jq 'del(.deployment.pending_operations)' | pulumi stack import