https://pulumi.com logo
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
  • f

    famous-jelly-72366

    05/29/2020, 8:24 AM
    Is there a recommended way to handle multiple 'sub' projects? yarn workspaces, lerna, something else?
    l
    • 2
    • 4
  • f

    famous-jelly-72366

    05/29/2020, 2:42 PM
    hmm I have things mostly working now with yarn workspaces, but pulumi doesn't seem to build typescript referenced projects? should use
    tsc -b
    • 1
    • 1
  • c

    curved-pharmacist-41509

    05/31/2020, 9:27 AM
    Where can I find more details about how the lambda call back extraction works? Got some odd errors and need to debug the transpilation, just not sure how it works
    m
    • 2
    • 3
  • f

    famous-jelly-72366

    06/02/2020, 3:39 PM
    how exactly is the typescript compile triggered? Is there any way to further configure, e.g. a script in package.json? still looking for best way to deal with referenced projects
    w
    • 2
    • 8
  • l

    little-cartoon-10569

    06/08/2020, 11:17 PM
    Slightly similar to the previous thread: I have a code tree with my Pulumi project, shared code and test code in various subdirectories. There is a single package.json, tsconfig.json etc. in the common ancestor directory. It was working fine until I created a new project yesterday. That one project is complaining about not being able to load package.json from its own directory. Which would be fair enough, but the other project and the test directories are finding the shared package.json. What might cause Pulumi to insist on finding the file in the current directory?
    b
    • 2
    • 16
  • s

    salmon-account-74572

    06/09/2020, 4:49 PM
    Is the code pattern of using
    push
    to create new items in an array deprecated/not supported in Pulumi 2.x? Example:
    let privRtAssoc = [];
    for (let i = 0; i < numberOfAZs; i++) {
        privRtAssoc.push(new aws.ec2.RouteTableAssociation(`${baseName}-priv-rta-${i+1}`, {
            routeTableId: privRt[i].id,
            subnetId: privSubnetIds[i],
        }));
    };
    I'm asking because I use this pattern a fair amount and need to find a replacement before migrating to Pulumi 2.x (yes, I'm lagging behind).
    g
    • 2
    • 3
  • c

    calm-parrot-72437

    06/10/2020, 4:26 AM
    Can someone help with this horrible bit of code that always wants to delete/replace network associations each time I up the stack its in: var i = 0; for (var subnetId of privateSubnetIds) { new aws.ec2clientvpn.NetworkAssociation(
    assoc-${i}
    , { clientVpnEndpointId: vpnEndpoint.id, subnetId: subnetId, }); i++; }
    g
    h
    • 3
    • 16
  • b

    busy-soccer-65968

    06/11/2020, 4:37 PM
    i'm seeing
    Diagnostics:
      pulumi:pulumi:Stack (infrastructure-stage):
        error: Running program '/home/p/Code/ss/infrastructure' failed with an unhandled exception:
        TypeError: Class extends value undefined is not a constructor or null
            at Object.<anonymous> (/home/p/Code/ss/infrastructure/node_modules/@pulumi/helm/v3/helm.ts:125:33)
            at Module._compile (internal/modules/cjs/loader.js:1200:30)
            at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
            at Module.load (internal/modules/cjs/loader.js:1049:32)
            at Function.Module._load (internal/modules/cjs/loader.js:937:14)
            at Module.require (internal/modules/cjs/loader.js:1089:19)
            at require (internal/modules/cjs/helpers.js:73:18)
            at Object.<anonymous> (/home/p/Code/ss/infrastructure/node_modules/@pulumi/helm/v3/index.ts:5:1)
            at Module._compile (internal/modules/cjs/loader.js:1200:30)
            at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    on a project that hasn't changed. In CI it suceeded friday, rerunning today it fails. anythoughts on what might h ave changed. I'm using
    pulumi/pulumi:latest
    docker image. Any idea where to start debugging this? I've updated all packages to newest versions. Any help is greatly appreciated.
    g
    c
    • 3
    • 29
  • n

    numerous-lifeguard-13411

    06/15/2020, 4:24 PM
    So far, the examples off the pulumi website all feature essentially static configurations. How does one make the
    index.ts
    file more dynamic? I'm trying to modify an SG in runtime--make a permissive one, then bring up the instance and allow it to update packages, and then (hopefully) make the SG more restrictive. Does plumi + typescript allow that in some fashion?
    l
    • 2
    • 4
  • s

    salmon-account-74572

    06/16/2020, 10:17 PM
    Newbie question here: what would folks recommend to help keep from littering my hard drive with multiple 200MB
    node_modules
    directories?
    l
    • 2
    • 5
  • l

    little-cartoon-10569

    06/17/2020, 4:29 AM
    Are the test fakes (
    pulumi.runtime.setMocks
    ) supposed to be cleared manually? I'm writing test modules and expecting the Pulumi runtime to know about the resources created during calls to Mocha
    before()
    and similar code, and the resources created during the test. Nothing else should exist. But I'm finding all resources there. Not just ones in the same file, but ones in completely unrelated files that are being run during the same call to
    npm run test
    . Do I need to clear the fakes ("mocks") out? Or do I need to wrap every test module in a call to
    runInPulumiStack()
    ?
    • 1
    • 5
  • s

    steep-angle-29984

    06/17/2020, 9:19 AM
    I can't wrap my head around this, maybe someone can help me out. I want do implement a default value for an optional pulumi.Input where the default value is also an pulumi.Input. This doesn't work:
    function getValue(optionalValue: pulumi.Input<number | undefined>, defaultValue: pulumi.Input<number>): pulumi.Input<number> {
        return pulumi.output(optionalValue).apply( v => {
            return v ?? defaultValue
        })
    }
    Error:(91, 9) TS2322: Type 'Output<Input<number>>' is not assignable to type 'Input<number>'. Type 'OutputInstance<Input<number>>' is not assignable to type 'Input<number>'. Type 'OutputInstance<Input<number>>' is not assignable to type 'OutputInstance<number>'. Type 'Input<number>' is not assignable to type 'number'. Type 'Promise<number>' is not assignable to type 'number'.
  • l

    little-cartoon-10569

    06/18/2020, 12:36 AM
    Can anyone recommend a good reference for learning about JS (ES6+) module scopes? I'd like something fairly thorough, but I do have an immediate case. Can I get different "versions" of Pulumi in every test file I import into? Pulumi stores its options in an unexported top-level variable that can't be reset.. but I need it clean for every suite of tests. So I want to scope my imports such that I get a different module/import/top-level variable each time I call 
    import * from "@pulumi/pulumi";
    .
  • f

    famous-bear-66383

    06/18/2020, 2:41 PM
    Quick question: How to convert
    pulumi.Output<string>
    to a
    string
    ? given
    const pass = new random.RandomPassword("password", { length: 20, special: true },{additionalSecretOutputs: ["password"]}).result;
    I want to use
    pass
    as a string to set other resources.
    const dbuser = new gcp.sql.User(`${user}-database-user`, {
        instance: instanceName,
        name: user,
        password: pass.apply(p => p.toString()),
        host: "cloudsqlproxy~%"
    });
    using
    apply
    like the following throughs errors
    pass.apply(p => p.toString()
    r
    f
    • 3
    • 7
  • l

    little-cartoon-10569

    06/18/2020, 11:44 PM
    I'm using EventRuleEventSubscription to convert an inline fat-arrow function to an AWS lambda. Works nicely when I use the AWS SDK. When I try to use a little bit of Pulumi code (which I know I should be able to, there's an example in https://github.com/pulumi/examples/blob/master/aws-ts-scheduled-function/index.ts), I get an import error. Am I missing something? Maybe I need to import EC2 differently? The code that produces the error is simply
    aws.ec2.getInstances({ filters: filters });
    . The error is
    typescript
    {
        "errorType": "Runtime.ImportModuleError",
        "errorMessage": "Error: Cannot find module '@pulumi/aws/ec2/index.js'\nRequire stack:\n- /var/task/__index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
        "stack": [
            "Runtime.ImportModuleError: Error: Cannot find module '@pulumi/aws/ec2/index.js'",
            "Require stack:",
            "- /var/task/__index.js",
            "- /var/runtime/UserFunction.js",
            "- /var/runtime/index.js",
            "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
            "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
            "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
            "    at Module._compile (internal/modules/cjs/loader.js:1133:30)",
            "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)",
            "    at Module.load (internal/modules/cjs/loader.js:977:32)",
            "    at Function.Module._load (internal/modules/cjs/loader.js:877:14)",
            "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)",
            "    at internal/main/run_main_module.js:18:47"
        ]
    }
    w
    • 2
    • 4
  • f

    famous-bear-66383

    06/19/2020, 11:58 AM
    Why
    cert-manager
    chart deployment keeps failing ? A bit of context. I install
    cert-manager
    using his helm chart like the following.
    const certmanager =  new k8s.helm.v2.Chart("cert-manager", {
        repo: "jetstack",
        chart: "cert-manager",
        version: "v0.10.0",
        namespace: "cert-manager",
        values: {
            ingressShim: {
                enabled: true,
                extraArgs: [
                    "--default-issuer-name=letsencrypt-dev",
                    "--default-issuer-kind=ClusterIssuer",
                    "--dns01-recursive-nameservers-only=true"
                ]
            }
        }
    },{dependsOn:[certmanagerSecret]);
    The first
    pulumi up
    was successful, but as soon as I change other resources on the file not related to certmanager it always throws those errors
    error: resource cert-manager-controller-certificates was not successfully created by the Kubernetes API server : <http://clusterroles.rbac.authorization.k8s.io|clusterroles.rbac.authorization.k8s.io> "cert-manager-controller-certificates" already exists
    13:55:21.102[cert-manager-control] failed create kubernetes:<http://rbac.authorization.k8s.io/v1beta1:ClusterRole|rbac.authorization.k8s.io/v1beta1:ClusterRole>
    13:55:26.990[cert-manager-cainjec] Retry #0; creation failed: <http://clusterrolebindings.rbac.authorization.k8s.io|clusterrolebindings.rbac.authorization.k8s.io> "cert-manager-cainjector" already exists
    13:55:26.990[cert-manager-cainjec] error: resource cert-manager-cainjector was not successfully created by the Kubernetes API server : <http://clusterrolebindings.rbac.authorization.k8s.io|clusterrolebindings.rbac.authorization.k8s.io> "cert-manager-cainjector" already exists
    13:55:26.990[cert-manager-cainjec] failed create kubernetes:<http://rbac.authorization.k8s.io/v1beta1:ClusterRoleBinding|rbac.authorization.k8s.io/v1beta1:ClusterRoleBinding>
    13:55:29.808[cert-manager-control] Retry #0; creation failed: <http://clusterroles.rbac.authorization.k8s.io|clusterroles.rbac.authorization.k8s.io> "cert-manager-controller-orders" already exists
    13:55:29.808[cert-manager-control] error: resource cert-manager-controller-orders was not successfully created by the Kubernetes API server : <http://clusterroles.rbac.authorization.k8s.io|clusterroles.rbac.authorization.k8s.io> "cert-manager-controller-orders" already exists
    13:55:29.809[cert-manager-control] failed create kubernetes:<http://rbac.authorization.k8s.io/v1beta1|rbac.authorization.k8s.io/v1beta1>:
    The resources are installed but pulumi detects as new or something and want to install them. is there a way to make this idempotent ?
  • c

    curved-pharmacist-41509

    06/22/2020, 12:36 AM
    Does Pulumi support TypeScript project references? I tried a new project with Pulumi being a referenced project and the root tsconfig just referencing it but it doesn't appear to build the referenced projects?
    l
    • 2
    • 1
  • c

    curved-pharmacist-41509

    06/22/2020, 12:36 AM
    Is there any way instead to have a pre-run build step or anything for me to run
    tsc -b
    ?
    l
    • 2
    • 4
  • s

    salmon-account-74572

    06/22/2020, 8:35 PM
    Bit of a TypeScript newbie here w/ a question on changes necessary to account for "Remove synchronous invokes" in Pulumi 2.x (described at https://www.pulumi.com/docs/get-started/install/migrating-2.0/). I was using
    aws.getAvailabilityZones
    and using the results to a) create an array of strings to capture the AZ names and b) use the
    length
    function on said array of strings to determine how many AZs were in the region. I thought that wrapping the
    aws.getAvailabilityZones
    in
    pulumi.output
    and then using
    apply
    would get me back to working, but it appears not. Code is threaded below.
    f
    • 2
    • 6
  • m

    mammoth-address-60583

    06/25/2020, 6:58 PM
    Hi guys! I am trying to setup an Websocket type API Gateway. I understand I have to use ApiGatewayV2 but I am having a hard time figuring out how to get everything setup. Is there an example of setting this up somewhere?
    👀 1
  • r

    ripe-russia-4239

    06/27/2020, 9:35 PM
    Hi 👋 I’m trying to write a simple test with Pulumi, TypeScript and AVA 🤓 At the moment, the app deliberately only creates a resource group in Azure while I get my tech stack up and running. My tests verify the tags on the resource group (similarly to the unit testing guide in the docs) and the Azure location in which the resource group is created. I’m struggling to test the
    location
    property of the created resource has the value I require, as I’ve set it in my
    Pulumi.yaml
    file and not in the
    new azure.core.ResourceGroup()
    call, as described in the docs. There are two things I can’t work out: • Is
    Pulumi.yaml
    an accepted place to store config common to all stacks in a project?
    A closer reading of the docs suggest
    Pulumi.<stack name>.yaml
    only 🤔 • At what point are the config values used in creating the resource group? I’ve tried modifying my
    newResource
    fake as below, but the
    location
    property stubbornly remains
    undefined
    .
    newResource: (type, name, inputs) => {
      return {
        id: `${inputs.name}_id`,
        state: {
          ...inputs,
          name: inputs.name || name,
          location: inputs.location || config.get("azure:location"),
        },
      };
    }
    
    // ...
    
    const config = new pulumi.Config();
    Is the config, as loaded by Pulumi in the app, available in the test context, or these mock functions? Trying to use an exported config instance leaves me with leaked promises 😞
    • 1
    • 1
  • r

    rhythmic-flag-11093

    06/29/2020, 2:58 AM
    Hey there - complete Pulumi noob here about to get thrown into a project, was wondering why it is when I try this:
    import * as awsx from "@pulumi/awsx";
    
    // Allocate a new VPC with the default settings:
    const vpc = new awsx.ec2.Vpc("custom");
    
    // Export a few resulting fields to make them easy to use:
    export const vpcId = vpc.id;
    export const vpcPrivateSubnetIds = vpc.privateSubnetIds;
    export const vpcPublicSubnetIds = vpc.publicSubnetIds;
    from here: https://www.pulumi.com/docs/guides/crosswalk/aws/vpc/ I get this error:
    index.ts(6,13): error TS2554: Expected 2-3 arguments, but got 1.
    It's referring to this line
    const vpc = new awsx.ec2.Vpc("custom");
    Any feedback is appreciated
    l
    • 2
    • 7
  • l

    little-cartoon-10569

    06/30/2020, 1:45 AM
    I'm unit testing my ComponentResources using Mocha and async functions. I call
    expect()
    directly from the async function (passed as a parameter to
    it()
    ), unless there's an
    Output
    or
    Promise
    involved, in which case I call
    expect()
    from within an
    apply()
    . When everything passes, all good. And tests without
    apply
    fail, all is good too: Test Explorer shows me my errors. But when an
    expect()
    inside an
    apply()
    fails, Test Explorer shows the test as passing. I see the error message in VSCode's Output window, or in the console if that's where I running them, but Test Explorer isn't noticing that there was a failed
    expect()
    . The failures always show up as *UnhandledPromiseRejectionWarning*s. What am I doing wrong?
    f
    • 2
    • 13
  • l

    little-cartoon-10569

    07/01/2020, 1:24 AM
    I have this code:
    return pulumi.all([this.vpc.publicSubnets, this.vpc.privateSubnets, this.vpc.isolatedSubnets]).apply(([pub, pri, iso]) => {
      // ...
    });
    That's all good in VSCode, Pulumi CLI, and Mocha (when called from VSCode's Test Explorer). But when I run my tests from the command line, I'm getting implicit-any errors:
    main/pulumi/resources/Vpc.ts:72:108 - error TS7031: Binding element 'pub' implicitly has an 'any' type.
    72     return pulumi.all([this.vpc.publicSubnets, this.vpc.privateSubnets, this.vpc.isolatedSubnets]).apply(([pub, pri, iso]) => {
    What might cause this? My tsconfig.json files are almost identical (the test one has an additional glob in the include section for the test directory), my package.json's scripts.test section is pretty straightforward
    "scripts": {
        "compile": "tsc",
        "lint": "node_modules/tslint/bin/tslint --project tsconfig.json",
        "prepare": "npm run compile",
        "test": "env TS_NODE_PROJECT=\"tsconfig.test.json\" node --trace-warnings --unhandled-rejections=strict node_modules/mocha/bin/_mocha --config test/mocha/.mocharc.json",
      },
    I have no idea what I'm doing wrong...
    m
    • 2
    • 5
  • m

    many-dress-88879

    07/07/2020, 11:30 PM
    any body know which pulumi resources i do need to use for this change?
    gsutil iam ch \
      serviceAccount:service-PROJECT_NUM@cloud-cdn-fill.iam.gserviceaccount.com:objectViewer \
      gs://[BUCKET]
    h
    • 2
    • 5
  • d

    dazzling-sundown-39670

    07/08/2020, 1:50 PM
    How would I push to this registry I've created on Digitalocean?
    const registry = new digitalocean.ContainerRegistry(appName)
    
    const credentials = new digitalocean.ContainerRegistryDockerCredentials(appName, {
      registryName: registry.name,
    });
    
    const image = new docker.Image(appName, {
      build: '../',
      imageName: appName,
      registry: ???, // What to put here?
    })
    m
    g
    • 3
    • 6
  • q

    quiet-hairdresser-18834

    07/11/2020, 12:54 PM
    I have a fun one. I have an extension to domain join a VM. This requires a domain admin password. I do not want that stored in my config (even as a secret) as it is too sensitive to put there. Storing as an environment variable also seems like a bad idea. Is there a way to prompt the user for that credential only if the resource needs to be created? I have not really tried anything yet as I wanted to see if this was something I should even attempt or if there is a better pattern for this!
  • w

    white-rainbow-68240

    07/13/2020, 1:08 PM
    Anyone who knows how I can install private npm packages via github actions? I'm using a github ssh link
    "foo-abc": "<git+ssh://git>@github.com/my-co/foo-abc.git#v1.0.1"
    The relevant yaml for my github workflow looks like this:
    - name: setup ssh
            env:
              SSH_AUTH_SOCK: /tmp/ssh_agent.sock
            run: |
              mkdir -p ~/.ssh
              ssh-keyscan <http://github.com|github.com> >> ~/.ssh/known_hosts
              ssh-agent -a $SSH_AUTH_SOCK > /dev/null
              ssh-add - <<< "${{ secrets.GH_PRIVATE_SSH }}"
          - name: npm install
            env:
              SSH_AUTH_SOCK: /tmp/ssh_agent.sock
            run: npm install
    m
    • 2
    • 10
  • w

    white-rainbow-68240

    07/13/2020, 1:09 PM
    I just don't know how to get the ssh stuff into the infra.
  • w

    white-rainbow-68240

    07/13/2020, 1:10 PM
    I'm using AWS ECS.
Powered by Linen
Title
w

white-rainbow-68240

07/13/2020, 1:10 PM
I'm using AWS ECS.
View count: 1