Terraform detects changes and adds/removes resources when executed apply/plan for next time to changes made in aws_s3_bucket_lifecycle_configuration expiration value. Earlier all the s3 bucket resource were under same block I haven’t faced any issue in the deployment. After separation of s3 resource in separate blocks I am facing this issue
Blockquoteresource “aws_s3_bucket” “karthik_s3” {
bucket = module.naming.name
tags = module.tags.default_tags
}
resource “aws_s3_bucket_versioning” “karthik_s3_versioning” {
bucket = aws_s3_bucket.karthik_s3.id
versioning_configuration {
status = “Enabled”
}
}
resource “aws_s3_bucket_server_side_encryption_configuration” “karthik_s3_encryption” {
bucket = aws_s3_bucket.karthik_s3.bucket
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = aws_kms_key.kms_key.arn
sse_algorithm = “aws:kms”
}
}
}
resource “aws_s3_bucket_lifecycle_configuration” “karthik_s3_lifecycle” {
bucket = aws_s3_bucket.karthik_s3.id
rule {
id = “expire_all_files”
expiration {
days = 30
}
noncurrent_version_expiration {
noncurrent_days = 30
}
status = "Enabled"
}
}
resource “aws_s3_bucket_policy” “karthik_s3_policy” {
bucket = aws_s3_bucket.karthik_s3.id
policy = data.aws_iam_policy_document.karthik_s3_policy_document.json
}
Blockquote