-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Use the Rank from the environmentType when reading a deployment to allow valid imports of bitbucket_deployment
#186
Comments
nemoinho
pushed a commit
to nemoinho/terraform-provider-bitbucket
that referenced
this issue
Mar 19, 2024
nemoinho
pushed a commit
to nemoinho/terraform-provider-bitbucket
that referenced
this issue
Mar 19, 2024
The documentation from bitbucket is actually not that good, because it doesn't explain any of the fields in question. However I observed on the bitbucket-cloud instance that the previous implementation lead to errors during imports of deployment configurations into a terraform state. Steps to reproduce the error: 1. Create a repository in bitbucket-cloud 2. Create a deployment for the repository via GUI for Production or Staging (not Test!) 3. write a terraform module (which exactly matches the deployment) and perform `terraform import` to import the existing deployment into the terraform state 4. perform `terraform apply` and terraform wants to change the resource! This change reads the rank from the `environment_type` which is the only valid source if the deployment was created via UI and still a valid source for a deployment which was created via this provider.
nemoinho
pushed a commit
to nemoinho/terraform-provider-bitbucket
that referenced
this issue
Mar 19, 2024
The documentation from bitbucket is actually not that good, because it doesn't explain any of the fields in question. However I observed on the bitbucket-cloud instance that the previous implementation lead to errors during imports of deployment configurations into a terraform state. Steps to reproduce the error: 1. Create a repository in bitbucket-cloud 2. Create a deployment for the repository via GUI for Production or Staging (not Test!) 3. write a terraform module (which exactly matches the deployment) and perform `terraform import` to import the existing deployment into the terraform state 4. perform `terraform apply` and terraform wants to change the resource! This change reads the rank from the `environment_type` which is the only valid source if the deployment was created via UI and still a valid source for a deployment which was created via this provider. Reference: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-deployments/#api-repositories-workspace-repo-slug-environments-environment-uuid-get-response Closes: zahiar#186
nemoinho
pushed a commit
to nemoinho/terraform-provider-bitbucket
that referenced
this issue
Mar 19, 2024
The documentation from bitbucket is actually not that good, because it doesn't explain any of the fields in question. However I observed on the bitbucket-cloud instance that the previous implementation lead to errors during imports of deployment configurations into a terraform state. Steps to reproduce the error: 1. Create a repository in bitbucket-cloud 2. Create a deployment for the repository via GUI for Production or Staging (not Test!) 3. write a terraform module (which exactly matches the deployment) and perform `terraform import` to import the existing deployment into the terraform state 4. perform `terraform apply` and terraform wants to change the resource! This change reads the rank from the `environment_type` which is the only valid source if the deployment was created via UI and still a valid source for a deployment which was created via this provider. Reference: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-deployments/#api-repositories-workspace-repo-slug-environments-environment-uuid-get-response Closes: zahiar#186
nemoinho
changed the title
Please use the Rank from the environmentType when reading a deployment to allow valid imports of
Use the Rank from the environmentType when reading a deployment to allow valid imports of Mar 19, 2024
bitbucket_deployment
bitbucket_deployment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The deployment-resource is a rather seldom used but very useful resource.
Unfortunately the bitbucket-devs were a bit lazy with the requirements of this and didn't even bother to create a proper documentation of the actual response.
This lead to the confusing situation that the API respond with two different fields for the
rank
, one in the root of the response and one as part ofenvironment_type
. When you're going to create a deployment with the terraform-resource this is fine, because both occurences are going to be changed. But if you've set the rank through the UI, only the rank withinenvironment_type
is changed!If you then try to import a resource through
terraform import
it's impossible to import them correctly without a change!The
The simpliest solution to address this issue is a change of the attached line to look for
deployment.EnvironmentType.Rank
. As I said it doesn't change the behavior of a deployment created with this resource but enables a clean import!terraform-provider-bitbucket/bitbucket/resource_bitbucket_deployment.go
Lines 99 to 101 in 49edc9f
A sample for such an UI created deployment might look like this:
While a deployment via the resource might look like this:
The only diff is the
rank
on the root (and obviously the uuid).The text was updated successfully, but these errors were encountered: