aws-cdk: [pipelines] Metadata errors should fail synthesis (on stacks deployed in the pipeline)

This issue is similar to https://github.com/aws/aws-cdk/issues/5594 however, occurs without nested stacks. Instead, I have a cross-account CdkPipeline setup according to the minimal example from the documentation. My Stack consists only of a simple VPC.

When deploying, the CloudFormation template in the target account still contains the dummy1a, dummy1b etc. AZs. Finally, these are reported as invalid and my stack is rolled back.

Reproduction Steps

pipeline.addApplicationStage(new MyApplication(this, 'Dev', {
      env: {
        account: '11111111111',
        region: 'eu-west-1',
      }
    }));

Where MyApplication consist of a single stack with only new VPC(this, 'VPCName')

Error Log

Value (dummy1a) for parameter availabilityZone is invalid. Subnets can currently only be created in the following availability zones: eu-west-1a, eu-west-1b, eu-west-1c. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue

Environment

  • CLI Version : 1.54.0
  • Framework Version: 1.54.0
  • Node.js Version: 14.4.0
  • OS :
  • Language (Version): TypeScript (3.8.3)

Other


This is 🐛 Bug Report

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 36
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@moshir Try setting the AZs in your context. You can do this through the context file very easily:

{
  "availability-zones:account=<your account id>:region=eu-west-1": [
    "eu-west-1a",
    "eu-west-1b",
    "eu-west-1c"
  ]
}

Pipelines does not currently support lookups.

(From the blog)

Developer preview limitations CDK Pipelines is currently in developer preview. AWS is working to lift some limitations, but you should keep the following in mind:

No context queries – Context queries are not supported. That means that Vpc.fromLookup() and other functions like it don’t work.

Are there any plans to support lookups like @aws-cdk/aws-ec2.Vpc.fromLookup() in @aws-cdk/pipelines anytime soon?

If you run cdk deploy from your local, it should populate the cdk.context.json file with AZ info you can use as a template for additional regions, etc.

I changed the title and made it a feature request.

What’s the current/recommended way to create a VPC in a pipeline ?

@njdancer You are right, this is not a workaround but rather an offline solution. An alternative would be to perform this lookup yourself via the AWS SDK, but then you could run into issues with the cross account setup.