diff --git a/.github/workflows/terraform_workflow.yml b/.github/workflows/terraform_workflow.yml index c8b5ae6..f1d850c 100644 --- a/.github/workflows/terraform_workflow.yml +++ b/.github/workflows/terraform_workflow.yml @@ -238,6 +238,24 @@ jobs: terraform apply -auto-approve fi + - name: Find Errored Terraform State + if: ${{ always() }} + run: | + cd ${{ inputs.working_directory }} + if [ -f "errored.tfstate" ]; then + ls -la errored.tfstate + echo "Uploading errored.tfstate as artifact..." + else + echo "Errored Terraform state file not found." + fi + + - name: Upload Errored Terraform State Artifact + if: ${{ always() }} && success() && steps.find_errored_tfstate.outputs['errored_found'] == 'true' + uses: actions/upload-artifact@v4 + with: + name: errored_tfstate + path: ${{ inputs.working_directory }}/errored.tfstate + - name: Terraform destroy if: ${{ inputs.destroy == true }} id: destroy diff --git a/.github/workflows/tf-checks.yml b/.github/workflows/tf-checks.yml index f5af4e6..c955ea7 100644 --- a/.github/workflows/tf-checks.yml +++ b/.github/workflows/tf-checks.yml @@ -11,9 +11,8 @@ on: type: string default: './examples/complete/' provider: - required: true + required: false type: string - default: gcp description: 'Cloud provider to run the workflow. e.g. azurerm or aws or gcp' terraform_version: description: 'Terraform version to use. Leave empty for the latest version.'