Adding Google Storage Bucket that already exist

236 views
Skip to first unread message

Jim Alateras

unread,
May 20, 2019, 5:46:31 PM5/20/19
to Terraform
I was wondering whether there was a way to add a bucket that already exists to my terraform script. Currently, this throws a 409, bucket name already exists exception. Is there a lifecycle hook or something similar that would allow me to skip the creation of the bucket if it exists.

resource "google_storage_bucket" "etcd-backup" {
name = "${var.etcd_bucket}"
location = "US-WEST1"
project = "${var.project_id}"
}

cheers
</jima>

Stuart Clark

unread,
May 20, 2019, 5:47:16 PM5/20/19
to terrafo...@googlegroups.com, Jim Alateras

Use "terraform import"


-- 
Stuart Clark

ameya agashe

unread,
May 20, 2019, 8:02:49 PM5/20/19
to terrafo...@googlegroups.com, Jim Alateras
Why cannot we use a "data" resource rather than "terraform import". Would love to learn

Ameya

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/7cdc2f82-b74a-40e0-e1c6-d55805e4ca68%40Jahingo.com.
For more options, visit https://groups.google.com/d/optout.

Stuart Clark

unread,
May 20, 2019, 8:17:47 PM5/20/19
to terrafo...@googlegroups.com, ameya agashe, Jim Alateras
On 21/05/2019 01:02, ameya agashe wrote:
Why cannot we use a "data" resource rather than "terraform import". Would love to learn

It depends what you are trying to achieve.

If you are wanting Terraform to manage the bucket, add the resource and the run "terraform import".

If you are just wanting to refer to the bucket elsewhere, but not manage the bucket, use a data source.



For more options, visit https://groups.google.com/d/optout.


-- 
Stuart Clark

ameya agashe

unread,
May 20, 2019, 8:19:46 PM5/20/19
to Stuart Clark, terrafo...@googlegroups.com, Jim Alateras
Ok got it. Just to be clear when you say "manage", you create, change and destroy?

Ameya

Stuart Clark

unread,
May 20, 2019, 8:20:41 PM5/20/19
to terrafo...@googlegroups.com, ameya agashe, Jim Alateras
Yes
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Jim Alateras

unread,
May 20, 2019, 8:21:49 PM5/20/19
to Terraform
Thanks Stuart,

worked like a charm

ameya agashe

unread,
May 20, 2019, 8:55:07 PM5/20/19
to Stuart Clark, terrafo...@googlegroups.com, Jim Alateras
Thanks Stuart
Reply all
Reply to author
Forward
0 new messages