File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 7676 - name : Validate ${{ matrix.terraform_dir }} module (covers all submodules)
7777 working-directory : ${{ matrix.terraform_dir }}
7878 run : |
79+ # Some modules use aliased AWS providers (for example aws.destination/aws.target)
80+ # and fail direct `terraform validate` unless alias configs are present.
81+ # Generate a temporary provider file for any discovered aws.<alias> references.
82+ AWS_ALIASES="$(grep -RhoE 'provider[[:space:]]*=[[:space:]]*aws\.[A-Za-z0-9_]+' -- *.tf 2>/dev/null | sed -E 's/.*aws\.([A-Za-z0-9_]+)/\1/' | sort -u || true)"
83+ if [[ -n "${AWS_ALIASES}" ]]; then
84+ AUTO_PROVIDER_FILE=".tfvalidate.providers.auto.tf"
85+ {
86+ echo "// Generated by CI for terraform validate."
87+ echo "// Do not commit."
88+ echo
89+ } > "${AUTO_PROVIDER_FILE}"
90+
91+ for alias in ${AWS_ALIASES}; do
92+ cat >> "${AUTO_PROVIDER_FILE}" <<EOF
93+ provider "aws" {
94+ alias = "${alias}"
95+ region = "us-east-2"
96+ }
97+
98+ EOF
99+ done
100+
101+ echo "Generated ${AUTO_PROVIDER_FILE} for aliases : ${AWS_ALIASES}"
102+ fi
103+
79104 terraform init -backend=false
80105 terraform validate
You can’t perform that action at this time.
0 commit comments