I am looking at this documentation and cannot determine the default value for the field associate_public_ip_address
thx
Alan
I am looking at this documentation and cannot determine the default value for the field associate_public_ip_address
thx
Alan
Logically, it should be false. But I can’t find the actual reference in the SDK.
Seems to default to true.
I’m necroing a 5 year old thread because somehow it’s still the top result for this subject and its answer is incomplete.
The Short Answer:
associate_public_ip_address
does not have a stateless default. It defaults to the behavior of the subnet it’s in, with relation to themap_public_ip_on_launch
attribute.
My Reasoning:
associate_public_ip_address
for aws_instance
left as null
doesn’t actually default to anything beyond “what the subnet says it should do.”
If you are making this aws_instance
inside of a subnet with map_public_ip_on_launch
set to true
, the aws_instance
will get a public ipv4 address regardless of your specifying true, false, or null on associate_public_ip_address
.
The matrix is as such:
map_public_ip_on_launch
aws_subnet, false
aws_instance >>> true
map_public_ip_on_launch
aws_subnet, true
aws_instance >>> true
map_public_ip_on_launch
aws_subnet, null
aws_instance >>> true
no map_public_ip_on_launch
aws_subnet, false
aws_instance >>> false
no map_public_ip_on_launch
aws_subnet, true
aws_instance >>> true
no map_public_ip_on_launch
aws_subnet, null
aws_instance >>> false
So, rather than this being a default of true
the actual default is “whatever the subnet tells the instance to do.”
As an aside, still receiving a public IP regardless of setting it false
in a map_public_ip_on_launch
subnet makes the false
setting useless. I question the need for anything other than true
and null
to exist for this parameter, given the effective uselessness of this attribute in overriding the subnet’s parameters.