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

Importing a GCS bucket results in terraform wanting to change the bucket immediately afterwards #1161

Closed
NAJ10 opened this issue Mar 7, 2018 · 2 comments · Fixed by #1223
Labels

Comments

@NAJ10
Copy link

NAJ10 commented Mar 7, 2018

Terraform Version

Terraform v0.11.3

  • provider.google v1.6.0

Affected Resource(s)

  • google_storage_bucket

Terraform Configuration Files

terraform {
  backend "gcs" {
    bucket = "terraform-states"
    path = "gcp/gcp.tfstate"
    project = "demo"
  }
}

variable "project_name" {
  default = "demo"
}   
    
variable "primary_region" {
  description = "Specifies the region the infrastructure should be created in"
  type = "string"
  default = "europe-west1"
}

provider "google" {
  project = "${var.project_name}"
  region = "${var.primary_region}"
  version = "1.6"
}

resource "demo-bucket" "demo-bucket" {
  force_destroy = "false"
  name = "demo-bucket"
  location = "EUROPE-WEST1"
}

What should have happened?
importing a GCS bucket created outside of terraform should not result in a terraform plan command wanting to try to change the force_destroy state of the bucket

Actual Behavior

After importing the GCS bucket a terraform plan command wanted to update the bucket in place because of the force_destroy state.

Steps to Reproduce

~/Development/repository/demo/terraform/nonprod$ terraform init

Initializing the backend...
"path": [DEPRECATED] Use the "prefix" option instead

Successfully configured the backend "gcs"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...

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.
~/Development/repository/demo/terraform/nonprod$ terraform import google_storage_bucket.demo-bucket demo-bucket
google_storage_bucket.demo-bucket: Importing from ID "demo-bucket"...
google_storage_bucket.demo-bucket: Import complete!
Imported google_storage_bucket (ID: demo-bucket)
google_storage_bucket.demo-bucket: Refreshing state... (ID: demo-bucket)

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

~/Development/repository/demo/terraform/nonprod$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

google_storage_bucket.demo-bucket: Refreshing state... (ID: demo-bucket)


An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

~ google_storage_bucket.demo-bucket
force_destroy: "" => "false"

Plan: 0 to add, 1 to change, 0 to destroy.


Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
Please list the steps required to reproduce the issue, for example:

  1. terraform apply
@rosbo
Copy link
Contributor

rosbo commented Mar 7, 2018

As a workaround before we publish a fix you can manually update your state file to set force_destroy to false.

@rosbo rosbo added the bug label Mar 7, 2018
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Sep 27, 2019
@ghost
Copy link

ghost commented Mar 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants