Unfortunately, all my efforts to use tge resolved value in an aws_security_group body results in the security_group becoming invalid with no error message:
# existential question: who am I?
data "http" "whoami" {
url = "
http://icanhazip.com"
}
resource "aws_security_group" "config" {
name = "terraform_config"
description = "Used in the terraform provisioning process"
vpc_id = "${
aws_vpc.nuodb-domain.id}"
# SSH access from the terraform host only
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${data.http.whoami.body}/32"]
# cidr_blocks = ["${var.local_public_ip}"]
}
# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["
0.0.0.0/0"]
}
}
terraform apply ...
data.http.whoami: Refreshing state...
Error running plan: 1 error(s) occurred:
* aws_instance.controller: 1 error(s) occurred:
* aws_instance.controller: Resource 'aws_security_group.config' not found for variable '
aws_security_group.config.id'
If I change back to ${var.local_public_ip} which equals "
0.0.0.0/0", then the security_group is valid again.
I have an output variable which outputs ${data.http.whoami.body} and the value is correct there.
Has anyone any thoughts?
Cheers!
Nik