Reputation: 765
I would like to try if terraform data source will be able to place the output to a text file. I was looking on it online but not able to find any, I plan to perform on getting the load balancer name and after that our automation script will perform aws-cli command and will use the load balancer name taken by the data-source
Upvotes: 1
Views: 2276
Reputation: 238867
If your CLB name is autogenrated by TF, you can save it in a file using local_file:
resource "aws_elb" "clb" {
availability_zones = ["ap-southeast-2a"]
listener {
instance_port = 8000
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
}
resource "local_file" "foo" {
content = <<-EOL
${aws_elb.clb.name}
EOL
filename = "${path.module}/clb_name.txt"
}
output "clb_name" {
value = aws_elb.clb.name
}
But maybe it would be easier to get the output value directly as json:
clb_name=$(terraform output -json clb_name | jq -r)
echo ${clb_name}
Upvotes: 1