https://pulumi.com logo
#automation-api
Title
# automation-api
h

hundreds-musician-51496

11/04/2020, 6:15 PM
I'm trying to run a program using the automation API and getting this error:
Copy code
Error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
at requireTestModeEnabled (C:\Users\Justin\Source\foo\internal-docs\deploy\node_modules\@pulumi\pulumi\runtime\settings.js:108:15)
at Object.getMonitor (C:\Users\Justin\Source\foo\internal-docs\deploy\node_modules\@pulumi\pulumi\runtime\settings.js:190:13)
at Object.readResource (C:\Users\Justin\Source\foo\internal-docs\deploy\node_modules\@pulumi\pulumi\runtime\resource.js:48:32)
at new Resource (C:\Users\Justin\Source\foo\internal-docs\deploy\node_modules\@pulumi\pulumi\resource.js:204:24)
at new CustomResource (C:\Users\Justin\Source\foo\internal-docs\deploy\node_modules\@pulumi\pulumi\resource.js:303:9)
at new StackReference (C:\Users\Justin\Source\foo\internal-docs\deploy\node_modules\@pulumi\pulumi\stackReference.js:44:9)
at C:\Users\Justin\Source\foo\internal-docs\deploy\index.ts:64:193
at Generator.next (<anonymous>)
at C:\Users\Justin\Source\foo\internal-docs\deploy\index.ts:8:71
at new Promise (<anonymous>)
I'm sure i'm missing something obvious. (thread)
package.json
has the right pulumi packages I think:
Copy code
"@pulumi/aws": "^3.0.0",
        "@pulumi/awsx": "^0.22.0",
        "@pulumi/pulumi": "^2.12.0",
Hmm - this program does try to re-use stack outputs as input to a pulumi program ... I'm doing this:
Copy code
const authnOutput= new pulumi.StackReference(`...`).outputs

const args: InlineProgramArgs = {
  ...
  program: async () => authnOutput.apply((authnOutput) => createDocumentSite(authnOutput.authNDomain, authnOutput.publicKey))
};
Where
createDocumentSite
creates resources, but notice I'm using
apply
to get stack output values ... Probably bad?
f

fancy-jelly-61092

11/04/2020, 6:24 PM
Try moving the `const authnRef = new pulumi.StackReference(...)`` line to inside your program. You cannot create any resources outside of that program() method
h

hundreds-musician-51496

11/04/2020, 6:46 PM
That helped me make progress, thanks! I ended up with:
Copy code
const args: InlineProgramArgs = {
  ...
  program: async () => {
    const authnOutput= new pulumi.StackReference(`...`).outputs
    authnOutput.apply((authnOutput) => createDocumentSite(authnOutput.authNDomain, authnOutput.publicKey))
  }
};
l

lemon-agent-27707

11/04/2020, 10:27 PM
Yes, any pulumi related code has to be run from within the
program
(inline function). This would include stack references. The error message could definitely be more clear here
2 Views