-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoscaling.tf
98 lines (84 loc) · 2.75 KB
/
autoscaling.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
module "plex_autoscaling" {
source = "terraform-aws-modules/autoscaling/aws"
version = "~> 7.7"
name = "plex"
use_name_prefix = true
ignore_desired_capacity_changes = true
min_size = 1
max_size = 1
desired_capacity = 1
wait_for_capacity_timeout = 0
health_check_type = "EC2"
vpc_zone_identifier = module.vpc.public_subnets
instance_initiated_shutdown_behavior = "terminate"
protect_from_scale_in = false
instance_refresh = {
strategy = "Rolling"
preferences = {
checkpoint_delay = 600
checkpoint_percentages = [35, 70, 100]
instance_warmup = 30
min_healthy_percentage = 50
}
}
launch_template_name = "plex"
update_default_version = true
image_id = data.aws_ami.plex.id
instance_type = var.instance_type
user_data = base64encode(templatefile("${path.module}/templates/userdata.sh",
{
BUCKETS = local.buckets,
BUCKET_FSTAB_STRING = local.bucket_fstab_string
CONFIG_BUCKET = module.s3_plex_db.s3_bucket_id
}
))
ebs_optimized = true
enable_monitoring = false
block_device_mappings = [
{
# Root volume
device_name = "/dev/xvda"
no_device = 0
ebs = {
delete_on_termination = true
encrypted = true
volume_size = var.instance_storage_size
volume_type = "gp3"
iops = 3000
throughput = 125
}
}
]
create_iam_instance_profile = true
iam_role_name = "plex"
iam_role_path = "/ec2/"
iam_role_policies = {
AmazonSSMManagedInstanceCore = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore",
AmazonEC2ContainerServiceforEC2Role = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role",
S3Access = aws_iam_policy.plex_server.arn
}
capacity_reservation_specification = {
capacity_reservation_preference = "open"
}
instance_market_options = {
market_type = "spot"
}
maintenance_options = {
auto_recovery = "default"
}
metadata_options = {
http_endpoint = "enabled"
http_tokens = "optional"
http_put_response_hop_limit = 32
instance_metadata_tags = "enabled"
}
network_interfaces = [
{
associate_public_ip_address = true
delete_on_termination = true
description = "eth0"
device_index = 0
security_groups = [aws_security_group.plex_admin.id]
}
]
}