Thread
#aws
    i

    important-australia-792

    3 months ago
    Hi all, new to Pulumi here, your patience is appreciated, coming from tf. I'm using an example from the website, using awsx.ec2.Vpc to create a VPC. When I run pulumi up once, it works, when I run pulumi up a second time, the typescript compiler complains and fails.
    import * as pulumi from "@pulumi/pulumi";    
    import * as aws from "@pulumi/aws";    
    import * as awsx from "@pulumi/awsx";    
        
    const vpc = new awsx.ec2.Vpc("custom", {    
      subnetSpecs:[    
        {    
          type: awsx.ec2.SubnetType.Public,    
          cidrMask: 22,    
        },    
        {    
          type: awsx.ec2.SubnetType.Private,    
          cidrMask: 20,    
        },    
      ],    
    });
    The errors i'm receiving are:
    Diagnostics:
      pulumi:pulumi:Stack (vpc-dev):
        error: Running program '/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc' failed with an unhandled exception:
        TSError: ⨯ Unable to compile TypeScript:
        index.ts(6,3): error TS2345: Argument of type '{ subnetSpecs: { type: any; cidrMask: number; }[]; }' is not assignable to parameter of type 'VpcArgs | ExistingVpcArgs | ExistingVpcIdArgs'.
          Object literal may only specify known properties, and 'subnetSpecs' does not exist in type 'VpcArgs | ExistingVpcArgs | ExistingVpcIdArgs'.
        index.ts(8,22): error TS2339: Property 'SubnetType' does not exist on type 'typeof import("/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/node_modules/@pulumi/awsx/ec2/index")'.
        index.ts(12,22): error TS2339: Property 'SubnetType' does not exist on type 'typeof import("/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/node_modules/@pulumi/awsx/ec2/index")'.
        
            at createTSError (/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/node_modules/ts-node/src/index.ts:261:12)
            at getOutput (/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/node_modules/ts-node/src/index.ts:367:40)
            at Object.compile (/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/node_modules/ts-node/src/index.ts:558:11)
            at Module.m._compile (/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/node_modules/ts-node/src/index.ts:439:43)
            at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
            at Object.require.extensions.<computed> [as .ts] (/mnt/storage/Cody/projects/grizzlyforce/pulumi/vpc/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)
    Here were the outputs from the previous run to show that it did launch the first time:
    Outputs:
      - vpcId            : "vpc-0f42382f75c6d7a70"
      - vpcPrivateSubnets: [
      -     [0]: "subnet-0634fa67343a153e7"
      -     [1]: "subnet-0bb0cbf6bc1078b1b"
        ]
      - vpcPublicSubnets : [
      -     [0]: "subnet-0a7f9f9da8c3043e6"
      -     [1]: "subnet-0fe54f1016b4aa906"
        ]
    My tsconfig
    {
      "compilerOptions": {
        "strict": true,
        "outDir": "bin",
        "target": "es2016",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "experimentalDecorators": true,
        "pretty": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "forceConsistentCasingInFileNames": true
      },
      "files": [
        "index.ts"
      ]
    }
    i haven't made any changes to the tsconfig or the sample code, i just simply tried to run it a second time.
    l

    little-cartoon-10569

    3 months ago
    What version of awsx are you using?
    i

    important-australia-792

    3 months ago
    pulumi 3.34.1 awx 0.40.0 they were the default installed when using the one-line install
    and aws 5.8.0, in case it matters if i upgrade awsx version
    i'm sort of confused why it would work once and then fail the second time
    if i destroy and delete the stack, and then provision again, it works, but then fails on subsequent runs again
    l

    little-cartoon-10569

    3 months ago
    awsx 0.40 is the old version; all the docs still describe it, it's what I use. I don't think subnetSpec is part of that API, is it? I can't see it, I see just subnets: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/awsx/ec2/#VpcArgs-subnets
    Where did you see
    subnetSpec
    ?
    i

    important-australia-792

    3 months ago
    half way down the page under "Configuring Subnets for a VPC"
    maybe the documenation was updated early?
    l

    little-cartoon-10569

    3 months ago
    Yea maybe, let's find the API for awsx 1.0.
    i

    important-australia-792

    3 months ago
    l

    little-cartoon-10569

    3 months ago
    Yep, I see SubnetSpec in there. Try changing your awsx version in package.json
    i

    important-australia-792

    3 months ago
    i know its a beta, but its like beta 8, to me that would seem fairly stable?
    maybe you're right and i should just push the version forward
    l

    little-cartoon-10569

    3 months ago
    It's either that or change the syntax to be 0.40 compliant. It's very similar, a minor change.
    I'd roll forward though.
    i

    important-australia-792

    3 months ago
    as a first experience, this does not spark joy
    l

    little-cartoon-10569

    3 months ago
    You missed
    nodejs
    i

    important-australia-792

    3 months ago
    cheers
    it looks like the path changed during that upgrade as well, 1.0.0 is no longer in nodejs folder
    Thanks for your help @little-cartoon-10569 👍 super appreciated sir. You provided me with a new way to discover issues as well, I didn't go read the code before but this broke the ice.