forked from MithunTechnologiesDevOps/Terraform_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstances.tf
30 lines (26 loc) · 897 Bytes
/
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
# Demo Ubuntu Server(t2.medium)
resource "aws_instance" "Demo_Server" {
count = 1
ami = var.ubuntuami
instance_type = "t2.medium"
vpc_security_group_ids = [aws_security_group.demo_sg.id]
subnet_id = element(aws_subnet.subnets.*.id, count.index)
key_name = var.key_name
tags = {
Name = "UbuntuServer"
Type = "Docker"
}
}
# 2 Instance Of Redhat Servers(t2.micro)
resource "aws_instance" "redhat_servers" {
count = 2
ami = var.redhatami
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.demo_sg.id]
subnet_id = element(aws_subnet.subnets.*.id, count.index)
key_name = var.key_name
user_data = file("init_script.sh")
tags = {
Name = "Redhat_Server_${count.index + 1}"
}
}