@@ -176,23 +176,56 @@ runs:
176176 settingsPath: settings.integrations.github.gitops.artifact-storage.cosmos-endpoint
177177 outputPath: cosmos-endpoint
178178
179- - name : Install Terraform
180- if : ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-version != '' && fromJson(steps.atmos-settings.outputs.settings).terraform-version != 'null' }}
181- uses : hashicorp/setup-terraform@v3
179+ - name : Add Terraform and OpenTofu to Aqua
180+ shell : bash
181+ run : |
182+ cat << EOF > aqua.yaml
183+ registries:
184+ - type: standard
185+ ref: v4.233.0
186+ packages:
187+ - name: suzuki-shunsuke/tfcmt@v4.14.5
188+ EOF
189+
190+ # Add Terraform if specified
191+ if [[ "${{ fromJson(steps.atmos-settings.outputs.settings).terraform-version }}" != "" && "${{ fromJson(steps.atmos-settings.outputs.settings).terraform-version }}" != "null" ]]; then
192+ VERSION="${{ fromJson(steps.atmos-settings.outputs.settings).terraform-version }}"
193+ if [[ ! "$VERSION" =~ ^v ]]; then
194+ VERSION="v$VERSION"
195+ fi
196+ echo " - name: hashicorp/terraform@$VERSION" >> aqua.yaml
197+ fi
198+
199+ # Add OpenTofu if specified
200+ if [[ "${{ fromJson(steps.atmos-settings.outputs.settings).opentofu-version }}" != "" && "${{ fromJson(steps.atmos-settings.outputs.settings).opentofu-version }}" != "null" ]]; then
201+ VERSION="${{ fromJson(steps.atmos-settings.outputs.settings).opentofu-version }}"
202+ if [[ ! "$VERSION" =~ ^v ]]; then
203+ VERSION="v$VERSION"
204+ fi
205+ echo " - name: opentofu/opentofu@$VERSION" >> aqua.yaml
206+ fi
207+
208+ # Debug output if debug is enabled
209+ if [[ "${{ inputs.debug }}" == "true" ]]; then
210+ echo "Generated aqua.yaml:"
211+ cat aqua.yaml
212+ fi
213+
214+ - name : Cache Aqua
215+ uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
182216 with :
183- terraform_version : ${{ fromJson(steps.atmos-settings.outputs.settings).terraform-version }}
184- terraform_wrapper : false
217+ path : ~/.local/share/aquaproj-aqua
218+ key : v2-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
219+ restore-keys : |
220+ v2-aqua-installer-${{runner.os}}-${{runner.arch}}-
185221
186- - name : Install Dependencies
187- uses : cloudposse-github-actions/install-gh-releases@v1
222+ - name : Install dependencies with Aqua
223+ uses : aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2
188224 with :
189- cache : true
190- config : |-
191- opentofu/opentofu:
192- tag: ${{ startsWith(fromJson(steps.atmos-settings.outputs.settings).opentofu-version, 'v') && fromJson(steps.atmos-settings.outputs.settings).opentofu-version || format('v{0}', fromJson(steps.atmos-settings.outputs.settings).opentofu-version) }}
193- skip: ${{ fromJson(steps.atmos-settings.outputs.settings).opentofu-version == '' || fromJson(steps.atmos-settings.outputs.settings).opentofu-version == 'null' }}
194- suzuki-shunsuke/tfcmt:
195- tag: v4.14.0
225+ aqua_version : v2.50.0
226+ env :
227+ AQUA_CONFIG : aqua.yaml
228+ AQUA_LOG_LEVEL : debug
196229
197230 - name : Configure Plan AWS Credentials
198231 uses : aws-actions/configure-aws-credentials@v4
@@ -265,6 +298,13 @@ runs:
265298 id : atmos-plan
266299 shell : bash
267300 run : |
301+ # Verify tfcmt is installed
302+ # Since we disable exit on error, the real error will be swallowed later on
303+ echo "Ensure tfcmt is installed:"
304+ tfcmt --version
305+
306+ # Disable exit on error so we can capture the terraform exit code
307+ # and handle it appropriately later in the script
268308 set +e
269309
270310 # Remove the environment file from the cache to avoid conflicts with workspace select
0 commit comments