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

aws_ec2: assigning of public IP is not disabled #26120

Closed
IllarionovDimitri opened this issue Jun 26, 2023 · 3 comments
Closed

aws_ec2: assigning of public IP is not disabled #26120

IllarionovDimitri opened this issue Jun 26, 2023 · 3 comments
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@IllarionovDimitri
Copy link

IllarionovDimitri commented Jun 26, 2023

Describe the bug

I want to deploy ec2 instance into public subnet but disable the assignment of public IP.

Since the instances are part of ASG first I tried with

aws_autoscaling.AutoScalingGroup(
    self,
    ...
    associate_public_ip_address=False
    ...
)

But since I define ASG via mixed_instances_policy and launch_template props, I got an error

RuntimeError: Setting 'associatePublicIpAddress' must not be set when 'launchTemplate' or 'mixedInstancesPolicy' is set

There is no prop in ec2.LaunchTemplate to disable the public ip, so I went to the subnet configuration

ec2.SubnetConfiguration(
            name=f"{config.ID}-public",
            subnet_type=ec2.SubnetType.PUBLIC,
            map_public_ip_on_launch=False,
            cidr_mask=24,
        )

After I've re-deployed the stack, Auto-assign public IPv4 address was still set to Yes and the instance was assigned the public IP.

Bildschirmfoto 2023-06-26 um 16 58 18

Expected Behavior

  1. Setting of map_public_ip_on_launch=False disables auto assignment of public IPs
  2. If it is not possible to use associate_public_ip_address in aws_autoscaling.AutoScalingGroup, the property should be available in launch template.

Current Behavior

See section "Describe the bug"

Reproduction Steps

EC2 instance must be deployed in the public subnet, where subnet setting defined as follows

ec2.SubnetConfiguration(
            name=f"{config.ID}-public",
            subnet_type=ec2.SubnetType.PUBLIC,
            map_public_ip_on_launch=False,
            cidr_mask=24,
        )

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.85.0

Framework Version

No response

Node.js Version

18

OS

Ubuntu 20.04

Language

Python

Language Version

3.10.6

Other information

No response

@IllarionovDimitri IllarionovDimitri added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Jun 26, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@lenfree
Copy link

lenfree commented Aug 11, 2023

Any updates on this?

@IllarionovDimitri
Copy link
Author

IllarionovDimitri commented Aug 11, 2023

not an issue, works fine. was re-deploying the wrong stack, therefore closed this issue

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. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants