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

Creating a terraform resource in a non-existing region creates a resource in the default region instead of erroring out #5275

Closed
omar-albastami opened this issue Apr 15, 2024 · 0 comments · Fixed by #5297

Comments

@omar-albastami
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform IBM Provider Version

Observed in 1.59.0, but can be applied to other versions as well

Affected Resource(s)

Observed bug in ibm_cd_toolchain, but can also be applied to other resources

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

ibmcloud_api_key = "APIKEY"
region = "eu-es"

Debug Output

Example output follows. Note the value of the location property in the output, and note the region set in the above config

tf_empty_toolchain_attributes = {
  "account_id" = "4d686d1b782b51cfcf3219e51fe3d760"
  "created_at" = "2024-04-02T21:08:58.940Z"
  "created_by" = "IBMid-27000338XY"
  "crn" = "crn:v1:bluemix:public:toolchain:us-south:a/4d686d1b782b51cfcf3219e51fe3d760:dc54c57c-7606-4fea-af25-c6370084e06c::"
  "description" = ""
  "href" = "https://api.us-south.devops.cloud.ibm.com/toolchain/v2/toolchains/dc54c57c-7606-4fea-af25-c6370084e06c"
  "id" = "dc54c57c-7606-4fea-af25-c6370084e06c"
  "location" = "us-south"
  "name" = "tf-empty-toolchain-eu-es-provider-1_59_0"
  "resource_group_id" = "61bfd9aef1b94ed88ea339065d901823"
  "tags" = toset([])
  "ui_href" = "https://cloud.ibm.com/devops/toolchains/dc54c57c-7606-4fea-af25-c6370084e06c?env_id=ibm:yp:us-south"
  "updated_at" = "2024-04-02T21:08:58.940Z"
}

Panic Output

N/A

Expected Behavior

Since provider version 1.59.0 does not support eu-es in the CD toolchain service, the expected behaviour would be to produce a panic with a descriptive error informing the user that the region is invalid.

Actual Behavior

The provider falls back to the default service region, which in our case is us-south, and proceeds to create the resource.

Steps to Reproduce

  1. Create a terraform project and use terraform provider version 1.59.0.
  2. Create a terraform.tfvars file and define region as eu-es and ibmcloud_api_key as your production IAM API key.
  3. Define an ibm_cd_toolchain terraform resource.
  4. terraform apply

NOTE: running the steps in terraform provider version 1.60.0 and above produces the correct output, because this is when we added eu-es as a valid region. This is why the problem only exists in older provider versions.

Important Factoids

We did our own investigation, this is the problematic code https://github.com/IBM-Cloud/terraform-provider-ibm/blob/master/ibm/conns/config.go#L3162-L3174 . The service Go SDK is correctly identifying the region as invalid and is producing an error, but the terraform provider catches this error and purposely sets the service URL to the default one. While this may make sense for platform services, it introduces problems for regional services. The example I provided in the issue is specific to the toolchain service, but I believe that it extends to all other regional IBM Cloud services.

References

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant