generated from GSA/template-brokerpak
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new: add code to schedule EC2 patching It doesn't work yet because the user deploying maintenance schedule needs IAM permissions; but this should bethe basic configuration * fix: can only use tags for target selection via a maint window target * update: eks service definition with maintenance.tf Co-authored-by: Nicholas Kumia <[email protected]>
- Loading branch information
1 parent
c49627d
commit cb233ca
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
resource "aws_ssm_maintenance_window" "window" { | ||
name = "maintenance-window-webapp" | ||
schedule = "cron(0 16 ? * * *)" | ||
duration = 3 | ||
cutoff = 1 | ||
} | ||
|
||
resource "aws_ssm_maintenance_window_target" "owned-instances" { | ||
window_id = aws_ssm_maintenance_window.window.id | ||
name = "${local.cluster_name}-instances" | ||
description = "The set of EC2 instances owned by ${local.cluster_name}" | ||
resource_type = "INSTANCE" | ||
|
||
targets { | ||
key = "tag:kubernetes.io/cluster/${local.cluster_name}" | ||
values = ["owned"] | ||
} | ||
} | ||
|
||
resource "aws_ssm_maintenance_window_task" "patch-vulnerabilities" { | ||
name = "${local.cluster_name}-patching" | ||
max_concurrency = 2 | ||
max_errors = 1 | ||
priority = 1 | ||
task_arn = "AWS-RunPatchBaseline" | ||
task_type = "RUN_COMMAND" | ||
window_id = aws_ssm_maintenance_window.window.id | ||
|
||
targets { | ||
key = "WindowTargetIds" | ||
values = [aws_ssm_maintenance_window_target.owned-instances.id] | ||
} | ||
|
||
task_invocation_parameters { | ||
run_command_parameters { | ||
timeout_seconds = 600 | ||
|
||
parameter { | ||
name = "Operation" | ||
values = ["Install"] | ||
} | ||
} | ||
} | ||
} |