-
Notifications
You must be signed in to change notification settings - Fork 0
/
instances.tf
30 lines (25 loc) · 1.25 KB
/
instances.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
##################################################################################
# DATA
##################################################################################
data "aws_ssm_parameter" "ami" {
name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
}
##################################################################################
# RESOURCES
##################################################################################
# INSTANCES #
resource "aws_instance" "nginx-instances" {
count = var.aws_instance_count[terraform.workspace]
ami = nonsensitive(data.aws_ssm_parameter.ami.value)
instance_type = var.aws_instance_type[terraform.workspace]
subnet_id = module.vpc.public_subnets[(count.index % var.vpc_subnet_count[terraform.workspace])]
vpc_security_group_ids = [aws_security_group.nginx_sg.id]
iam_instance_profile = module.web_app_s3.instance_profile_object.name
depends_on = [module.web_app_s3]
user_data = templatefile("${path.module}/startup_script.tpl", {
s3_bucket_name = module.web_app_s3.bucket_object.id
})
tags = merge(local.common_tags, {
Name = "${local.name_prefix}-instance${count.index}"
})
}