Aeseir
Aeseir

Reputation: 8414

Terraform and Azure: Unable to provision Storage Account

I am trying to provision a storage account but running it results in error:

Error: Error reading static website for AzureRM Storage Account "sa12345461234512name":
accounts.Client#GetServiceProperties: 
Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="AuthorizationPermissionMismatch" 
Message="This request is not authorized to perform this operation using this permission.\n
RequestId:05930d46-301e-00ac-6d72-f021f0000000\n
Time:2020-03-02T09:09:44.9417598Z"

Running OS Windows 10 Pro.

Steps to replicate (in Powershell with Azure CLI installed)

  1. az login
  2. mkdir dummyFolder
  3. cd dummyFolder
  4. create config.tf
  5. terraform init
  6. terraform plan
  7. terraform apply -auto-approve

Config.tf contents

# Configure the Azure Provider
provider "azurerm" {
  version = "=2.0.0"
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "Australia East"
}

resource "azurerm_storage_account" "example" {
  name                     = "sa12345461234512name"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  tags = {
    environment = "staging"
  }
}

Not sure what i am missing, all other resources work fine, just the storage account.

Upvotes: 1

Views: 10835

Answers (4)

MaxiPalle
MaxiPalle

Reputation: 450

Same problem as @tesharp experienced. On my Ubuntu WSL2 the following command fixed the problem:

sudo hwclock -s

Upvotes: 0

tesharp
tesharp

Reputation: 41

Just to add to this since none of above worked. In my case it first didn't work, then next day worked just to not work again in the evening... Not changing versions or anything, was same computer.

It turned out that my time settings on my Ubuntu running in Windows was skewed. Just simply running a sudo ntpdate time.nist.gov to update time solved the problem.

Upvotes: 1

Doug
Doug

Reputation: 35106

This is a bug in the azure provider, see: https://github.com/terraform-providers/terraform-provider-azurerm/issues/5869

Update your provider; it doesn't seem to be related to the terraform version.

From:

# Configure the Azure Provider
provider "azurerm" {
  # whilst the `version` attribute is optional, we recommend pinning to a given version of the Provider
  version = "=2.0.0"
  features {}
}

To:

provider "azurerm" {
  version = "~> 2.1.0" 
  features {}
}

Upvotes: 1

Aeseir
Aeseir

Reputation: 8414

Found the issue. Its got to do with Terraform. Just checked for updates and notices 0.12.21 is out (I was runnning 0.12.20).

Seems like if running AzureARM 2.0.0 then really need to be min 0.12.21 to make it work.

Upvotes: 0

Related Questions