Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ec2] Volume construct throws with fresh CDK app #9081

Closed
ddneilson opened this issue Jul 15, 2020 · 4 comments · Fixed by #9082
Closed

[ec2] Volume construct throws with fresh CDK app #9081

ddneilson opened this issue Jul 15, 2020 · 4 comments · Fixed by #9082
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. in-progress This issue is being actively worked on. needs-reproduction This issue needs reproduction.

Comments

@ddneilson
Copy link
Contributor

ddneilson commented Jul 15, 2020

If you have an app with an aws-ec2.Volume within it, then that app will throw a failed validation exception during the first fresh run of the app. This is because the VPC is not set up with true availability zones during this first run; instead it is set up with a dummy VPC -

const DUMMY_VPC_PROPS: cxapi.VpcContextResponse = {

Reproduction Steps

  1. Set up my AWS temp credentials.
  2. mkdir ebs_test; cd ebs_test
  3. npx cdk@1.51.0 init --language=typescript app
  4. Modify package.json to include "@aws-cdk/aws-ec2": "1.51.0", as a dependency
  5. Copy repro case from below into bin/ebs_test.ts (overwriting existing contents)
import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
const app = new cdk.App();
const env = {
    account: process.env.CDK_DEFAULT_ACCOUNT,
    region: process.env.CDK_DEFAULT_REGION
}
const stack = new cdk.Stack(app, 'Testing', { env });
const vpc = new ec2.Vpc(stack, 'Vpc');
new ec2.Volume(stack, 'Volume', {
  availabilityZone: vpc.availabilityZones[0],
  size: cdk.Size.gibibytes(8),
});
  1. npx cdk@1.51.0 deploy Testing

Error Log

`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token

Environment

  • CLI Version : 1.49.1+
  • Framework Version: 1.49.1+
  • Node.js Version: v10.16.3
  • OS : Linux
  • Language (Version): all

Other

The Volume code was introduced in #8219


This is 🐛 Bug Report

@ddneilson ddneilson added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 15, 2020
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Jul 15, 2020
@ericzbeard
Copy link
Contributor

ericzbeard commented Jul 15, 2020

@ddneilson I was not able to repro this issue with 1.51 in us-east-1. The stack created with no errors.

@ericzbeard ericzbeard added needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 15, 2020
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Jul 15, 2020
@ddneilson
Copy link
Contributor Author

@ddneilson I was not able to repro this issue with 1.51 in us-east-1. The stack created with no errors.

@ericzbeard Don't know what to tell you. I can reproduce it every time I try...

0) Set up my AWS temp credentials.

1) mkdir ebs_test; cd ebs_test

2) npx cdk@1.51.0 init --language=typescript app

3) Modify package.json to include "@aws-cdk/aws-ec2": "1.51.0", as a dependency

4) Copy repro case from above into bin/ebs_test.ts (overwriting existing contents)

5) yarn install

6) npx cdk@1.51.0 deploy Testing
npx: installed 217 in 3.547s
`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token

@NetaNir
Copy link
Contributor

NetaNir commented Jul 16, 2020

When the cdk.context.json file does not exist, like in the case of the first run of a fresh application, the value will be dummy until it will be resolved by the CLI. This the expected behavior, the volume construct should not validate the availabilityZones at all, additionally the dummy# values should not be relied on, as they are not a part of the public API. The right solution here is to remove the validation from the construct.

@ddneilson
Copy link
Contributor Author

When the cdk.context.json file does not exist, like in the case of the first run of a fresh application, the value will be dummy until it will be resolved by the CLI. This the expected behavior, the volume construct should not validate the availabilityZones at all, additionally the dummy# values should not be relied on, as they are not a part of the public API. The right solution here is to remove the validation from the construct.

That's certainly easy. Will get that up right now as a change to the attached PR.

@mergify mergify bot closed this as completed in #9082 Jul 16, 2020
mergify bot pushed a commit that referenced this issue Jul 16, 2020
This fixes an erroneous validation failure of the `availabilityZone` property of the `Volume` construct that occurs during the first run of a fresh application.

Fixes: #9081
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this issue Aug 11, 2020
This fixes an erroneous validation failure of the `availabilityZone` property of the `Volume` construct that occurs during the first run of a fresh application.

Fixes: aws#9081
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. in-progress This issue is being actively worked on. needs-reproduction This issue needs reproduction.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants