diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index 7644764..2189b03 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -55,7 +55,7 @@ jobs: if: steps.check_backend.outputs.backend_exists == 'false' run: | terraform init - terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }} + terraform workspace select ${{ github.event.inputs.environment }} 2>/dev/null || terraform workspace new ${{ github.event.inputs.environment }} terraform apply -auto-approve working-directory: ./bootstrap/setup-backend @@ -72,6 +72,6 @@ jobs: -backend-config="dynamodb_table=${{ vars.ORGANIZATION }}-terraform-lock-table-${{ github.event.inputs.environment }}" \ -backend-config="key=bootstrap/terraform.tfstate" - terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }} + terraform workspace select ${{ github.event.inputs.environment }} 2>/dev/null || terraform workspace new ${{ github.event.inputs.environment }} terraform apply -auto-approve working-directory: ./bootstrap/setup-oidc \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6be1017..0ccd7bd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -135,12 +135,11 @@ jobs: organization=${{ env.TF_VAR_organization }} \ cleanup_policies=${{ github.event_name == 'schedule' || github.event.inputs.cleanup_policies == 'true' }} - terraform workspace select ${{ needs.setup.outputs.env }} || terraform workspace new ${{ needs.setup.outputs.env }} chmod +x ./scripts/ci_retry_command.sh - name: ${{ (github.event_name == 'pull_request' && format('Terraform Plan{0}', matrix.step == 'iam' && ' & Apply' || '')) || 'Terraform Apply' }} run: | - terraform workspace select ${{ needs.setup.outputs.env }} || terraform workspace new ${{ needs.setup.outputs.env }} + terraform workspace select ${{ needs.setup.outputs.env }} 2>/dev/null || terraform workspace new ${{ needs.setup.outputs.env }} if [ ${{ github.event_name }} == 'pull_request' ]; then if [ ${{ matrix.step }} == 'iam' ]; then terraform plan -lock=false diff --git a/.github/workflows/destroy.yml b/.github/workflows/destroy.yml index 3846482..a95691c 100644 --- a/.github/workflows/destroy.yml +++ b/.github/workflows/destroy.yml @@ -79,12 +79,11 @@ jobs: organization=${{ env.TF_VAR_organization }} \ cleanup_policies=true - terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }} chmod +x ./scripts/ci_retry_command.sh - name: Terraform Destroy run: | - terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }} + terraform workspace select ${{ github.event.inputs.environment }} 2>/dev/null || terraform workspace new ${{ github.event.inputs.environment }} if ! ../../scripts/ci_retry_command.sh "terraform destroy -lock=false -auto-approve -var-file='${{ env.TFVARS_FILE_NAME }}.tfvars'"; then echo "Terraform failed after all retry attempts" exit 1 diff --git a/.github/workflows/remove_tf_state.yml b/.github/workflows/remove_tf_state.yml index 2ee2ff3..7e37108 100644 --- a/.github/workflows/remove_tf_state.yml +++ b/.github/workflows/remove_tf_state.yml @@ -78,12 +78,11 @@ jobs: organization=${{ env.TF_VAR_organization }} \ cleanup_policies=true - terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }} chmod +x ./scripts/ci_retry_command.sh - name: Check and Remove Resource from Terraform State run: | - terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }} + terraform workspace select ${{ github.event.inputs.environment }} 2>/dev/null || terraform workspace new ${{ github.event.inputs.environment }} echo "Removing resource: ${{ inputs.tf-rm }}" terraform state rm '${{ inputs.tf-rm }}' working-directory: ${{ env.TF_ROOT_DIRECTORY }} \ No newline at end of file