opencti-terraform icon indicating copy to clipboard operation
opencti-terraform copied to clipboard

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

Open harshal-vaidya-mox opened this issue 3 years ago • 2 comments

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.

harshal-vaidya-mox avatar Jun 17 '21 11:06 harshal-vaidya-mox

+1

ozuser avatar Jan 07 '22 05:01 ozuser

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.

chrisrios88 avatar Apr 11 '22 20:04 chrisrios88