-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathmain.tf
54 lines (45 loc) · 973 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
terraform {
required_version = ">= 0.12.0"
}
provider "aws" {
region = "us-west-2"
}
variable "vpc_name" {
description = "name of the VPC"
default = "tf-0.12-fce-example"
}
resource "aws_vpc" "my_vpc" {
cidr_block = "172.16.0.0/16"
tags = {
Name = var.vpc_name
}
}
resource "aws_subnet" "my_subnet" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "172.16.10.0/24"
availability_zone = "us-west-2a"
tags = {
Name = "tf-0.12-fce-example"
}
}
resource "aws_network_interface" "foo" {
subnet_id = aws_subnet.my_subnet.id
private_ips = ["172.16.10.100"]
tags = {
Name = "tf-0.12-fce-primary_network_interface"
}
}
resource "aws_instance" "foo" {
ami = "ami-22b9a343" # us-west-2
instance_type = "t2.micro"
tags = {
Name = "tf-0.12-fce-ec2-instance"
}
network_interface {
network_interface_id = aws_network_interface.foo.id
device_index = 0
}
}
output "private_dns" {
value = aws_instance.foo.private_dns
}