-
Notifications
You must be signed in to change notification settings - Fork 110
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
amazon: Impossible to associate public IP in default subnet w/o auto-assign public IP #18
Comments
Having the same issue since "AWS Foundational Security Best Practices v1.0.0" recommends removing auto assigning public IP addresses in public subnets. Removing the |
For me, this resolved it:
Then it was launched in a public subnet (which is necessary to allow public IPs) and with a public IP (which for my environment was disabled by default for security). Problem solved. |
That works, but then you have to know the subnet id beforehand, it should work without it as well. |
@v3rm0n How would it know what subnet to put it in? It would need to be a public subnet in order to be assigned a public IP. What would you prefer, that it would find a random public subnet to put it in? |
Yeah, random subnet from default VPC is fine for my use case. |
My use case is, I need set But seems if I set
|
If use But if My understand is, it should always go in if condition, never need So this line
Need be changed to
I am not golang developer, not sure how to change a plugin, and build with packer core. Any hints? |
Is there any timeline for addressing this bug? As it stands this means that Packer is incompatible with AWS Foundational Security Best Practices controls as documented at https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-fsbp-controls.html#fsbp-ec2-15 / https://docs.aws.amazon.com/config/latest/developerguide/subnet-auto-assign-public-ip-disabled.html which states "[EC2.15] EC2 subnets should not automatically assign public IP addresses". |
To expand upon this, if you want to lookup a random subnet on your default you can do the following: vpc_filter {
filters = {
"isDefault": "true"
}
}
# https://github.com/hashicorp/packer-plugin-amazon/issues/18
# https://github.com/hashicorp/packer/issues/6589
# https://github.com/hashicorp/packer-plugin-amazon/blob/main/builder/common/step_run_source_instance.go#L186
# https://github.com/hashicorp/packer-plugin-amazon/blob/main/builder/common/step_network_info.go#L86
# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html
associate_public_ip_address = true
subnet_filter {
most_free = true
random = true
filters = {
"subnet-id": "*"
}
} |
this is still reproducible on v1.1.5 amazon plugin. Workaround from neechbear still applies however |
This issue has been synced to JIRA for planning. JIRA ID: HPR-1056 |
Hi all, I can spend some time on this. Just to be clear on my side, the issue is that unless the subnet id i explicitly set, the instance won't get a public ip address. |
Hey everyone, I'm working on this feature now, from what I gather, and to @Glyphack's point, it looks like the main problem here is that the I'll rework the logic that manages that, and try to come up with acceptance tests so we can check that it works as expected. I'll keep this issue up-to-date on that, and hopefully come up with a PR to fix this in the coming days. |
This issue was originally opened by @emcpow2 as hashicorp/packer#6589. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
Packer v1.2.5
Builder type
amazon-ebs
Assuming default networking setup.
Steps to reproduce:
Auto-assign public IPv4 address
in its default subnetsvpc_id
andsubnet_id
in default values(unset)associate_public_ip
to trueMore information
associate_public_ip_address
: true
does not work here, because based on source code it only takes effect ifsubnet_id
(orvpc_id
) is specified.https://github.com/hashicorp/packer/blob/v1.2.5/builder/amazon/common/step_run_source_instance.go#L157-L167
associate_public_ip_address
must work for default VPC in spite of disabledAuto-assign public IPv4 address
.The text was updated successfully, but these errors were encountered: