Skip to content

Commit

Permalink
IL-878 Add az vm sku debugging and allow variables to override
Browse files Browse the repository at this point in the history
* To aid debugging, print what Azure thinks are available vm skus
  for the location we have set
* Allow overriding `location` and `vm_size` with action variables,
  if set
  • Loading branch information
thomashashi committed Sep 5, 2023
1 parent f77e487 commit 9954308
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion .github/workflows/infrastructure-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@ jobs:
with:
name: "tf-code"
path: ${{ github.workspace }}
azurerm-vms-available:
# We do this to aid things like IL-878, where Azure tells us we have no
# VMs of a certain size; this runs to show you what *was* available at
# the time
runs-on: ubuntu-latest
needs:
- terraform-init
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: "tf-code"
path: ${{ github.workspace }}
# Either upload or download-artifact does not preserve the exec bit on
# binaries, so fix that here
- name: fix-perms
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: set TF vars if set
run: |-
if [ -n ${{ vars.TF_VAR_location }} ]; then
echo "TF_VAR_location=${{ vars.TF_VAR_location}}" >> "${GITHUB_ENV}"
fi
if [ -n ${{ vars.TF_VAR_vm_size }} ]; then
echo "TF_VAR_vm_size=${{ vars.TF_VAR_vm_size}}" >> "${GITHUB_ENV}"
fi
- name: check VMs
run: |-
# Whether we're using the defaults in the varables.tf file, or have overriden
# them with environment variables, 'terraform console' will tell us the current
# value that TF would use
location=$(echo "var.location" | terraform console | sed 's/^"//' | sed 's/"$//')
az vm list-skus --location "${location}" --zone --output table
terraform-validate:
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -65,6 +98,14 @@ jobs:
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: set TF vars if set
run: |-
if [ -n ${{ vars.TF_VAR_location }} ]; then
echo "TF_VAR_location=${{ vars.TF_VAR_location}}" >> "${GITHUB_ENV}"
fi
if [ -n ${{ vars.TF_VAR_vm_size }} ]; then
echo "TF_VAR_vm_size=${{ vars.TF_VAR_vm_size}}" >> "${GITHUB_ENV}"
fi
- name: Terraform Plan
run: terraform plan -out=gha-infrastructure-tests-${{ github.run_id }}-${{ github.run_number }}.plan
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
Expand All @@ -88,6 +129,14 @@ jobs:
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: set TF vars if set
run: |-
if [ -n ${{ vars.TF_VAR_location }} ]; then
echo "TF_VAR_location=${{ vars.TF_VAR_location}}" >> "${GITHUB_ENV}"
fi
if [ -n ${{ vars.TF_VAR_vm_size }} ]; then
echo "TF_VAR_vm_size=${{ vars.TF_VAR_vm_size}}" >> "${GITHUB_ENV}"
fi
- name: Terraform Apply
run: terraform apply -auto-approve gha-infrastructure-tests-${{ github.run_id }}-${{ github.run_number }}.plan
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
Expand All @@ -111,5 +160,13 @@ jobs:
run: |-
# e.g. .terraform/providers/registry.terraform.io/hashicorp/null/3.2.1/linux_amd64/terraform-provider-null_v3.2.1_x5
chmod +x .terraform/providers/*/*/*/*/*/terraform-provider-*
- name: set TF vars if set
run: |-
if [ -n ${{ vars.TF_VAR_location }} ]; then
echo "TF_VAR_location=${{ vars.TF_VAR_location}}" >> "${GITHUB_ENV}"
fi
if [ -n ${{ vars.TF_VAR_vm_size }} ]; then
echo "TF_VAR_vm_size=${{ vars.TF_VAR_vm_size}}" >> "${GITHUB_ENV}"
fi
- name: Terraform Destroy
run: terraform destroy -auto-approve
run: terraform destroy -auto-approve

0 comments on commit 9954308

Please sign in to comment.