Skip to content

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

@harshal-vaidya-mox

Description

@harshal-vaidya-mox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions