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

storage bucket being created by tf despite being manually created due to requirements of tf backend block #23

Open
harshal-vaidya-mox opened this issue Jun 17, 2021 · 2 comments

Comments

@harshal-vaidya-mox
Copy link

harshal-vaidya-mox commented Jun 17, 2021

I'm using AWS.

The backend block uses the same bucket which is referenced by var.storage_bucket. The bucket used by the backend block needs to exist before tf is kicked in.

Store Terraform state in S3`
terraform {
backend "s3" {
# The bucket name is a variable defined in 'terraform.tfvars' (as 'storage_bucket'), but variables are not allowed in this block. If you change this, you will need to change that.
bucket = "mox-opencti-storage"
key = "terraform.tfstate"
# Again, no variable interpolation in this block so make sure this matches the region defined in 'terraform.tfvars'. Default 'us-east-1'.
region = "ap-southeast-1"
}
}

When tf runs the var.storage_bucket is again created which results in the following error during apply.

Error: Error creating S3 bucket: BucketAlreadyOwnedByYou: Your previous request to create the named bucket succeeded and you already own it.
status code: 409, request id: 8Z941E8XX87E8B2V, host id: bZnhhA0Wqgx1NpnCqZtT08+ut0z67ReihQmFBB4ER6CSYlIqDZP+nLKUu7rGpf5TsDqfysXDDZM=
on storage.tf line 2, in resource "aws_s3_bucket" "opencti_bucket":
2: resource "aws_s3_bucket" "opencti_bucket" {

The offending block is:

S3 bucket to store install and connectors scripts.
resource "aws_s3_bucket" "opencti_bucket" {
bucket = var.storage_bucket
acl = "private"
//Turn on bucket versioning. We'll be storing the Terraform state in S3 and versioning will help protect against human error.
versioning {
enabled = true
}
}

Please remove this offending block and re-arrange the code.

@ozuser
Copy link

ozuser commented Jan 7, 2022

+1

@chrisrios88
Copy link

Running into the same issue -- Do you have a fix?


2022-04-11T16:00:13.569-0400 [DEBUG] [aws-sdk-go]

│ Warning: Argument is deprecated

│ with aws_s3_bucket.opencti_bucket,
│ on storage.tf line 2, in resource "aws_s3_bucket" "opencti_bucket":
│ 2: resource "aws_s3_bucket" "opencti_bucket" {

│ Use the aws_s3_bucket_versioning resource instead

│ (and one more similar warning elsewhere)


│ Error: error creating S3 Bucket (opencti-storage): BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants