-
Notifications
You must be signed in to change notification settings - Fork 171
/
main.tf
47 lines (40 loc) · 961 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
# Terraform state will be stored in S3
terraform {
backend "s3" {
bucket = "terraform-bucket-alex"
key = "terraform.tfstate"
region = "us-east-1"
}
}
# Use AWS Terraform provider
provider "aws" {
region = "us-east-1"
}
# Create EC2 instance
resource "aws_instance" "default" {
ami = "${var.ami}"
count = "${var.count}"
key_name = "${var.key_name}"
vpc_security_group_ids = ["${aws_security_group.default.id}"]
source_dest_check = false
instance_type = "${var.instance_type}"
tags {
Name = "terraform-default"
}
}
# Create Security Group for EC2
resource "aws_security_group" "default" {
name = "terraform-default-sg"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}