简体   繁体   中英

Create google cloud bucket and save terraform state to it with the same terraform script?

I'm new to terraform, and am trying to use it to create and configure an entire project from scratch. We're currently thinking about it as 1 google project is one environment.

It seems reasonable to store the terraform remote state inside of a bucket in the project that it is configuring. ie have terraform create the google cloud project, create a bucket, and then store its own remote state in that bucket that it just created. That also seems very advanced and potentially chicken / egg.

Is it possible to store terraform scripts remote state in the project that the terraform script itself is creating?

You could use terraform to create the project and bucket and then migrate the state into that bucket. But this is a chicken/egg scenario that begs the question, what happens if you need to delete/rebuild the bucket containing the state?

A more sensible approach would be to manually create a master project and remote state bucket. From there you would have a base for a project vending machine to spin up new projects and baseline config.

No - you cannot do this. After days of research, this isn't something that's possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM