Open appleoddity opened 1 year ago
Thanks @appleoddity for calling this out. We've got an internal backlog already tracking this enhancement, I'll add your issue for further context during prioritization.
Any update on this? Being unable to set environment variables during the terraform execution makes it difficult to provision other terraform providers which depend on secrets (API keys, etc)
+1 on this issue. I'm trying to use a 3rd party provider, being able to set credentials in environment variables would be much more secure and practical.
I am not sure if this will solve the problems you are encountering but I successfully worked around this problem by doing this in my account customizations pre-api-helpers.sh script.
echo "Appending custom variables to terraform.tfvars"
cat << EOF >> "${DEFAULT_PATH}/${CUSTOMIZATION}/terraform/terraform.tfvars"
vpc_name = "${VPC_NAME}"
vpc_ipam_type = "${IPAM_TYPE}"
vpc_region = "${VPC_REGION}"
vpc_az_count = ${VPC_AZ_COUNT}
EOF
AFT Version: 1.10.3 (Latest)
Terraform Version & Provider Versions Please provide the outputs of
terraform version
andterraform providers
from within your AFT environmentterraform version
terraform providers
Bug Description The customizations Codebuild projects' buildspec definitions that use the pre_build and post_build execution of
pre-api-helpers.sh
andpost-api-helpers.sh
does not dot-source the script and any environment variables defined within these api-helper scripts are unavailable to other steps in the codebuild project.To Reproduce Steps to reproduce the behavior:
pre-api-helpers.sh
script:export test="test variable"
pre-api-helpers.sh
execution step:env
test
environment variable is not present in the output.Expected behavior Environment variables defined in the pre and post api helper scripts should be retained for the following build steps.
Additional context If we attempt to define TF_VAR environment variables in the pre/post-api-helpers.sh scripts those are lost in the following Terraform execution steps. To solve this problem we need to dot-source the scripts in the buildspec, i.e.:
. $DEFAULT_PATH/$CUSTOMIZATION/api_helpers/pre-api-helpers.sh