terraform backend s3 bucket creation returns 403 w/ Terraform 0.11.1

后端 未结 1 1220
时光说笑
时光说笑 2021-01-22 01:44

How do I create an S3 bucket that has access to put a terraform.tfstate file? How do I get the tfstate into the bucket? What is the proper way to do this?

To preface, I

相关标签:
1条回答
  • 2021-01-22 02:15

    Unfortunately that's the one caveat for using S3 as your backend to Terraform; you'll need to create the bucket manually. At times - a common pattern is that an organization will have multiple AWS accounts (For a variety of reasons - not just Terraform state) - this could be a possible option, to throw create your S3 bucket in that account, that way you can keep all of your other account's infrastructure defined by Terraform - but personally, I just create it by hand in my own account.

    One thing you can do, is import the bucket after the fact with terraform import if you wanted to manage it with Terraform, just of course there's the chicken and the egg problem still. Or - use a local state initially while creating the bucket, and then define it later; however either way you would not be able to dynamically reference the bucket via the resource object.

    But no - you cannot simultaneously create the bucket with Terraform while also setting it to your state.

    0 讨论(0)
提交回复
热议问题