https://pulumi.com logo
Docs
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
typescript
  • d

    dazzling-coat-30936

    03/11/2022, 3:09 PM
    Hello quick question I understand this isn't an issue, now but in the future will the pulumi/aws library support more types in the content body?
    // current (@pulumi/aws)
    content?: pulumi.Input<string>;
    
    // support for Buffer and Uint8Array
    content: pulumi.Input<string> | pulumi.Input<Uint8Array> | pulumi.Input<Buffer>;
    I was banging my head on the keyboard trying to figure out why my stream was not working turns out we might need additional types to support streams or is there a better option? Happy to submit a PR if needed. Thanks.
    e
    • 2
    • 1
  • m

    mammoth-art-6111

    03/11/2022, 3:20 PM
    i'd transform it to Input<string> using
    apply
    or
    all
    d
    • 2
    • 2
  • m

    mammoth-art-6111

    03/16/2022, 3:10 PM
    anyone have any difficulty w/ jest output? i've noticed that when i'm using ts-jest, if i import any pulumi resource or create a pulumi component during a test run (with mocks), it garbles the stack trace. when i remove the pulumi modules, the stack trace is fine
    l
    • 2
    • 34
  • r

    refined-terabyte-65361

    03/17/2022, 7:56 PM
    Hello I am trying to use pulumi with github actions i see this error during workflow
    Error: code: 255
     stdout: 
     stderr: error: could not create stack: the stack is currently locked by 1 lock(s). Either wait for the other process(es) to end or manually delete the lock file(s).
    how to fix this ? Thanks
    e
    • 2
    • 2
  • o

    orange-kite-80991

    03/22/2022, 5:39 PM
    Suggestions on how to load values from my .env file into Pulumi? My ultimate goal is transferring them to docker.image { build { args: ... } }. Preferably as a single ENV_ARGS: "multi-line string"
    l
    • 2
    • 2
  • a

    ancient-eve-13947

    03/23/2022, 2:38 PM
    How can I use fetch inside a dynamic provider? I get errors of the form:
    error: Error serializing '() => provider': index.js(28,47)
    
        '() => provider': index.js(28,47): captured
          variable 'provider' which indirectly referenced
            function 'Provider': configuration.ts(21,0): which referenced
              function 'send': configuration.ts(60,8): which could not be serialized because
                Unexpected missing variable in closure environment: fetch
    q
    • 2
    • 50
  • b

    breezy-bear-50708

    03/24/2022, 4:31 PM
    Hello, I'm regularly having issues with stack trace line numbers being completely incorrect. It looks like source mapping is broken somewhere in pulumi/ts-node. Any ideas what could be doing it? package.json
    {
      "name": "extended-test",
      "main": "src/index.ts",
      "devDependencies": {
        "@google-cloud/container": "^2.6.0",
        "@google-cloud/resource-manager": "^3.0.0",
        "@kubernetes/client-node": "^0.16.3",
        "@types/chai": "^4.3.0",
        "@types/k6": "^0.36.0",
        "@types/mocha": "^9.1.0",
        "@types/node": "^16.11.25",
        "chai": "^4.3.6",
        "mocha": "^9.2.1",
        "node-fetch": "^2.6.7"
      },
      "dependencies": {
        "@js-joda/core": "^5.2.0",
        "@pulumi/gcp": "^6.12.0",
        "@pulumi/kubernetes": "^3.16.0",
        "@pulumi/pulumi": "^3.26.1",
        "@pulumi/random": "^4.3.1",
        "@types/promise-poller": "^1.7.1",
        "promise-poller": "^1.9.1",
        "typescript": "~3.8.3"
      },
      "scripts": {
        "lint": "eslint --fix **/*.ts",
        "check": "eslint **/*.ts",
        "test": "mocha -r ts-node/register tests/**/*.ts"
      }
    }
    tsconfig:
    {
      "extends": "../tsconfig.base",
      "compilerOptions": {
        "outDir": "dist",
        "sourceMap": true
      },
      "include": [
        "src/**/*",
        "tests/**/*"
      ],
      "references": [
        {
          "path": "../tslib"
        }
      ]
    }
    example stack trace, line numbers are off by around ~150
    TypeError: Cannot read properties of undefined (reading 'name')
            at new PerformancePipeline (/home/james/redacted/extended-test/src/PerformancePipeline.ts:344:68)
            at Object.<anonymous> (/home/james/redacted/extended-test/src/index.ts:16:1)
            at Module._compile (node:internal/modules/cjs/loader:1101:14)
            at Module.m._compile (/home/james/redacted/extended-test/node_modules/.pnpm/ts-node@7.0.1/node_modules/ts-node/src/index.ts:439:23)
            at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
            at Object.require.extensions.<computed> [as .ts] (/home/james/redacted/extended-test/node_modules/.pnpm/ts-node@7.0.1/node_modules/ts-node/src/index.ts:442:12)
            at Module.load (node:internal/modules/cjs/loader:981:32)
            at Function.Module._load (node:internal/modules/cjs/loader:822:12)
            at Module.require (node:internal/modules/cjs/loader:1005:19)
            at require (node:internal/modules/cjs/helpers:102:18)
  • b

    bitter-psychiatrist-55958

    04/03/2022, 6:18 PM
    Hello, I have a simple VPC where I am trying to get a subnet ID to use in an
    aws.ec2.NetworkInterface
    . The VPC is defined as:
    const vpc = new awsx.ec2.Vpc("culex-vpc", {
      cidrBlock: "10.50.0.0/16",
      numberOfAvailabilityZones: 1,	// defaults to 2, but for a lab 1 is good enuf
      subnets: [
        { type: "public", location: "10.50.20.0/24", tags },
        { type: "private", location: "10.50.30.0/24", tags }
      ],
      tags
    });
    How would I get the private subnet to use in the
    subnetId
    property in
    aws.ec2.NetworkInterface
    ? I tried using
    subnetId: vpc.id.apply(async () => vpc.privateSubnetsIds),
    as seen above here, but have issues with it being the wrong type for
    subnetId
    .
    e
    • 2
    • 5
  • n

    nutritious-battery-42762

    04/04/2022, 1:56 PM
    Trying to destroy a stack but it hangs in deleting the security group . Seems as though it doesn't know how to handle security groups from external stacks
    const cluster = new awsx.ecs.Cluster("custom", {
        cluster: aws.ecs.Cluster.get("payup-" + env, databaseStack.getOutput("ECS_CLUSTER_NAME")),
    });
    This is where it hangs
    Type                      Name             Status
         pulumi:pulumi:Stack       application-dev
     -   └─ aws:ec2:SecurityGroup  custom           deleting.
  • n

    nutritious-battery-42762

    04/04/2022, 2:23 PM
    looks like i'll have manually delete everything
    Type                      Name             Status                  Info
         pulumi:pulumi:Stack       application-dev  **failed**              1 error
     -   └─ aws:ec2:SecurityGroup  custom           **deleting failed**     1 error
    
    Diagnostics:
      aws:ec2:SecurityGroup (custom):
        error: deleting urn:pulumi:dev::application::awsx:x:ecs:Cluster$awsx:x:ec2:SecurityGroup$aws:ec2/securityGroup:SecurityGroup::custom: 1 error occurred:
            * Error deleting security group: DependencyViolation: resource sg-0519c8bd76b8feab6 has a dependent object
            status code: 400, request id: b323e056-8b51-4fcb-a8ac-b6afd48fef91
  • n

    nutritious-battery-42762

    04/04/2022, 2:24 PM
    I really wanted to have my database in a separate stack but it seems that'll only cause issues
    m
    l
    • 3
    • 3
  • r

    rhythmic-whale-48997

    04/05/2022, 8:14 AM
    My Typescript skills are a bit rusty. How would I save Output to a file? I tried to use
    apply
    but I'm getting errors
    TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object
            at Object.writeFileSync (node:fs:2163:5)
    Code:
    cluster.kubeconfig.apply(v => {
        fs.writeFileSync("../test", v);
    });
    e
    • 2
    • 2
  • w

    witty-park-12681

    04/05/2022, 4:04 PM
    Hello y'all, I have something like the following that fails sometimes, but sometimes works
    const modelBucket = new aws.s3.Bucket(this.modelBucketName, modelBucketConfig, {
        parent: this,
        protect: true
    })
    
    const p0 = this.createQueue(pipelineName, 0, modelBucket)
    
    let modelNotificationName = `${pipelineName}-modelNotification-${ENV_LOWER}`;
    new aws.s3.BucketNotification(modelNotificationName, {
      bucket: modelBucket.id,
      queues: [{
        events: ["s3:ObjectCreated:*"],
        filterSuffix: "model.tar.gz",
        queueArn: p0.arn,
      }],
    }, {
      dependsOn: [modelBucket, p0],
      parent: this
    })
    
    
    /**
     * Create an SQS queue
     * 
     * @param name 
     * @param priority 
     * @param bucket 
     */
    private createQueue(name: string, priority: number, bucket: aws.s3.Bucket) {
    let queueName = `p${priority}-${name}-queue-${ENV_LOWER}`
    
    const queue = new aws.sqs.Queue(queueName, 
        {visibilityTimeoutSeconds: 120},
        { dependsOn: bucket, parent: this } // specify resource parent
    )
    
    new aws.sqs.QueuePolicy(`p${priority}-${name}-S3Events-${ENV_LOWER}`, {
        policy: pulumi.interpolate`{
        "Version": "2012-10-17",
        "Statement": [
            {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "sqs:SendMessage",
            "Resource": "${queue.arn}",
            "Condition": {
                "ArnEquals": { "aws:SourceArn": "${bucket.arn}" }
            }
            }
        ]
        }`,
        queueUrl: queue.url,
    },
    { dependsOn: [bucket, queue],
        parent: this })
    
    return queue
    }
    The error I get is the following
    error: 1 error occurred:
    	* error putting S3 Bucket Notification Configuration: InvalidArgument: Unable to validate the following destination configurations
    	status code: 400, request id: NZSHGJTE4XD0SFHA, host id: a+VHT+tq6Fj91OMR29gdfmvHxUbsCR8KpAsD/NNQiYQoxz03Z2hZgDlS6ibC/2PCCFDHLwwudH0=
    Can anyone shed light on why this might be failing. I'm trying to create a bucket, and SQS queue, with a queue notification when a file gets created in the bucket.
    g
    • 2
    • 1
  • p

    proud-cricket-86351

    04/10/2022, 7:33 PM
    Anyone have a typescript pulumi code repo available? Where i can take some inspiration from?
    e
    q
    • 3
    • 2
  • p

    proud-cricket-86351

    04/10/2022, 7:33 PM
    Mainly looking at best practices and such
  • q

    quiet-tomato-48326

    04/11/2022, 7:17 AM
    Hi team, I’m trying to troubleshoot an exit code 255 with no error messages. Any tips? I’m 98% sure it’s happening in a
    pulumi.dynamic.Resource
    subclass while calling super
    • 1
    • 4
  • q

    quiet-tomato-48326

    04/12/2022, 9:25 AM
    ☝️🏻I’ve created a github issue for this with some extra info: https://github.com/pulumi/pulumi/issues/9386 (includes
    pulumi about
    and the output of
    -v=9 --logtostderr
    ) any help would be appreciated, I’m kinda stumped on how to troubleshoot this one without any error messages 😕
  • p

    proud-cricket-86351

    04/13/2022, 8:03 PM
    Hi everyone im having a kind of design problem and was looking for advice. My design is the following: ComponentResource1 that holds multiple components: 1. aws eks 2. Aws rds 3. Aws alb When creating those components im using the constructor to pass in those values but the problem is i have like 10-15 different parameters/args and the component initilization and constructor is huge Is there any way to make it more clean? Or is this just how its done
    l
    • 2
    • 2
  • b

    busy-journalist-6936

    04/15/2022, 6:48 PM
    Typescript Noob question alert 🚨 lol I'm making little progress on self teaching the practical difference between type
    Output<string>
    and
    string
    . In this case, I want to do:
    const name: string = pulumi.concat(["kc2-", stack]);
    But obviously that does not work due to error:
    Type 'Output<string>' is not assignable to type 'string'.
    How do I remediate this?
    l
    • 2
    • 1
  • b

    busy-journalist-6936

    04/15/2022, 6:56 PM
    The end goal is:
    import * as k from "@pulumi/kubernetes";
    const stack = pulumi.getStack();
    const name: string = pulumi.concat(["kc2-", stack]);
    const ns = new k.core.v1.Namespace(name, {
      metadata: {
          name: name,
        },
    }, {
      provider: kubevirt,
    });
    l
    • 2
    • 2
  • m

    miniature-musician-31262

    04/15/2022, 7:02 PM
    @busy-journalist-6936 Yeah,
    concat
    returns an
    Output<string>
    — but I’m not sure you need that, as both values are strings — does this work?
    const name: string = `kc2-${stack}`;
    b
    • 2
    • 3
  • r

    rough-window-15889

    04/25/2022, 9:21 PM
    Does anyone know the best way to mock the resource to unit test?
    l
    • 2
    • 7
  • p

    purple-train-14007

    04/26/2022, 5:59 PM
    Is there a way to have Pulumi use Yarn out the gate rather than have it boot strap an initial project with NPM? I dont like having to clean out the npm stuff when I switch to Yarn.
    b
    v
    m
    • 4
    • 20
  • r

    rough-window-15889

    04/28/2022, 9:26 PM
    I wrote some unit tests for my Pulumi stack. The tests run correctly but I have promise leaks. I'm trying to debug the promise leaks but they aren't overly helpful. Any ideas of what it could be? Cloud provider is Azure. I am making some AD calls that I may suspect could be part of the issue.
    l
    • 2
    • 17
  • p

    proud-cricket-86351

    04/29/2022, 3:13 PM
    Is it possible to publish a TS pulumi project to NPM? and if so is there any tutorial?
    b
    • 2
    • 20
  • r

    rough-window-15889

    04/30/2022, 2:50 PM
    Does anyone else feel like their Typescript Pulumi project is slow? How have you addressed performance issues? Specifically slow to compile. Once it is compiled it seems to run at a reasonable speed.
    e
    c
    • 3
    • 5
  • b

    broad-gold-44713

    04/30/2022, 10:59 PM
    I have a Pulumi TS project that often runs into OOM issues on WSL. I'm not sure where the problem is (probably too large type definitions?). The only usable solution I have found is to use early-oom, which is not ideal. Anyone run into similar issues? Edit: I’m talking about IDE issues here. Pulumi runtime is fine.
    b
    • 2
    • 2
  • w

    wonderful-bird-78843

    05/01/2022, 6:59 PM
    Is there an obvious way to use a pulumi.Output in a callback function that's going to be serialized? I've tried all sorts of manipulations with apply/etc.
    const requestsSns = new aws.sns.Topic("mcurl-sns-requests");
    
    const mcurlHandler = new aws.lambda.CallbackFunction("mcurl-handler", {
        callback: async (ev, ctx) => {
            const snsClient = new SNSClient({ region: region });
            var msg = {}
            var msgString = JSON.stringify(msg);
            var params = {
                Message: msgString, 
                TopicArn: requestsSns.arn,    <--------
            };
            try {
    e
    • 2
    • 6
  • a

    adamant-dress-73325

    05/02/2022, 8:14 PM
    Has anyone else run into error ts(1203) when using the async entrypoint pattern from the docs (https://www.pulumi.com/docs/intro/languages/javascript/#entrypoint)? Could it be because I'm not specifying a tsconfig in this project?
  • w

    wonderful-bird-78843

    05/02/2022, 11:03 PM
    One more fun function serialization problem!
    import { promisify } from "util";
    import { execFile as execFileReal } from 'child_process';
    
    const execFile = promisify(execFileReal);
    and then in a sns
    Topic.onEvent()
    I'm doing:
    try {
                const { stdout } = await execFile('curl', args);
                console.log("stdout:", stdout);
                msg.Response = stdout;
    }
    On
    up
    , I'm getting:
    Diagnostics:
      pulumi:pulumi:Stack (mcurl-typescript-mcurl):
        error: Error serializing '(ev, ctx) => __awaiter(this, void 0, ...': index.ts(137,57)
    
        '(ev, ctx) => __awaiter(this, void 0, ...': index.ts(137,57): captured
          'execFile', a function defined at
            '(...args) => { const { promise, reso ...': node:child_process(231,9): which captured
              'orig', a function defined at
                function 'execFile': node:child_process(278,17): which captured
                  'ArrayIsArray', a function defined at
                    function 'isArray': which could not be serialized because
                      it was a native code function.
    • 1
    • 6
Powered by Linen
Title
w

wonderful-bird-78843

05/02/2022, 11:03 PM
One more fun function serialization problem!
import { promisify } from "util";
import { execFile as execFileReal } from 'child_process';

const execFile = promisify(execFileReal);
and then in a sns
Topic.onEvent()
I'm doing:
try {
            const { stdout } = await execFile('curl', args);
            console.log("stdout:", stdout);
            msg.Response = stdout;
}
On
up
, I'm getting:
Diagnostics:
  pulumi:pulumi:Stack (mcurl-typescript-mcurl):
    error: Error serializing '(ev, ctx) => __awaiter(this, void 0, ...': index.ts(137,57)

    '(ev, ctx) => __awaiter(this, void 0, ...': index.ts(137,57): captured
      'execFile', a function defined at
        '(...args) => { const { promise, reso ...': node:child_process(231,9): which captured
          'orig', a function defined at
            function 'execFile': node:child_process(278,17): which captured
              'ArrayIsArray', a function defined at
                function 'isArray': which could not be serialized because
                  it was a native code function.
https://www.pulumi.com/docs/intro/concepts/function-serialization/#capturing-modules-in-a-javascript-function
This seems to suggest that the import from
child_process
should just be serialized into an import on the server, no?
For the reasons cited previously, modules are captured in a special but intuitive fashion. When a module is captured in code, it is translated into an idiomatic require call in the serialized JavaScript code.
This form of module capturing only applies to external modules that are referenced, such as modules that are directly part of Node, or are in the node_modules directory.
Am I missing something?
ahh, bah... I moved the
const execFile = promisify(execFileReal);
into the callback, and that fixed it
is this a bug?
View count: 1