Building backend file into pipeline runtime
pending feedback
V
Voluminous Basilisk
We have scenario about repositories type - infra that this repos not exist backend file tf cause this file's buiding in runtime pipeline in github action, we've including this file in runtime before to start terraform plan and apply.
Log In
Sudarshan Purohit
updated the status to
pending feedback
Sudarshan Purohit
Voluminous Basilisk, could you add more information about the use case and the expected functionality, please?
V
Voluminous Basilisk
Sudarshan Purohit of course yes, nowadays we provisioning this file in runtime on github action, following:
We need buiding this file on Harnnes before step NATIVE Harness Terraform Plan.
- name: Create Terraform Provider
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
if: ${{ inputs.iac_command == 'terraform' }}
run: |
echo ::group::Create Terraform Provider
if [ "${{ env.DISABLE_PROVIDER }}" == "true" ]; then
echo "Criação automática do provider desabilitado no .iupipes.yml"
else
if [ -f "default_tags.hcl" ]; then
default_tags=$(cat default_tags.hcl)
echo "provider \"aws\" {
ignore_tags { key_prefixes = [\"c7n\"]}
default_tags {
tags = $default_tags
}
}" > provider.tf
else
echo "provider \"aws\" {
ignore_tags { key_prefixes = [\"c7n\"]}
}" > provider.tf
fi
fi
echo "terraform {
backend \"s3\" {
bucket = \"${{ env.BUCKET_BACKEND }}\"
key = \"${{ env.BUCKET_BACKEND_KEY }}\"
region = \"${{ env.S3_PROVIDER_REGION }}\"
encrypt = true
}
}" >> provider.tf
cat -n provider.tf
echo ::endgroup::