Closed ArghyaChakraborty closed 11 months ago
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Description
I am trying to create a new S3 bucket with CORS rules configured. But Terraform fails in Plan phase with following error: Error: Invalid count argument on .terraform/modules/s3_interim_bucket/main.tf line 200, in resource "aws_s3_bucket_cors_configuration" "this": 200: count = local.create_bucket && length(local.cors_rules) > 0 ? 1 : 0 The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on.
If your request is for a new feature, please use the
Feature request
template.⚠️ Note
Before you submit an issue, please perform the following first:
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
terraform init
Versions
Module version [Required]:
Terraform version:
v3.2.1Provider version(s):
aws: v5.21.0Reproduction Code [Required]
module "s3_interim_bucket" { source = "terraform-aws-modules/s3-bucket/aws"
bucket = "some-bucket" acl = "private"
control_object_ownership = true object_ownership = "ObjectWriter" force_destroy = true
block_public_acls = true block_public_policy = true ignore_public_acls = true restrict_public_buckets = true
versioning = { enabled = false }
lifecycle_rule = [ { id = "file" enabled = true
]
cors_rule = [ { allowed_headers = ["*"], allowed_methods = ["GET"], allowed_origins = ["https://corporatedns.com"], expose_headers = [] } ]
server_side_encryption_configuration = { rule = { apply_server_side_encryption_by_default = { sse_algorithm = "AES256" } } } }
Steps to reproduce the behavior:
NO YESJust doing terraform init -> terraform plan -> the above mentioned issue arises
Expected behavior
We would expect the S3 bucket to be created and CORS rules to be applied properly
Actual behavior
The terraform plan failed. Pasted error message at the top
Terminal Output Screenshot(s)
Additional context