boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

Exception Armrest::Error: #<Net::HTTPUnauthorized:0x0000561554b473e0> when executing terraspace up demo -y #297

Closed teddimitrov closed 1 year ago

teddimitrov commented 1 year ago

Checklist

My Environment

Software Version
Operating System Linux 5.15.90.1-microsoft-standard-WSL2 (Debian 11 Bullseye)
Terraform v1.4.2
Terraspace 2.2.3
Ruby ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]

After executing terraspace up demo -y for the terraform code to be deployed in the azure subscription

Building .terraspace-cache/eastus/dev/stacks/demo Current directory: .terraspace-cache/eastus/dev/stacks/demo Creating Resource Group dev-eastus... Exception Armrest::Error: #

download and install terraspace on debian run terraspace new project infra --plugin azurerm --examples followed by terraspace up demo -y

According to bundle exec ruby azure_check.rb:

Successfully connected to Azure with your ARM_CLIENT_ID and ARM_CLIENT_SECRET

terraspace setup check:

Detected Terraspace version: 2.2.3 Detected Terraform bin: /usr/bin/terraform Detected Terraform v1.4.2 Terraspace requires Terraform v0.12.x and above You're all set!

Code Sample

Solution Suggestion

ikhudur commented 1 year ago

Hello,

I also had this problem, and the solution in this issue worked for me: https://github.com/boltops-tools/terraspace/issues/220#issuecomment-1059087698

I.e. I ran the following command in azure cli:

az provider register --namespace Microsoft.Storage

teddimitrov commented 1 year ago

With the help of "export ARMREST_LOG_LEVEL=debug" (from the post about similar issue #220 ) I can glean additional information and it seems related to authorization. I'll revisit the documentation and videos on the site to see if I can get past that error:

D, [2023-03-30T14:59:05.430528 #19537] DEBUG -- : resp # D, [2023-03-30T14:59:05.430654 #19537] DEBUG -- : resp.code 401 D, [2023-03-30T14:59:05.430688 #19537] DEBUG -- : resp.body {"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}}

teddimitrov commented 1 year ago

After exporting again the azure environment variables (ARM_SUBSCRIPTION_ID and the rest) I was able to successfully run terraspace! Nothing wrong with terraspace itself but a newbie user error :)

PS. After I resolved the initial error I ran into a second roadblock but thanks to the output from "export ARMREST_LOG_LEVEL=debug" I was able to determine that it was due to a policy I had applied to the subscription - "Public network access should be disabled for PaaS services".