Skip to content

Commit

Permalink
adding terraform destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Paramadon committed Jan 15, 2025
1 parent 0538bed commit 090d2e9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/ec2-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ jobs:
- name: Verify Terraform version
run: terraform --version

# nick-fields/retry@v2 starts at base dir
# nick-fields/retry@v2 starts at base dir
- name: Terraform apply
if: steps.cache_if_success.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
max_attempts: 2
Expand All @@ -94,7 +96,7 @@ jobs:
fi
terraform init
terraform apply --auto-approve \
if terraform apply --auto-approve \
-var="ssh_key_value=${{env.PRIVATE_KEY}}" -var="github_test_repo=${{ inputs.test_repo_url }}" \
-var="test_name=${{ matrix.arrays.os }}" \
-var="cwa_github_sha=${{inputs.github_sha}}" -var="install_agent=${{ matrix.arrays.installAgentCommand }}" \
Expand All @@ -112,4 +114,16 @@ jobs:
-var="excluded_tests='${{ matrix.arrays.excludedTests }}'" \
-var="ssh_key_name=${{env.KEY_NAME}}" \
-var="test_dir=${{ matrix.arrays.test_dir }}" \
-var="agent_start=${{ matrix.arrays.agentStartCommand }}"
-var="agent_start=${{ matrix.arrays.agentStartCommand }}"; then terraform destroy -var="region=${{ inputs.region }}" -var="ami=${{ matrix.arrays.ami }}" -auto-approve
else
terraform destroy -var="region=${{ inputs.region }}" -var="ami=${{ matrix.arrays.ami }}" -auto-approve && exit 1
fi
#This is here just in case workflow cancel
- name: Terraform destroy
if: ${{ cancelled() || failure() }}
uses: nick-fields/retry@v2
with:
max_attempts: 2
timeout_minutes: 8
retry_wait_seconds: 5
command: cd ${{ inputs.test_dir }} && terraform destroy -var="region=${{ inputs.region }}" -var="ami=${{ matrix.arrays.ami }}" --auto-approve

0 comments on commit 090d2e9

Please sign in to comment.