Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with sbercloud_obs_bucket #157

Closed
Uiopas opened this issue Sep 6, 2022 · 0 comments
Closed

Problem with sbercloud_obs_bucket #157

Uiopas opened this issue Sep 6, 2022 · 0 comments

Comments

@Uiopas
Copy link

Uiopas commented Sep 6, 2022

Hi there,

I ran into the problem that the variable enterprise_project_id is overwritten after executing terraform apply, although it is displayed correctly in terraform plan.

Terraform Version

terraform -v
Terraform v1.1.8
on darwin_amd64

Affected Resource(s)

  • sbercloud_obs_bucket

Terraform Configuration Files

resource "sbercloud_obs_bucket" "b" {
  bucket = "my-first-tf-test-bucket"
  acl    = "private"

  enterprise_project_id = data.sbercloud_enterprise_project.test.id
}
data "sbercloud_enterprise_project" "test" {
  name = "mytestiest"
}

Expected Behavior

I Expected behavior like this in terraform plan and than I'm used terraform apply -auto-approve.

 resource "sbercloud_obs_bucket" "b" {
      acl                   = "private"
      bucket                = "my-first-tf-test-bucket"
      bucket_domain_name    = (known after apply)
      bucket_version        = (known after apply)
      encryption            = false
      enterprise_project_id = "8909dsada-efhjks-sada-..."
      force_destroy         = false
      id                    = (known after apply)
      multi_az              = (known after apply)
      policy                = (known after apply)
      policy_format         = "obs"
      quota                 = 0
      region                = (known after apply)
      storage_class         = "STANDARD"
      versioning            = false
 }

But After apply I got enterprise_project_id = 0.

Steps to Reproduce

  1. terraform plan
  2. terraform apply -auto-approve

Solve

I solved this problem by rebuilding the provider, but before that I deleted a few lines in the files.
In file vendor/github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/common.go

func GetEnterpriseProjectID(d *schema.ResourceData, config *config.Config) string {
	if v, ok := d.GetOk("enterprise_project_id"); ok {
		return v.(string)
	}

	return config.EnterpriseProjectID
}

and in vendor/github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/common/common.go

func GetEnterpriseProjectID(d *schema.ResourceData, config *config.Config) string {
	if v, ok := d.GetOk("enterprise_project_id"); ok {
		return v.(string)
	}

	return config.EnterpriseProjectID
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants