Ideas or code sources:
https://stackoverflow.com/a/53782560/2282604
Hey all,
Some time ago while using Terraform Cloud I faced issue when I was need to access AWS resources while I had SG with whitelisted access.
Main idea is:
- get your IP
- add that IP into SG
Here is workaround for Terraform:
data "http" "myip" {
url = "http://ipv4.icanhazip.com"
}
And whenever you want to place your IP just use data.http.myip.body
, example:
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = ["${chomp(data.http.myip.body)}/32"]
}
Easy :)
You’ll get changes on every run!