logic for deleting resource groups without terraform

This commit is contained in:
miampf 2024-05-02 13:32:32 +02:00
parent f6999084c9
commit 2cfb3baeb8
No known key found for this signature in database
GPG Key ID: EF039364B5B6886C

View File

@ -80,10 +80,12 @@ jobs:
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
- name: Create IAM configuration
id: iam-create
shell: pwsh
run: |
$uid = Get-Random -Minimum 1000 -Maximum 9999
$rgName = "e2e-win-${{ github.run_id }}-${{ github.run_attempt }}-$uid"
Write-Output "rgName=$($rgName)" >> $Env::GITHUB_OUTPUT
.\constellation.exe config generate azure -t "workflow=${{ github.run_id }}"
.\constellation.exe iam create azure --region=westus --resourceGroup=$rgName-rg --servicePrincipal=$rgName-sp --update-config --debug -y
@ -150,6 +152,7 @@ jobs:
}
- name: Terminate cluster
id: terminate-cluster
if: always()
shell: pwsh
run: |
@ -162,11 +165,19 @@ jobs:
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
- name: Delete IAM configuration
id: delete-iam
if: always()
shell: pwsh
run: |
.\constellation.exe iam destroy --debug -y
- name: Clean up after failure
if: ${{ (failure() && (steps.terminate-cluster.conclusion == 'failure' || steps.delete-iam.conclusion == 'failure') || cancelled() }} # run on a cleanup failure or if cancelled
shell: pwsh
run: |
az rg delete --name ${{ steps.iam-create.outputs.rgName }}-rg --yes
az rg delete --name ${{ steps.iam-create.outputs.rgName }}-sp --yes
notify-failure:
name: Notify about failure
runs-on: ubuntu-22.04
@ -196,25 +207,3 @@ jobs:
provider: Azure
attestationVariant: "azure-sev-snp"
upload-tfstate:
name: Upload terraform state if it exists
runs-on: ubuntu-22.04
needs: e2e-test
if: always()
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
- name: Upload tfstate
if: always()
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ github.run_id }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
skipDeletion: "true"