Hi,
I got an error when applying for creating an S3 bucket with logging enabled. Terraform apply gave the error
Error: error reading S3 Bucket Logging: empty output
I could not figure out what is the error from the message. Need some help. Thanks.
1 Like
Hey Libra! Can you provide your syntax?
Make sure to use the aws_s3_bucket_logging resource. See below!
resource "aws_s3_bucket_logging" "log_test" {
bucket = aws_s3_bucket.test-bucket10002000.id
target_bucket = aws_s3_bucket.log-bucket10002000.id
target_prefix = "log/"
}
Iām seeing a similar issue configuration looks like this, the issue is intermittent as well affecting different numbers of buckets each run. Any insight? Also a subsequent run will always have tainted resources which it properly sets logging on.
resource "aws_s3_bucket" "main_bucket" {
bucket = var.bucket_name
force_destroy = var.force_destroy
timeouts {
delete = "60m"
}
tags = {
Name = var.bucket_name
Tenant = var.tenant
Environment = var.environment
TerraformConfig = local.terraform_config
}
}
resource "aws_s3_bucket_logging" "main_bucket" {
bucket = aws_s3_bucket.main_bucket.id
target_bucket = var.s3_logging_bucket
target_prefix = "${var.bucket_name}/"
}
I was running into the same issue but was able to get past it by:
- Removing the
aws_bucket_logging
resource from the state
- Importing it back into the state
- Rerunning the apply