Test - Failed plan - Drift #513
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Test - Failed plan - Drift" | |
on: | |
workflow_dispatch: {} | |
env: | |
AWS_REGION: us-east-2 | |
# Permissions required for assuming AWS identity | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | |
run: echo "Do setup" | |
test: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
needs: [setup] | |
steps: | |
- uses: actions/checkout@v4 | |
# with: | |
# ref: ${{ github.event.pull_request.head.ref }} | |
- shell: bash | |
run: | | |
mkdir -p ${{ runner.temp }} | |
cp ./tests/terraform/atmos.yaml ${{ runner.temp }}/atmos.yaml | |
for file in ./tests/terraform/stacks/catalog/*.yaml; do | |
if [ -f "$file" ]; then | |
sed -i -e "s#__INFRACOST_ENABLED__#false#g" "$file" | |
sed -i -e "s#__STORAGE_REGION__#${{ env.AWS_REGION }}#g" "$file" | |
sed -i -e "s#__STORAGE_BUCKET__#${{ secrets.TERRAFORM_STATE_BUCKET }}#g" "$file" | |
sed -i -e "s#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g" "$file" | |
sed -i -e "s#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g" "$file" | |
sed -i -e "s#__STORAGE_ROLE__#${{ secrets.TERRAFORM_STATE_ROLE }}#g" "$file" | |
sed -i -e "s#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g" "$file" | |
sed -i -e "s#__APPLY_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g" "$file" | |
fi | |
done | |
- name: Plan Atmos Component | |
id: current | |
uses: ./ | |
with: | |
component: "foobar-fail" | |
stack: "plat-ue2-sandbox" | |
sha: ${{ github.sha }} | |
drift-detection-mode-enabled: true | |
atmos-config-path: ${{ runner.temp }} | |
atmos-version: 1.92.0 | |
do-not-checkout: true | |
outputs: | |
result: ${{ steps.current.outcome }} | |
summary: ${{ steps.current.outputs.summary }} | |
assert: | |
runs-on: ubuntu-latest | |
needs: [test] | |
steps: | |
- uses: nick-fields/assert-action@v2 | |
with: | |
expected: 'failure' | |
actual: "${{ needs.test.outputs.result }}" | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: metadata | |
pattern: metadata-* | |
merge-multiple: true | |
- name: Display structure of downloaded files | |
id: metadata | |
run: | | |
set +e | |
test -d ./metadata | |
DIR_EXISTS=$? | |
echo "dir_exists=${DIR_EXISTS}" >> $GITHUB_OUTPUT | |
test -f ./metadata/plat-ue2-sandbox-foobar-fail.metadata.json | |
FILE_EXISTS=$? | |
echo "file_exists=${FILE_EXISTS}" >> $GITHUB_OUTPUT | |
test -f ./metadata/issue-description-plat-ue2-sandbox-foobar-fail.md | |
FILE_EXISTS=$? | |
echo "file_md_exists=${FILE_EXISTS}" >> $GITHUB_OUTPUT | |
echo "file_md=$(cat ./metadata/issue-description-plat-ue2-sandbox-foobar-fail.md | jq -Rs .)" >> $GITHUB_OUTPUT | |
echo "file_json=$(cat ./metadata/plat-ue2-sandbox-foobar-fail.metadata.json | jq -Rs . )" >> $GITHUB_OUTPUT | |
- uses: nick-fields/assert-action@v2 | |
with: | |
actual: "${{ steps.metadata.outputs.dir_exists }}" | |
expected: "0" | |
- uses: nick-fields/assert-action@v2 | |
with: | |
actual: "${{ steps.metadata.outputs.file_exists }}" | |
expected: "0" | |
- uses: nick-fields/assert-action@v2 | |
with: | |
actual: "${{ steps.metadata.outputs.file_md_exists }}" | |
expected: "0" | |
- uses: nick-fields/assert-action@v2 | |
with: | |
actual: "${{ fromJSON(needs.test.outputs.summary) }}" | |
expected: "${{ fromJSON(steps.metadata.outputs.file_md) }}" | |
- uses: nick-fields/assert-action@v2 | |
with: | |
actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}" | |
expected: | | |
{ "stack": "plat-ue2-sandbox", "component": "foobar-fail", "componentPath": "tests/terraform/components/terraform/foobar", "drifted": false, "error": true } | |
- uses: nick-fields/assert-action@v2 | |
with: | |
actual: "${{ fromJSON(needs.test.outputs.summary) }}" | |
expected: | | |
## Drift Detection Failed for `foobar-fail` in `plat-ue2-sandbox`! | |
<a href="https://cloudposse.com/"><img src="https://cloudposse.com/logo-300x69.svg" width="100px" align="right"/></a> | |
[![failed](https://shields.io/badge/PLAN-FAILED-ff0000?style=for-the-badge)](#user-content-result-plat-ue2-sandbox-foobar-fail) | |
<details><summary><a id="result-plat-ue2-sandbox-foobar-fail" />:warning: Error summary</summary> | |
<br/> | |
To reproduce this locally, run:<br/><br/> | |
```shell | |
atmos terraform plan foobar-fail -s plat-ue2-sandbox | |
``` | |
--- | |
```hcl | |
Error: Invalid function argument | |
on main.tf line 17, in locals: | |
17: failure = var.enabled && var.enable_failure ? file("Failed because failure mode is enabled") : null | |
├──────────────── | |
│ while calling file(path) | |
Invalid value for "path" parameter: no file exists at "Failed because failure | |
mode is enabled"; this function works only with files that are distributed as | |
part of the configuration source code, so if this file will be created by a | |
resource in this configuration you must instead obtain this result from an | |
attribute of that resource. | |
exit status 1 | |
``` | |
</details> | |
<details><summary>Metadata</summary> | |
```json | |
{ | |
"component": "foobar-fail", | |
"stack": "plat-ue2-sandbox", | |
"componentPath": "tests/terraform/components/terraform/foobar", | |
"commitSHA": "${{ github.sha }}" | |
} | |
``` | |
</details> | |
teardown: | |
runs-on: ubuntu-latest | |
needs: [assert] | |
if: ${{ always() }} | |
steps: | |
- name: Tear down | |
run: echo "Do Tear down" |