I've been looking, but I don't know how to do this...
# getting-started
b
I've been looking, but I don't know how to do this. How do you pass external values into the pulumi stack. For example, I take in from the user the s3 bucket name, how do I replace `"aws.s3.Bucket("s3-website-bucket")`"? Do I set an env variable and use
aws.s3.Bucket(process.env["BUCKET_NAME"])
?
f
thus something like
Copy code
let config = new pulumi.Config();
let bucketName = config.require("bucketName");
aws.s3.Bucket(bucketName)
or do you mean this is an interactive node console app?
if yes, you might want to look into the Automation API - here's an example https://github.com/pulumi/automation-api-examples/blob/main/nodejs/inlineProgram-tsnode/index.ts
b
Interactive, if I take in the name from a UI and pass it to a workflow which runs the pulumi cli. So it sounds like automation api to solve this.
f
Nice. Yeah I'd explore the Automation API 🙂
b
thanks for the quick response. The index.ts still uses
const siteBucket = new s3.Bucket("s3-website-bucket", {
but the the doc site looks like it is the use case I'm looking for.
f
no prob! let me know how it goes! 🙂
b
With `import { InlineProgramArgs, LocalWorkspace } from "@pulumi/pulumi/automation`"; it looks like you can treat it like a normal console app where you process command line args
Copy code
const process = require('process');

const args = process.argv.slice(2);
let destroy = false;
if (args.length > 0 && args[0]) {
    destroy = args[0] === "destroy";
}
f
yep! it's pretty awesome
great for making self-contained self-service apps for non-devs to use (e.g. QA, Sales, standing up new SaaS customer environments, etc)