-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
73 lines (60 loc) · 2.3 KB
/
main.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
resource "aws_key_pair" "deployer" {
key_name = "deployer-key"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtpzM//FD9TWElDBp+LoJA4y9wnwEMgjZlBHAifpaVoI75iBrwWJooNLKITtkhgv5lzjiCHoC5k0i3p77VvLywNhSu8XAHTmJ0VlNH6LpHHy3nlDsEpye+MOTdcCAPOs/deSEqAOlHH726GD8UI0/TMupziu3TyVcO9Yf465L4u1Ynoa7XdLB8A/hNVcJAhcOQ/gEaHfqZ5jwAbbpYWF/na7oHpg+FgBcZEjO+AD3qDsihaf3CFbPEsvbpeKxIyY2QZZhXl0o81usGjJhd7ZxGSHodwjoIaCf5wG0Zwir4NqRTTZrrW0WqmN7c0Epfq49O/L4KfNYI2M+6SYAn+jUZX79wojkNQwwLhQFt9PtwEP834d43nbhSXu9kAwQTHUBwiSFm/BU9Ai0UF0mfvJ1frYb6vKCCkUjdf+3veAvsfkzPONIvEytcxdyUquXhmWtBgK6D+buuieiq76AKJUCEKjHr8kMKGaXkhifl8iByGh0un7EQF0wAUaEvxulqq9MUxGkjjrrp+W1EoPaxcTnzuYiszDMrcIEDNT/Wji0IwNjtbWzuy8hr5az7XTcXspnpofuMhF/xsjI2rmkNPmPJKNzXWY+gD+mEd4d3u6b+gScLjQRld4YGIDYHhMBqebi/qtzq2x6KcvtSK/k6GL5Ge8GG9YY/2y2qjTfpfjnxIw== [email protected]"
}
resource "aws_instance" "jamal_server" {
for_each = {
nano = "t2.nano"
micro = "t2.micro"
small = "t2.nano"
}
ami = "ami-09fd16644beea3565"
instance_type = each.value
key_name = "jamal-test-keypair"
vpc_security_group_ids = [aws_security_group.sg_jamal_server.id]
user_data = data.template_file.user_data.rendered
tags = {
Name = join("-", ["jamal-server", each.key])
}
}
resource "aws_security_group" "sg_jamal_server" {
name = "sg_jamal_server"
description = "Allow port 80 and ssh from SP"
vpc_id = data.aws_vpc.main.id
ingress {
description = "TLS from VPC"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = []
}
ingress {
description = "SSH"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["188.39.149.98/32"]
ipv6_cidr_blocks = []
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "sg_jamal_server"
}
}
resource "aws_s3_bucket" "depends_on_bucket" {
bucket = "jamal-depends-on-bucket-s3"
depends_on = [aws_instance.jamal_server]
}
data "aws_vpc" "main" {
id = "vpc-05e90d7c"
}
data "template_file" "user_data" {
template = file("./userdata.yml")
}