How to overwrite base module variable in extended module ? Here I want to change transition_to_std_ia_day to override the value to 120 days, how do I do that? when I try to access the variable to set the variable , terraform plan complains "An argument or block definition is required here" !!
base module main.tf:
resource "aws_s3_bucket_lifecycle_configuration" "bucket_lifecycle_config" {
bucket = module.s3.bucket_name
rule {
id = "lc_pd_rule"
status = "Enabled"
"transition" {
content {
days = var.custom_lc_rule.transition_to_std_ia_day
storage_class = "STANDARD_IA"
}
}
variable "custom_lc_rule" {
type = map(string)
description = "Custom lifecycle rule to choose days for Standard-IA, Glacier, and Expiration."
default = {
"transition_to_std_ia_day" = "30",
"transition_to_glacier_day" = "90",
"objects_expire_days" = "365"
}
}
-- here is my sub module life-cycle config calling source as base module above.
resource "aws_s3_bucket_lifecycle_configuration" "bucket_lifecycle_config" {
bucket = module.s3.bucket_name
rule {
id = "prod_rule"
status = "Enabled"
transition {
days = var.custom_lc_rule.trans_standard_ia_day
storage_class = "STANDARD_IA"
}
transition {
days = var.custom_lc_rule.trans_glacier_day
storage_class = "GLACIER"
}
expiration {
days = var.custom_lc_rule.expiration_day
}
}
}
variables.tf - submodule variables tf file has the transition and expiration days defined as below.
variable "custom_lc_rule" {
type = map(string)
description = "Custom prod lifecycle rule for Standard-IA, Glacier, and expiration days."
default = {
"trans_standard_ia_day" = "60",
"trans_glacier_day" = "180",
"expiration_day" = "2555"
}
}
Wondering how the tf runtime reads these variables? I see very random behavior. code works fine sometimes. but weird sometimes it doesn't consider submodule variables .