-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
56 lines (46 loc) · 1020 Bytes
/
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
terraform {
required_providers {
aws = {
version = "~> 2.70"
source = "hashicorp/aws"
}
}
}
provider "aws" {
profile = "default"
region = var.region
access_key = var.access_key
secret_key = var.secret_key
}
resource "aws_instance" "web" {
ami = lookup(var.amis, var.region)
subnet_id = var.subnet
security_groups = var.securityGroups
key_name = var.keyName
instance_type = var.instanceType
ebs_block_device {
device_name = "/dev/xvdb"
volume_type = "gp2"
volume_size = var.DiskSize
}
tags = {
Name = var.instanceName
}
provisioner "file" {
source = "files/homer_installer.sh"
destination = "/tmp/homer_installer.sh"
}
provisioner "remote-exec" {
inline = [
"chmod -x /tmp/homer_installer.sh",
"sudo /tmp/homer_installer.sh",
]
}
connection {
type = "ssh"
user = "admin"
password = ""
private_key = file(var.keyPath)
host = self.public_ip
}
}