Skip to content

feat(aws-ec2): control over VPC AZs#20562

Merged
mergify[bot] merged 2 commits intoaws:mainfrom
philipmw:vpc
Jun 6, 2022
Merged

feat(aws-ec2): control over VPC AZs#20562
mergify[bot] merged 2 commits intoaws:mainfrom
philipmw:vpc

Conversation

@philipmw
Copy link
Copy Markdown
Contributor

@philipmw philipmw commented Jun 1, 2022

With this change, the Vpc construct gains a new constructor prop,
availabilityZones, which gives more control over AZs than the existing
maxAzs prop.

closes #5847


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jun 1, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team June 1, 2022 02:59
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Jun 1, 2022
*
* This option overrides `maxAzs`.
*
* @default (a subset of) AZs of the stack
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @default (a subset of) AZs of the stack
* @default - a subset of AZs of the stack

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Comment on lines +608 to +612
for (let i = 1; i < 2; i++) {
Template.fromStack(stack).hasResourceProperties('AWS::EC2::Subnet', {
AvailabilityZone: `${stack.region}b`,
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this loop doesn't do anything, should be:

Suggested change
for (let i = 1; i < 2; i++) {
Template.fromStack(stack).hasResourceProperties('AWS::EC2::Subnet', {
AvailabilityZone: `${stack.region}b`,
});
}
Template.fromStack(stack).hasResourceProperties('AWS::EC2::Subnet', {
AvailabilityZone: `${stack.region}b`,
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that was a thoughtless copy-paste. Fixed.


this.availabilityZones = stack.availabilityZones;
if (props.availabilityZones) {
this.availabilityZones = props.availabilityZones;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect there is validation that should be done on this parameter, to ensure there are no deployment time issues.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done.

@comcalvi comcalvi self-assigned this Jun 1, 2022
Copy link
Copy Markdown
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a feature, please add an integ test for this feature.

@philipmw
Copy link
Copy Markdown
Contributor Author

philipmw commented Jun 3, 2022

Thanks for the review, @comcalvi . I made the changes you suggested.

comcalvi
comcalvi previously approved these changes Jun 3, 2022
Copy link
Copy Markdown
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@mergify mergify bot dismissed comcalvi’s stale review June 3, 2022 23:23

Pull request has been modified.

@philipmw
Copy link
Copy Markdown
Contributor Author

philipmw commented Jun 3, 2022

@comcalvi Thanks. I don't know if I messed it up, but the branch was out of date so I merged main into it. Now it needs another review from you. Would you please?

With this change, the `Vpc` construct gains a new constructor prop,
`availabilityZones`, which gives more control over AZs than the existing
`maxAzs` prop.

closes aws#5847
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jun 6, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 9da7c89
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 58dffd8 into aws:main Jun 6, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jun 6, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@fitzoh fitzoh mentioned this pull request Jun 14, 2022
2 tasks
@philipmw philipmw deleted the vpc branch June 16, 2022 16:52
daschaa pushed a commit to daschaa/aws-cdk that referenced this pull request Jul 9, 2022
With this change, the `Vpc` construct gains a new constructor prop,
`availabilityZones`, which gives more control over AZs than the existing
`maxAzs` prop.

closes aws#5847


----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@AlJohri
Copy link
Copy Markdown

AlJohri commented May 24, 2025

It would be great to alternatively support availabilityZoneIds parameter. This is already supported by CfnSubnet: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnSubnet.html#availabilityzoneid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control over VPC AZs

4 participants