UPD: taking a couple inputs as varibales

This commit is contained in:
xpk 2024-02-24 12:21:58 +08:00
parent fdc22c6179
commit cdcadc444e
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 15 additions and 3 deletions

View File

@ -26,7 +26,7 @@ resource "aws_ssm_maintenance_window" "this" {
name = replace(title(var.description), " ", "") name = replace(title(var.description), " ", "")
description = var.description description = var.description
schedule = var.cron-expression schedule = var.cron-expression
duration = 2 duration = var.maintenance-window-duration
cutoff = 1 cutoff = 1
} }
@ -58,7 +58,7 @@ resource "aws_ssm_maintenance_window_task" "this" {
task_invocation_parameters { task_invocation_parameters {
run_command_parameters { run_command_parameters {
timeout_seconds = 600 timeout_seconds = var.maintenance-window-duration * 60 - 15
cloudwatch_config { cloudwatch_config {
cloudwatch_log_group_name = aws_cloudwatch_log_group.this.name cloudwatch_log_group_name = aws_cloudwatch_log_group.this.name
@ -75,6 +75,6 @@ resource "aws_ssm_maintenance_window_task" "this" {
resource "aws_cloudwatch_log_group" "this" { resource "aws_cloudwatch_log_group" "this" {
name = "/aws/ssm-maintenance/${replace(title(var.description), " ", "")}" name = "/aws/ssm-maintenance/${replace(title(var.description), " ", "")}"
retention_in_days = 30 retention_in_days = var.cloudwatch-log-retention-days
log_group_class = "STANDARD" # infrequent access logs can only be viewed via insight log_group_class = "STANDARD" # infrequent access logs can only be viewed via insight
} }

View File

@ -21,4 +21,16 @@ variable description {
variable schedule-name { variable schedule-name {
type = string type = string
description = "Name of maintenance window. e.g. Daily0900UTC8" description = "Name of maintenance window. e.g. Daily0900UTC8"
}
variable maintenance-window-duration {
type = number
description = "Duration of maintenance window, must be >= 2"
default = 2
}
variable cloudwatch-log-retention-days {
type = number
description = "Days to retain logs on cloudwatch logs"
default = 30
} }