Skip to content

Commit 8483dd2

Browse files
committed
NRL-1385 base ec2 set up
1 parent 8a6a522 commit 8483dd2

File tree

1 file changed

+97
-0
lines changed
  • terraform/account-wide-infrastructure/modules/ec2

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module "autoscaling" {
2+
source = "registry.terraform.io/terraform-aws-modules/autoscaling/aws"
3+
version = "6.5.2"
4+
5+
name = "PowerBI-On-Premise-Gateway"
6+
7+
min_size = 0
8+
max_size = 1
9+
desired_capacity = 1
10+
11+
# Autoscaling Schedule
12+
schedules = {
13+
morning_start = {
14+
min_size = -1
15+
max_size = -1
16+
desired_capacity = 1
17+
recurrence = "50 5 * * 0-6"
18+
time_zone = "Europe/Paris"
19+
}
20+
21+
morning_stop = {
22+
min_size = -1
23+
max_size = -1
24+
desired_capacity = 0
25+
recurrence = "30 6 * * 0-6"
26+
time_zone = "Europe/Paris"
27+
}
28+
29+
noon_start = {
30+
min_size = -1
31+
max_size = -1
32+
desired_capacity = 1
33+
recurrence = "50 11 * * 0-6"
34+
time_zone = "Europe/Paris"
35+
}
36+
37+
noon_stop = {
38+
min_size = -1
39+
max_size = -1
40+
desired_capacity = 0
41+
recurrence = "30 12 * * 0-6"
42+
time_zone = "Europe/Paris"
43+
}
44+
45+
evening_start = {
46+
min_size = -1
47+
max_size = -1
48+
desired_capacity = 1
49+
recurrence = "50 17 * * 0-6"
50+
time_zone = "Europe/Paris"
51+
}
52+
53+
evening_stop = {
54+
min_size = -1
55+
max_size = -1
56+
desired_capacity = 0
57+
recurrence = "30 18 * * 0-6"
58+
time_zone = "Europe/Paris"
59+
}
60+
}
61+
62+
wait_for_capacity_timeout = 0
63+
health_check_type = "EC2"
64+
health_check_grace_period = 300
65+
enable_monitoring = false
66+
67+
#image_id = data.aws_ami.windows.id // Phase 2 : we let the Auto Scaling Group use the AMI we've juste created.
68+
image_id = data.aws_ami.final.id
69+
launch_template_version = "$Latest"
70+
instance_type = "m5a.large"
71+
72+
instance_market_options = {
73+
market_type = "spot"
74+
}
75+
76+
# Refresh instances when redeploying
77+
instance_refresh = {
78+
strategy = "Rolling"
79+
triggers = ["tag"]
80+
}
81+
82+
# Assign a role to the instance
83+
create_iam_instance_profile = true
84+
iam_role_name = "powerbi-gateway-role"
85+
iam_role_description = "Allow the Power BI Gateway to be managed by"
86+
iam_role_policies = {
87+
AmazonSSMManagedInstanceCore = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
88+
}
89+
key_name = aws_key_pair.ec2_key_pair.key_name
90+
91+
vpc_zone_identifier = data.aws_subnets.subnets.ids
92+
93+
security_groups = [module.security-group-outbound.security_group_id]
94+
95+
user_data = filebase64("./userdata.txt")
96+
update_default_version = true
97+
}

0 commit comments

Comments
 (0)