Skip to content

Commit

Permalink
Workspace select
Browse files Browse the repository at this point in the history
  • Loading branch information
carlssonk committed Sep 28, 2024
1 parent 7f6f11a commit e0cd35d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
if: steps.check_backend.outputs.backend_exists == 'false'
run: |
terraform init
terraform workspace new ${{ github.event.inputs.environment }}
terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }}
terraform apply -auto-approve
working-directory: ./bootstrap/setup-backend

Expand All @@ -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 new ${{ github.event.inputs.environment }}
terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }}
terraform apply -auto-approve
working-directory: ./bootstrap/setup-oidc
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ jobs:
organization=${{ env.TF_VAR_organization }} \
cleanup_policies=${{ github.event_name == 'schedule' || github.event.inputs.cleanup_policies == 'true' }}
terraform workspace new ${{ needs.setup.outputs.env }}
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 select ${{ needs.setup.outputs.env }} || terraform workspace new ${{ needs.setup.outputs.env }}
if [ ${{ github.event_name }} == 'pull_request' ]; then
if [ ${{ matrix.step }} == 'iam' ]; then
terraform plan -lock=false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
organization=${{ env.TF_VAR_organization }} \
cleanup_policies=true
terraform workspace new ${{ github.event.inputs.environment }}
terraform workspace select ${{ github.event.inputs.environment }} || terraform workspace new ${{ github.event.inputs.environment }}
chmod +x ./scripts/ci_retry_command.sh
- name: Terraform Destroy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/remove_tf_state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ jobs:
organization=${{ env.TF_VAR_organization }} \
cleanup_policies=true
terraform workspace new ${{ github.event.inputs.environment }}
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 select ${{ github.event.inputs.environment }} || 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 }}

0 comments on commit e0cd35d

Please sign in to comment.