hi everyone, i'm kicking the tires with pulumi-cdk...
# pulumi-cdk
c
hi everyone, i'm kicking the tires with pulumi-cdk and I'm running into an issue with what appears to the
Vpc.fromLookup
method. Anyone else bump into this problem? I have an existing VPC that I want to use but Pulumi is erroring out and is instead using a placeholder VPC reference (vpc-12345)
Copy code
Diagnostics:
  aws:lb:TargetGroup (ServiceLBPublicListenerECSGroup0CC8688C):
    error: 1 error occurred:
    	* creating LB Target Group: ValidationError: The VPC ID 'vpc-12345' is not found
    	status code: 400, request id: 5b58926c-338e-41e0-b0f8-10e7588ce64a

  aws:ec2:SecurityGroup (ServiceSecurityGroupEEA09B68):
    error: 1 error occurred:
    	* creating Security Group (ServiceSecurityGroupEEA09B68-b2c605f): InvalidVpcID.NotFound: The vpc ID 'vpc-12345' does not exist
    	status code: 400, request id: de44e778-78ef-4a97-bdfa-14a64a294ae0

  aws:ec2:SecurityGroup (ServiceLBSecurityGroupF7435A5C):
    error: 1 error occurred:
    	* creating Security Group (ServiceLBSecurityGroupF7435A5C-f054950): InvalidVpcID.NotFound: The vpc ID 'vpc-12345' does not exist
    	status code: 400, request id: 2260d61e-dfd3-4db4-9332-7110ce670c5c

  pulumi:pulumi:Stack (pulumi-spike-demo):
    error: update failed
Code:
Copy code
class FargateStack extends pulumicdk.Stack {
    clusterArn: pulumi.Output<string>;
    serviceArn: pulumi.Output<string>;

    constructor(id: string, options?: pulumicdk.StackOptions) {
        super(id, options);

        const vpc = ec2.Vpc.fromLookup(this, "VPC", {
            vpcId: "vpc-000000aaaaaab",
        });

        const service = new ecsPatterns.ApplicationLoadBalancedFargateService(
            this,
            "Service",
            {
                vpc,
                cpu: 512,
                memoryLimitMiB: 1024,
                desiredCount: 1,
                taskImageOptions: {
                    image: ecs.ContainerImage.fromRegistry(
                        "amazon/amazon-ecs-sample"
                    ),
                },
            }
        );

        this.clusterArn = this.asOutput(service.cluster.clusterArn);
        this.serviceArn = this.asOutput(service.service.serviceArn);

        this.synth();
    }
}

new FargateStack("FargateStack", {
    props: {
        env: {
            region: "us-west-2",
            account: "1234567890",
        },
    },
});
m
Were you able to resolve this? I just tried this myself, and I was able to find a VPC with what looks like the same code using an ID I know exists.
Ohh, wait — I think I see what you mean now — the ARN of the looked-up VPC has
vpc-12345
tacked onto the end.
Looks like this may be a CDK issue. Digging a bit.
Yeah — if you Google “vpc-12345”, you’ll see this mentioned in several CDK GitHub issues. 🤔
Not clear what the workaround would be here, though, since that
ApplicationLoadBalancedFargateService
needs a CDK
IVpc
. Curious what you came up with, if anything!
c
It's quite odd because the exact same code works with CDK and I even tried copying over the
cdk.context.json
that it generated to the Pulumi project and it didn't work so something must be preventing these context lookups. But as a workaround, the
fromVpcAttributes
works but it's not nearly as convenient as
fromLookup
. I also suspect that other modules that have their own
fromLookup
method might fail for the same reasons