Hi,
in
terraform/builtin/providers/aws/resource_aws_instance.go
the parameter
associate_public_ip_address
is always associating a public ip-address even when set to false.
associate_public_ip_address = false
I have no idea of Golang even though its looking like a fascination programming language.
Can somebody correct this behavior?
Thanks
Peter
Hi @P13612
Please can you supply a sample of the config that you are using and we can see if this bug can be reproduced?
Thanks
Paul
Hi Paul,
so quick? Thank you. Here is your example:
resource "aws_instance" "app" {
ami = "${var.anylinuxami}"
instance_type = "t2.micro"
associate_public_ip_address = false
subnet_id = "${aws_subnet.private_1.id}"
private_ip = "10.130.0.7"
security_groups = ["default"]
key_name = "${var.key_name}"
tags {
Name = "APP"
}
}
It's fairly straightforward. It's simply an instance inside a private subnet.
Thank you for your quick response again
Peter
Hi @P13612
I believe this is the issue. You are trying to assign a public_ip to an instance in a private_subnet. I would take a punt and suggest that the private_subnet doesn't actually create public_ip address
Paul
Hi Paul,
but I'm doing this:
associate_public_ip_address = false
subnet_id = "${aws_subnet.private_1.id}"
private_ip = "10.130.0.7"
I'm associating a private IP and I want no public IP therefore I set
associate_public_ip_address = false
I even didn't use this parameter at all and still I get a public IP
Peter
Hi @P13612
Apologies - ok so can you show me the configuration that creates a subnet?
Paul
Sure,
resource "aws_subnet" "private_1" {
vpc_id = "${aws_vpc.vpc.id}"
cidr_block = "10.130.0.0/27"
availability_zone = "us-west-1a"
map_public_ip_on_launch = true
tags {
Name = "myprivatesubnet"
}
}
oops! Is this my problem?
map_public_ip_on_launch = true
Peter
That's the issue :)
Hi Paul,
I dropped the line and all is fine.
Thank you
Peter
Nice one! Thanks for letting me know
this happened to me and some other people on the interwebtz as well it seems. maybe worth noting in the docs?
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
this happened to me and some other people on the interwebtz as well it seems. maybe worth noting in the docs?