Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation API error: Program run without the Pulumi engine available; re-run using the pulumi CLI\n' when using random provider #16161

Closed
rubenceroni opened this issue May 10, 2024 · 2 comments
Labels
area/automation-api kind/bug Some behavior is incorrect or out of spec language/javascript

Comments

@rubenceroni
Copy link

rubenceroni commented May 10, 2024

What happened?

I am writing a lambda in Typescript that uses the automation api to provision resources.
I am encountering weird behaviour while using the random provider. When creating any resource with this provider inside an inline program i get this error:

 'Command failed with exit code 255: pulumi up --yes --skip-preview --client=127.0.0.1:52034 --exec-kind auto.inline --stack test --non-interactive\n' +
      'Updating (test):\n' +
      '\n' +
      ' +  pulumi:pulumi:Stack test_random-test creating (0s) \n' +
      ' +  pulumi:pulumi:Stack test_random-test creating (0s) error: Unhandled exception: Error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI\n' +
      ' +  pulumi:pulumi:Stack test_random-test creating (0s) error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI\n' +
      ' +  pulumi:pulumi:Stack test_random-test **creating failed (0.36s)** 2 errors\n' +
      'Diagnostics:\n' +
      '  pulumi:pulumi:Stack (test_random-test):\n' +
      '    error: Unhandled exception: Error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI\n' +
      '        at requireTestModeEnabled (/Users/$USER_HOME/test_random/node_modules/@pulumi/random/node_modules/@pulumi/pulumi/runtime/settings.js:123:15)\n' +
      '        at Object.getMonitor (/Users/$USER_HOME/test_random/node_modules/@pulumi/random/node_modules/@pulumi/pulumi/runtime/settings.js:214:13)\n' +
      '        at Object.registerResource (/Users/$USER_HOME/test_random/node_modules/@pulumi/random/node_modules/@pulumi/pulumi/runtime/resource.js:212:32)\n' +
      '        at new Resource (/Users/$USER_HOME/test_random/node_modules/@pulumi/random/node_modules/@pulumi/pulumi/resource.js:215:24)\n' +
      '        at new CustomResource (/Users/$USER_HOME/test_random/node_modules/@pulumi/random/node_modules/@pulumi/pulumi/resource.js:307:9)\n' +
      '        at new RandomString (/Users/$USER_HOME/test_random/node_modules/@pulumi/randomString.ts:175:9)\n' +
      '        at Object.pulumiProgram [as init] (/Users/$USER_HOME/test_random/index.ts:24:18)\n' +
      '        at Stack.<anonymous> (/Users/$USER_HOME/test_random/node_modules/@pulumi/runtime/stack.ts:77:39)\n' +
      '        at Generator.next (<anonymous>)\n' +
      '        at fulfilled (/Users/$USER_HOME/test_random/node_modules/@pulumi/pulumi/runtime/stack.js:18:58)\n' +
      '    error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI\n' +
      '\n' +
      'Resources:\n' +
      '    + 1 created\n' +
      '\n' +
      'Duration: 1s\n',

If I remove the Randomstring resource the program runs correctly.
If I run the program with the pulumi cli, using the same example but by swapping pulumiProgram() with testRandom() as my main, all resources are created correctly.

From my understanding this only happens when I use a resource from the random provider inside an inline program.
I followed examples from the docs to configure the provider, I believe that there is some interaction between random and inline programs that causes this error, as it is the only combination that causes this behaviour.

Example

import { LocalWorkspace } from "@pulumi/pulumi/automation";
import * as random from "@pulumi/random";
import * as time from "@pulumiverse/time";

const pulumiProgram = async () => {

    const provider = new time.Provider("provider", {});
    const offset = new time.Offset("offset", {offsetDays: 7});
    const test = new random.RandomString("prova", {
        length: 40
    })
    return {
        // test,
        offset
    }
};

export const testRandom = async () => {
    try {
        const stackName = "test"
        const stack = await LocalWorkspace.createStack({
            stackName,
            projectName: "test_random",
            program: pulumiProgram
        });
        const upRes = await stack.up({ onOutput: console.info });
        const outs = await stack.outputs();
        console.log(outs)
    } catch (error) {
        console.error("Error:", error);
    }
};

testRandom();

// pulumiProgram()

Output of pulumi about

CLI
Version 3.115.2
Go Version go1.22.2
Go Compiler gc

Plugins
KIND NAME VERSION
resource aws 6.34.0
resource awsx 2.9.0
resource docker 4.5.3
resource docker 3.6.1
language nodejs unknown
resource random 3.2.0

Host
OS darwin
Version 14.4.1
Arch x86_64

This project is written in nodejs: executable='/usr/local/bin/node' version='v22.1.0'

Backend
Name REDACTED.local
URL s3://REDACTED?region=eu-south-1
User REDACTED
Organizations
Token type personal

Pulumi locates its logs in /var/folders/f8/4sbm64zj2937pgtb7nnzt7pjs0l5fh/T/ by default
warning: Failed to get information about the Pulumi program's dependencies: failed to run "/usr/local/bin/npm ls --json --depth=0": exit status 1
warning: Failed to get information about the current stack: No current stack

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@rubenceroni rubenceroni added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 10, 2024
@julienp
Copy link
Contributor

julienp commented May 10, 2024

Could you share how you are running your example? I tried your code and ran it with tsc && node index.js and it worked as expected.

@julienp julienp added language/javascript awaiting-feedback Blocked on input from the author area/automation-api and removed needs-triage Needs attention from the triage team labels May 10, 2024
@rubenceroni
Copy link
Author

Hi, i was running the example in the same way you suggested, the issue was in the outdated version of pulumi random (3.2.0). Upgrading to an up to date version fixed the issue

@mikhailshilkov mikhailshilkov removed the awaiting-feedback Blocked on input from the author label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/automation-api kind/bug Some behavior is incorrect or out of spec language/javascript
Projects
None yet
Development

No branches or pull requests

3 participants