2024-05-30T14:21:43.6289629Z ##[section]Starting: TerraformCLI
2024-05-30T14:21:43.6295767Z ==============================================================================
2024-05-30T14:21:43.6295928Z Task : Terraform CLI
2024-05-30T14:21:43.6296007Z Description : Execute terraform cli commands
2024-05-30T14:21:43.6296103Z Version : 2.1.2
2024-05-30T14:21:43.6296189Z Author : Charles Zipp
2024-05-30T14:21:43.6296270Z Help :
2024-05-30T14:21:43.6296333Z ==============================================================================
2024-05-30T14:21:48.0830792Z [command]/usr/local/bin/terraform version
2024-05-30T14:21:56.4031321Z Terraform v1.8.4
2024-05-30T14:21:56.4032241Z on linux_amd64
2024-05-30T14:21:56.4215356Z [command]/usr/bin/az login --service-principal -t 6b9ca1ab-2493-4d57-ad52-9ac0e86be0f1 -u *** -p ***
2024-05-30T14:22:17.6850138Z [
2024-05-30T14:22:17.6850640Z {
2024-05-30T14:22:17.6851503Z "cloudName": "AzureCloud",
2024-05-30T14:22:17.6851998Z "homeTenantId": "6b9ca1ab-2493-4d57-ad52-9ac0e86be0f1",
2024-05-30T14:22:17.6852379Z "id": "1694212d-b07d-4db6-9852-7a33c8e2c3fe",
2024-05-30T14:22:17.6852575Z "isDefault": true,
2024-05-30T14:22:17.6852750Z "managedByTenants": [],
2024-05-30T14:22:17.6852912Z "name": "theRealGavlar",
2024-05-30T14:22:17.6853087Z "state": "Enabled",
2024-05-30T14:22:17.6853367Z "tenantId": "6b9ca1ab-2493-4d57-ad52-9ac0e86be0f1",
2024-05-30T14:22:17.6853562Z "user": {
2024-05-30T14:22:17.6853930Z "name": "***",
2024-05-30T14:22:17.6854105Z "type": "servicePrincipal"
2024-05-30T14:22:17.6854268Z }
2024-05-30T14:22:17.6854401Z }
2024-05-30T14:22:17.6854532Z ]
2024-05-30T14:22:18.0140602Z [command]/usr/bin/az account set -s 1694212d-b07d-4db6-9852-7a33c8e2c3fe
2024-05-30T14:22:18.4689004Z [command]/usr/bin/az group create --name therealgavlar-terraform-backend-resource-group --location westeurope
2024-05-30T14:22:19.7626501Z {
2024-05-30T14:22:19.7627191Z "id": "/subscriptions/1694212d-b07d-4db6-9852-7a33c8e2c3fe/resourceGroups/therealgavlar-terraform-backend-resource-group",
2024-05-30T14:22:19.7627685Z "location": "westeurope",
2024-05-30T14:22:19.7627887Z "managedBy": null,
2024-05-30T14:22:19.7628279Z "name": "therealgavlar-terraform-backend-resource-group",
2024-05-30T14:22:19.7628574Z "properties": {
2024-05-30T14:22:19.7628775Z "provisioningState": "Succeeded"
2024-05-30T14:22:19.7628945Z },
2024-05-30T14:22:19.7629079Z "tags": null,
2024-05-30T14:22:19.7629359Z "type": "Microsoft.Resources/resourceGroups"
2024-05-30T14:22:19.7629628Z }
2024-05-30T14:22:19.8521479Z [command]/usr/bin/az storage account show --name trgavlar-storage-account --resource-group therealgavlar-terraform-backend-resource-group
2024-05-30T14:22:23.1054402Z ERROR: (ResourceNotFound) The Resource 'Microsoft.Storage/storageAccounts/trgavlar-storage-account' under resource group 'therealgavlar-terraform-backend-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
2024-05-30T14:22:23.1055183Z Code: ResourceNotFound
2024-05-30T14:22:23.1056478Z Message: The Resource 'Microsoft.Storage/storageAccounts/trgavlar-storage-account' under resource group 'therealgavlar-terraform-backend-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
2024-05-30T14:22:23.3113338Z ##[error]Error: ERROR: (ResourceNotFound) The Resource 'Microsoft.Storage/storageAccounts/trgavlar-storage-account' under resource group 'therealgavlar-terraform-backend-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound
Message: The Resource 'Microsoft.Storage/storageAccounts/trgavlar-storage-account' under resource group 'therealgavlar-terraform-backend-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
2024-05-30T14:22:23.3122848Z az storage account create: storage account not found, creating...
2024-05-30T14:22:23.3135853Z [command]/usr/bin/az storage account create --name trgavlar-storage-account --resource-group therealgavlar-terraform-backend-resource-group --sku Standard_RAGRS --kind StorageV2 --encryption-services blob --access-tier hot --allow-blob-public-access false --https-only true --min-tls-version TLS1_2
2024-05-30T14:22:24.4779455Z ERROR: (SubscriptionNotFound) Subscription 1694212d-b07d-4db6-9852-7a33c8e2c3fe was not found.
2024-05-30T14:22:24.4780340Z Code: SubscriptionNotFound
2024-05-30T14:22:24.4782232Z Message: Subscription 1694212d-b07d-4db6-9852-7a33c8e2c3fe was not found.
2024-05-30T14:22:24.6957708Z ##[error]Error: ERROR: (SubscriptionNotFound) Subscription 1694212d-b07d-4db6-9852-7a33c8e2c3fe was not found.
Code: SubscriptionNotFound
Message: Subscription 1694212d-b07d-4db6-9852-7a33c8e2c3fe was not found.
2024-05-30T14:22:24.7020345Z [command]/usr/bin/az storage container create --auth-mode login --name therealgavlarstorageaccountcontainer --account-name trgavlar-storage-account
2024-05-30T14:23:51.7991590Z ERROR: <urllib3.connection.HTTPSConnection object at 0x7f6c52261090>: Failed to establish a new connection: [Errno -2] Name or service not known
2024-05-30T14:23:52.0178165Z ##[error]Error: ERROR: <urllib3.connection.HTTPSConnection object at 0x7f6c52261090>: Failed to establish a new connection: [Errno -2] Name or service not known
2024-05-30T14:23:52.0192729Z [command]/usr/local/bin/terraform init -backend-config=storage_account_name=trgavlar-storage-account -backend-config=container_name=therealgavlarstorageaccountcontainer -backend-config=key=kubernetes-dev.tfstate -backend-config=resource_group_name=therealgavlar-terraform-backend-resource-group -backend-config=subscription_id=1694212d-b07d-4db6-9852-7a33c8e2c3fe -backend-config=tenant_id=6b9ca1ab-2493-4d57-ad52-9ac0e86be0f1 -backend-config=client_id=*** -backend-config=client_secret=***
2024-05-30T14:23:52.2917317Z
2024-05-30T14:23:52.2918723Z �[0m�[1mInitializing the backend...�[0m
2024-05-30T14:23:52.9541814Z �[31m�[31m╷�[0m�[0m
2024-05-30T14:23:52.9543698Z �[31m│�[0m �[0m�[1m�[31mError: �[0m�[0m�[1mFailed to get existing workspaces: Error retrieving keys for Storage Account "trgavlar-storage-account": storage.AccountsClient#ListKeys: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Storage/storageAccounts/trgavlar-storage-account' under resource group 'therealgavlar-terraform-backend-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"�[0m
2024-05-30T14:23:52.9592722Z �[31m│�[0m �[0m
2024-05-30T14:23:52.9601204Z �[31m│�[0m �[0m�[0m
2024-05-30T14:23:52.9601448Z �[31m╵�[0m�[0m
2024-05-30T14:23:52.9601629Z �[0m�[0m
2024-05-30T14:23:52.9609241Z ##[error]Terraform command 'init' failed with exit code '1'.
2024-05-30T14:23:52.9627948Z ##[error]�[31m�[31m╷�[0m�[0m
�[31m│�[0m �[0m�[1m�[31mError: �[0m�[0m�[1mFailed to get existing workspaces: Error retrieving keys for Storage Account "trgavlar-storage-account": storage.AccountsClient#ListKeys: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Storage/storageAccounts/trgavlar-storage-account' under resource group 'therealgavlar-terraform-backend-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"�[0m
�[31m│�[0m �[0m
�[31m│�[0m �[0m�[0m
�[31m╵�[0m�[0m
�[0m�[0m
2024-05-30T14:23:52.9672574Z ##[section]Finishing: TerraformCLI
I'm not entirely sure what's going wrong as the resource group is created, it's only when the storage account attempts to be created the pipeline fails.
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- script: echo k8s terraform azure
displayName: 'Run a one-line script'
- task: DownloadSecureFile@1
name: publicKey
inputs:
secureFile: 'azure_rsa.pub'
- task: TerraformCLI@2
inputs:
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/configuration/iaac/azure/kubernetes'
backendType: 'azurerm'
backendServiceArm: 'therealgavlar-azure-resource-manager'
ensureBackend: true
backendAzureRmResourceGroupName: 'therealgavlar-terraform-backend-resource-group'
backendAzureRmResourceGroupLocation: 'westeurope'
backendAzureRmStorageAccountName: 'trgavlar-storage-account'
backendAzureRmContainerName: 'therealgavlarstorageaccountcontainer'
backendAzureRmKey: 'kubernetes-dev.tfstate'
allowTelemetryCollection: false
- task: TerraformCLI@2
inputs:
command: 'apply'
workingDirectory: '$(System.DefaultWorkingDirectory)/configuration/iaac/azure/kubernetes'
environmentServiceName: 'therealgavlar-azure-resource-manager'
commandOptions: '-var client_id=$(client_id) -var client_secret=$(client_secret) -var ssh_public_key=$(publicKey.secureFilePath)'
allowTelemetryCollection: false