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

feat(ec2): explicit mapPublicIpOnLaunch configuration for public subnets #17346

Merged
merged 14 commits into from
Nov 29, 2021
Merged

feat(ec2): explicit mapPublicIpOnLaunch configuration for public subnets #17346

merged 14 commits into from
Nov 29, 2021

Conversation

hguillermo
Copy link
Contributor

@hguillermo hguillermo commented Nov 5, 2021

Issue (Fixes #14194, #16838)
When creating a VPC you can define a SubnetConfiguration but it is not possible to define mapPublicIpOnLaunch for public subnets.

VPC Example:

        const vpc = new ec2.Vpc(this, 'vpc-id', {
            maxAzs: 2,
            subnetConfiguration: [
                {
                    name: 'private-subnet-1',
                    subnetType: ec2.SubnetType.PRIVATE,
                    cidrMask: 24,
                },
                {
                    name: 'public-subnet-1',
                    subnetType: ec2.SubnetType.PUBLIC,
                    cidrMask: 24,
                },
            ]
        });

Proposal:

        const vpc = new ec2.Vpc(this, 'vpc-id', {
            maxAzs: 2,
            subnetConfiguration: [
                {
                    name: 'private-subnet-1',
                    subnetType: ec2.SubnetType.PRIVATE,
                    cidrMask: 24,
                },
                {
                    name: 'public-subnet-1',
                    subnetType: ec2.SubnetType.PUBLIC,
                    cidrMask: 24,
                    mapPublicIpOnLaunch: false, // or true
                },
            ]
        });

@gitpod-io
Copy link

gitpod-io bot commented Nov 5, 2021

@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Nov 5, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 5, 2021

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@hguillermo hguillermo changed the title VPC SubnetConfiguration should allow mapPublicIpOnLaunch for public subnets feat(aws-ec2): VPC SubnetConfiguration should allow mapPublicIpOnLaunch for public subnets Nov 5, 2021
@hguillermo hguillermo marked this pull request as ready for review November 5, 2021 03:04
Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

Looks good; can you please add a test for the behaviors? Both happy case and the error condition.

@mergify mergify bot dismissed njlynch’s stale review November 16, 2021 19:23

Pull request has been modified.

@hguillermo
Copy link
Contributor Author

@njlynch Added some tests. What do you think?

@hguillermo
Copy link
Contributor Author

@njlynch This is ready for review/merge. Thanks

@njlynch njlynch changed the title feat(aws-ec2): VPC SubnetConfiguration should allow mapPublicIpOnLaunch for public subnets feat(ec2): explicit mapPublicIpOnLaunch configuration for public subnets Nov 29, 2021
@njlynch njlynch added the pr-linter/exempt-readme The PR linter will not require README changes label Nov 29, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 29, 2021

Thank you for contributing! Your pull request will be updated from master 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
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 471bbf3
  • 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 a1685c6 into aws:master Nov 29, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 29, 2021

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

@hguillermo hguillermo deleted the vpc-subnet-configuration-public-map-ip-at-launch branch November 29, 2021 17:38
pedrosola pushed a commit to pedrosola/aws-cdk that referenced this pull request Dec 1, 2021
…ets (aws#17346)

**Issue (Fixes aws#14194, aws#16838
When creating a VPC you can define a SubnetConfiguration but it is not possible to define `mapPublicIpOnLaunch` for public subnets.

VPC Example:
```
        const vpc = new ec2.Vpc(this, 'vpc-id', {
            maxAzs: 2,
            subnetConfiguration: [
                {
                    name: 'private-subnet-1',
                    subnetType: ec2.SubnetType.PRIVATE,
                    cidrMask: 24,
                },
                {
                    name: 'public-subnet-1',
                    subnetType: ec2.SubnetType.PUBLIC,
                    cidrMask: 24,
                },
            ]
        });
```

Proposal:
```
        const vpc = new ec2.Vpc(this, 'vpc-id', {
            maxAzs: 2,
            subnetConfiguration: [
                {
                    name: 'private-subnet-1',
                    subnetType: ec2.SubnetType.PRIVATE,
                    cidrMask: 24,
                },
                {
                    name: 'public-subnet-1',
                    subnetType: ec2.SubnetType.PUBLIC,
                    cidrMask: 24,
                    mapPublicIpOnLaunch: false, // or true
                },
            ]
        });
```
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ets (aws#17346)

**Issue (Fixes aws#14194, aws#16838
When creating a VPC you can define a SubnetConfiguration but it is not possible to define `mapPublicIpOnLaunch` for public subnets.

VPC Example:
```
        const vpc = new ec2.Vpc(this, 'vpc-id', {
            maxAzs: 2,
            subnetConfiguration: [
                {
                    name: 'private-subnet-1',
                    subnetType: ec2.SubnetType.PRIVATE,
                    cidrMask: 24,
                },
                {
                    name: 'public-subnet-1',
                    subnetType: ec2.SubnetType.PUBLIC,
                    cidrMask: 24,
                },
            ]
        });
```

Proposal:
```
        const vpc = new ec2.Vpc(this, 'vpc-id', {
            maxAzs: 2,
            subnetConfiguration: [
                {
                    name: 'private-subnet-1',
                    subnetType: ec2.SubnetType.PRIVATE,
                    cidrMask: 24,
                },
                {
                    name: 'public-subnet-1',
                    subnetType: ec2.SubnetType.PUBLIC,
                    cidrMask: 24,
                    mapPublicIpOnLaunch: false, // or true
                },
            ]
        });
```
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 pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(ec2): Add option to turn Auto-assign public IPv4 address off for public subnets
3 participants