-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssm.tf
61 lines (54 loc) · 1.66 KB
/
ssm.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#################
# Patch manager #
#################
resource "aws_ssm_patch_baseline" "patch_baseline" {
name = "patch-baseline-${var.var_dev_environment}"
description = "Patch repository for ${local.operating_system}"
operating_system = local.operating_system
approved_patches = ["AWS-AmazonLinux2DefaultPatchBaseline"]
}
resource "aws_ssm_patch_group" "patch_group" {
baseline_id = aws_ssm_patch_baseline.patch_baseline.id
patch_group = "${var.var_name}-${var.var_dev_environment}-patch-group"
}
##################
# Resource group #
##################
# Change tag filter for environment type (test,development,stage,production)
resource "aws_resourcegroups_group" "mw_target_group" {
name = "${var.var_name}-${var.var_dev_environment}-resource-group"
resource_query {
query = <<JSON
{
"ResourceTypeFilters": [
"AWS::EC2::Instance"
],
"TagFilters": [
{
"Key": "user:Environment",
"Values": ["stage","bastion"]
}
]
}
JSON
}
}
###########################
# SSM Maintainance window #
###########################
resource "aws_ssm_maintenance_window" "m_window" {
name = "${var.var_name}-${var.var_dev_environment}-maintenance-window"
schedule = "cron(0 0 * * ? *)"
duration = 3
cutoff = 1
}
resource "aws_ssm_maintenance_window_target" "instance_env" {
window_id = aws_ssm_maintenance_window.m_window.id
name = "${var.var_name}-${var.var_dev_environment}-mw-target"
description = "This is a maintenance window target"
resource_type = "RESOURCE_GROUP"
targets {
key = "resource-groups:Name"
values = ["${var.var_name}-${var.var_dev_environment}-resource-group"]
}
}