I would like to use ${aws_instance.my_rds_instance_name.endpoint} as the input to a postgresql provider host attribute. There is no other way to get the endpoint without manually constructing it. Because endpoint includes the port, this results in:
* postgresql_database.my_db_name: Error creating postgresql database my_db_name: dial tcp: too many colons in address [aws address removed]:5432:5432
Since the port is available from another exported attribute, endpoint should contain the endpoint only, and not the port specification, e.g. :5432.
not ipv6 safe, but a workaround is:
${element(split(":", aws_instance.my_rds_instance_name.endpoint), 0)}
changing endpoint would be a backward incompatible change for anyone who currently relies on it. adding a new computed attribute (host) would be forward-compatible, but requires code change unlike the above workaround.
for ipv6 safety perhaps it would useful to have an interpolation function that safely understands both [ff00::a:b]:3306 and 127.0.0.1:3306 formats and always returns a tuple (list) of host,port e.g.
${element(split_hostport(aws_instance.rds.endpoint), 0)}
Hi @zdexter
Apologies for this slipping through the gaps here. Currently we have the following available:
d.Set("port", v.Endpoint.Port)
d.Set("address", v.Endpoint.Address)
d.Set("endpoint", fmt.Sprintf("%s:%d", *v.Endpoint.Address, *v.Endpoint.Port))
This suggests to me that you want to use Address rather than Endpoint. Endpoint is a combination of address + port. This follows what AWS displays in the console
Hope this helps?
Paul
Hi @zdexter
Apologies for this slipping through the gaps here. Currently we have the following available:
d.Set("port", v.Endpoint.Port) d.Set("address", v.Endpoint.Address) d.Set("endpoint", fmt.Sprintf("%s:%d", *v.Endpoint.Address, *v.Endpoint.Port))This suggests to me that you want to use Address rather than Endpoint. Endpoint is a combination of address + port. This follows what AWS displays in the console
Hope this helps?
Paul
Thanks @stack72, this was a life saver tip for me..
Regards
Digvijay Sinha
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
Hi @zdexter
Apologies for this slipping through the gaps here. Currently we have the following available:
This suggests to me that you want to use Address rather than Endpoint. Endpoint is a combination of address + port. This follows what AWS displays in the console
Hope this helps?
Paul