Reputation: 341
I am working on a command in gitlab-ci.yml where I need to read some value from a terraform named locals.tf
Below is the terraform code
locals {
lambda_edge_name = format(var.resource_name_pattern, "cloudfront-edge")
}
yml code
lambda-deletion:
stage: lambda-deletion
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
script:
lambda_name = //read_terraform_value_here
echo $lambda_name;
I want to read the lambda_edge_name into a variable in gitlab-ci.yml file.
I tried many things(which are not even worth mentioning here), but seems like I am stuck at this.
Upvotes: 0
Views: 1747
Reputation: 6922
You could just export an output
and then read it
locals {
lambda_edge_name = format("${var.resource_name_pattern}-something", "cloudfront-edge")
}
output "lambda_edge_name" {
value = local.lambda_edge_name
}
Then in your script run:
lambda_name =$(terraform output lambda_edge_name)
If you can format this output without using variables, you may use hclq
, for example:
locals {
lambda_edge_name = "cloudfront-edge"
}
Then:
cat locals.tf | hclq get 'locals.lambda_edge_name'
Upvotes: 0