-
Notifications
You must be signed in to change notification settings - Fork 22
/
basic_usage.tf
158 lines (137 loc) · 5.1 KB
/
basic_usage.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
terraform {
required_version = ">= 1.0.0"
}
provider "aws" {
version = "~> 3.0"
region = "us-west-2"
}
resource "random_string" "name_rstring" {
length = 8
special = false
}
module "vpc" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-vpc_basenetwork?ref=v0.12.7"
name = "${random_string.name_rstring.result}-ec2-asg-basenetwork-example"
}
data "aws_region" "current_region" {}
resource "random_string" "sqs_rstring" {
length = 18
special = false
upper = false
}
resource "aws_sqs_queue" "ec2_asg_test_sqs" {
name = "${random_string.sqs_rstring.result}-my-example-queue"
}
module "sns" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-sns?ref=v0.12.2"
create_subscription_1 = true
endpoint_1 = aws_sqs_queue.ec2_asg_test_sqs.arn
name = "${random_string.sqs_rstring.result}-ec2-asg-test-topic"
protocol_1 = "sqs"
}
module "clb" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-clb?ref=v0.12.4"
name = "${random_string.name_rstring.result}-ec2-asg-clb-example"
security_groups = [module.vpc.default_sg]
subnets = module.vpc.public_subnets
internal_loadbalancer = false
create_logging_bucket = false
rackspace_managed = false
tags = {
Example = "Example-clb"
}
listeners = [
{
instance_port = 8000
instance_protocol = "HTTP"
lb_port = 80
lb_protocol = "HTTP"
},
]
}
module "ec2_asg" {
source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-ec2_asg?ref=v0.12.23"
asg_count = "2"
asg_wait_for_capacity_timeout = "10m"
backup_tag_value = "False"
cloudwatch_log_retention = "30"
cw_high_evaluations = "3"
cw_high_operator = "GreaterThanThreshold"
cw_high_period = "60"
cw_high_threshold = "60"
cw_low_evaluations = "3"
cw_low_operator = "LessThanThreshold"
cw_low_period = "300"
cw_low_threshold = "30"
cw_scaling_metric = "CPUUtilization"
detailed_monitoring = true
ec2_os = "centos7"
ec2_scale_down_adjustment = "1"
ec2_scale_down_cool_down = "60"
ec2_scale_up_adjustment = "1"
ec2_scale_up_cool_down = "60"
enable_ebs_optimization = false
enable_scaling_notification = true
encrypt_secondary_ebs_volume = false
environment = "Development"
health_check_grace_period = "300"
health_check_type = "EC2"
install_codedeploy_agent = false
instance_role_managed_policy_arn_count = "3"
instance_type = "t2.micro"
load_balancer_names = [module.clb.name]
name = "${random_string.name_rstring.result}-ec2-asg-instance-example"
perform_ssm_inventory_tag = "True"
primary_ebs_volume_iops = "0"
primary_ebs_volume_size = "60"
primary_ebs_volume_type = "gp2"
rackspace_managed = true
scaling_max = "2"
scaling_min = "1"
scaling_notification_topic = module.sns.topic_arn
secondary_ebs_volume_iops = "0"
secondary_ebs_volume_size = "60"
secondary_ebs_volume_type = "gp2"
security_groups = [module.vpc.default_sg]
ssm_association_refresh_rate = "rate(1 day)"
ssm_patching_group = "MyPatchGroup1"
subnets = [element(module.vpc.public_subnets, 0), element(module.vpc.public_subnets, 1)]
tenancy = "default"
terminated_instances = "30"
instance_role_managed_policy_arns = [
"arn:aws:iam::aws:policy/AmazonEC2FullAccess",
"arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetTaggingRole",
"arn:aws:iam::aws:policy/CloudWatchActionsEC2Access",
]
ssm_bootstrap_list = [
{
action = "aws:runDocument",
inputs = {
documentPath = "arn:aws:ssm:${data.aws_region.current_region.name}:507897595701:document/Rack-Install_Package",
documentParameters = {
Packages = "tmux"
},
documentType = "SSMDocument"
},
name = "InstallTmux",
timeoutSeconds = 300
},
{
action = "aws:runDocument",
inputs = {
documentPath = "AWS-RunShellScript",
documentParameters = {
commands = ["touch /tmp/myfile"]
},
documentType = "SSMDocument"
},
name = "CreateFile",
timeoutSeconds = 300
},
]
tags = {
MyTag1 = "Myvalue1"
MyTag2 = "Myvalue2"
MyTag3 = "Myvalue3"
}
}