Search code examples
pulumi

how can I create InternetGateway with Pulumi


I have a problem that I can't create InternetGateway with pulumi when execute pulumi up.

even if I execute pulumi up, the Execution result will be above sentence. my ideal is (read) → (create).

code is following.

const vpc = new aws.ec2.Vpc("custom1-vpc", {
            cidrBlock: "10.51.0.0/16",
            enableDnsHostnames: true,
            enableClassiclinkDnsSupport: true,
            instanceTenancy: "default",
            tags: {
                Name: "custom1-vpc"
            }
        });

const internatGateway = new aws.ec2.InternetGateway("custom1_gateway", {
            vpcId: vpc.id
        }, vpc);

result is following.

Do you want to perform this update? details
+ pulumi:pulumi:Stack: (create)
    [urn=urn:pulumi:pulumi-with-typescript::typescriptPulumi::pulumi:pulumi:Stack::typescriptPulumi-pulumi-with-typescript]
    + aws:ec2/vpc:Vpc: (create)
        [urn=urn:pulumi:pulumi-with-typescript::typescriptPulumi::aws:ec2/vpc:Vpc::custom1-vpc]
        assignGeneratedIpv6CidrBlock: false
        cidrBlock                   : "10.51.0.0/16"
        enableClassiclinkDnsSupport : true
        enableDnsHostnames          : true
        enableDnsSupport            : true
        instanceTenancy             : "default"
        tags                        : {
            Name      : "custom1-vpc"
        }
    > aws:ec2/internetGateway:InternetGateway: (read)
        [urn=urn:pulumi:pulumi-with-typescript::typescriptPulumi::aws:ec2/internetGateway:InternetGateway::custom1_gateway]
        vpcId: output<string>

Solution

  • You shouldn't specify vpc as the third parameter. Just run this:

    const internatGateway = new aws.ec2.InternetGateway("custom1_gateway", {
         vpcId: vpc.id
    });