sbercloud-terraform / terraform-provider-sbercloud

Terraform SberCloud Provider
https://registry.terraform.io/providers/sbercloud-terraform/sbercloud/latest/docs
Mozilla Public License 2.0
34 stars 21 forks source link

Authentication failed #303

Closed sleepdan closed 4 months ago

sleepdan commented 4 months ago

I am try to get started by this guide: https://cloud.ru/docs/terraform/ug/topics/quickstart.html. I create Access Key (AK) и Secret Key (SK). As say this guide https://cloud.ru/docs/terraform/ug/topics/guides__configuring-terraform-provider.html create config file for CLI (.terraformrc):

provider_installation {
   network_mirror {
      url = "https://terraform.cloud.ru/"
      include = ["registry.terraform.io/*/*"]
   }
   direct {
      exclude = ["registry.terraform.io/*/*"]
   }
}

When create variables.tf with my access and secret keys (values is ommited):

variable "access_key" {
        default = ""
        sensitive = true
}
variable "secret_key" {
        default = ""
        sensitive = true
}

For testing create a simple terraform config main.tf:

terraform {
  required_providers {
    sbercloud = {
      source  = "sbercloud-terraform/sbercloud" # Initialize Advanced provider
      version = "1.12.0"
    }
  }
}
provider "sbercloud" {
  auth_url = "https://iam.ru-moscow-1.hc.sbercloud.ru/v3" # Authorization address
  region   = "ru-moscow-1" # The region where the cloud infrastructure will be deployed
  access_key = var.access_key
  secret_key = var.secret_key
}

data "sbercloud_compute_flavors" "flavors" {
  region = "ru-moscow-1"
  performance_type  = "normal"
  cpu_core_count    = 2
  memory_size       = 4
}

output "flavors" {
  value = data.sbercloud_compute_flavors.flavors
}

Run % terraform init

Initializing the backend...
Initializing provider plugins...
- Finding sbercloud-terraform/sbercloud versions matching "1.12.0"...
- Installing sbercloud-terraform/sbercloud v1.12.0...
- Installed sbercloud-terraform/sbercloud v1.12.0 (verified checksum)

Terraform has made some changes to the provider dependency selections recorded
in the .terraform.lock.hcl file. Review those changes and commit them to your
version control system if they represent changes you intended to make.
╷

│ Warning: Incomplete lock file information for providers

│

│ Due to your customized provider installation methods, Terraform was forced to calculate lock file checksums locally for the following providers:

│   - sbercloud-terraform/sbercloud

│

│ The current .terraform.lock.hcl file only includes checksums for darwin_amd64, so Terraform running on another platform will fail to install these providers.

│

│ To calculate additional checksums for another platform, run:

│   terraform providers lock -platform=linux_amd64

│ (where linux_amd64 is the platform to generate)

╵
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

After all i try run "terraform plan" and get following output with error:

data.sbercloud_compute_flavors.flavors: Reading...

Planning failed. Terraform encountered an error while generating this plan.
│ Error: Authentication failed
│   with data.sbercloud_compute_flavors.flavors,
│   on main.tf line 20, in data "sbercloud_compute_flavors" "flavors":
│   20: data "sbercloud_compute_flavors" "flavors" {

Why??

Terraform Version

Terraform v1.5.7 on darwin_amd64

Affected Resource(s)

Terraform Configuration Files

terraform {
  required_providers {
    sbercloud = {
      source  = "sbercloud-terraform/sbercloud" # Initialize Advanced provider
      version = "1.12.0"
    }
  }
}
provider "sbercloud" {
  auth_url = "https://iam.ru-moscow-1.hc.sbercloud.ru/v3" # Authorization address
  region   = "ru-moscow-1" # The region where the cloud infrastructure will be deployed
  access_key = var.access_key
  secret_key = var.secret_key
}

data "sbercloud_compute_flavors" "flavors" {
  region = "ru-moscow-1"
  performance_type  = "normal"
  cpu_core_count    = 2
  memory_size       = 4
}

output "flavors" {
  value = data.sbercloud_compute_flavors.flavors
}

Debug Output

data.sbercloud_compute_flavors.flavors: Reading...

Planning failed. Terraform encountered an error while generating this plan. │ Error: Authentication failed │ with data.sbercloud_compute_flavors.flavors, │ on main.tf line 20, in data "sbercloud_compute_flavors" "flavors": │ 20: data "sbercloud_compute_flavors" "flavors" {

Panic Output

Expected Behavior

No errors

Actual Behavior

Got error

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan
0ohmresistor commented 4 months ago

Try to create new folder, move your main.tf and variables.tf and run terraform init there. Also try to create new access key. If this doesn't work, run TF_LOG=debug terraform plan command and paste here the output.