aliyun / terraform-provider-alicloud

Terraform AliCloud provider
https://www.terraform.io/docs/providers/alicloud/
Mozilla Public License 2.0
579 stars 539 forks source link

Terraform init with oss backend configuration fails #3624

Open arun2205 opened 3 years ago

arun2205 commented 3 years ago

Hi,

I am trying to create ECS instance using terraform with oss as a backend configuration to store terraform statefile.

Terraform Version

Terraform version: 0.15.4

Terraform Configuration Files

provider "alicloud" { access_key = "${var.access_key}" secret_key = "${var.secret_key}" region = "${var.region}" } terraform { required_providers { alicloud = { source = "aliyun/alicloud" version = "~> 1.123.0" } }

backend "oss" { bucket = "alicloud-dev" prefix = "terraform-state/test" endpoint = "https://oss-cn-shanghai.aliyuncs.com" region = "cn-shanghai" }

}

Debug Output

Initializing the backend... 2021-06-11T17:02:07.429+0800 [DEBUG] Instantiate OSS client using endpoint: "https://oss-cn-shanghai.aliyuncs.com" ╷ │ Error: Failed to get existing workspaces: oss: service returned error: StatusCode=400, ErrorCode=InvalidArgument, ErrorMessage="Authorization header is invalid.", RequestId=60C3268F3BA05A313934DDB7

Expected Behavior

Terraform should intialize and store statefile in oss

Actual Behavior

  1. Giving authetication error even after hardcoding access-key and secrete key in provider block
  2. Same working if i export access key and secret id as env varaiables as below export ALICLOUD_ACCESS_KEY="anaccesskey" export ALICLOUD_SECRET_KEY="asecretkey" export ALICLOUD_REGION="cn-beijing" Output:

machine and OS details

os: Ubuntu 20.04 64-bit platform: alibabacloud machine-type: ecs.n1.small CPU & Memory: 1Cores 2 GiB

is there i need to configure anything specifically?

SORC3r3r commented 3 years ago

Having the same issue. It worked before (last tested 2-3 weeks ago).

mihaics commented 3 years ago

Mee to, same issue with oss backend

fsdrw08 commented 1 year ago

same issue, any updates?

mstewio commented 3 months ago

Setting my access and secret keys as system variables in my PC advanced settings fixed the issue for me. Variables must be named ALICLOUD_ACCESS_KEY and ALICLOUD_SECRET_KEY