-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.port-variable.tf.bak
56 lines (46 loc) · 1.3 KB
/
main.port-variable.tf.bak
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
provider "aws" {
region = "us-east-1"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web_server" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.instance.id}"]
user_data = <<-EOF
#!/bin/bash
echo "Hello, world" > index.html
nohup busybox httpd -f -p "${var.server_port}" &
EOF
tags {
Name = "Web-Server"
}
}
resource "aws_security_group" "instance" {
name = "terraform-web-server-security-group"
ingress {
from_port = "${var.server_port}"
to_port = "${var.server_port}"
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
output "public_ip" {
value = "${aws_instance.web_server.public_ip}"
}
output "public_port" {
value = "${var.server_port}"
}
#This line add an elastic IP-Address to one instance
#This IP-Address is public, and should be associated to one instance.
# resource "aws_eip" "ip" {
# instance = "${aws_instance.terraform_example.id}"
# }