-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
56 lines (49 loc) · 1.56 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
##################################################################################
# PROVIDERS
##################################################################################
provider "aws" {
region = var.region
}
##################################################################################
# DATA
##################################################################################
data "aws_ami" "amazon-linux-2" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
# import cloudformation output
data "aws_cloudformation_export" "vpc_id" {
name = "VpcID"
}
data "aws_cloudformation_export" "PublicSubnetA" {
name = "PublicSubnetA"
}
data "aws_cloudformation_export" "PublicSubnetB" {
name = "PublicSubnetB"
}
data "aws_cloudformation_export" "PublicSubnetC" {
name = "PublicSubnetC"
}
data "aws_cloudformation_export" "PrivateSubnetA" {
name = "PrivateSubnetA"
}
data "aws_cloudformation_export" "PrivateSubnetB" {
name = "PrivateSubnetB"
}
data "aws_cloudformation_export" "PrivateSubnetC" {
name = "PrivateSubnetC"
}
##################################################################################
# RESOURCES
##################################################################################
resource "aws_instance" "Bastion" {
ami = data.aws_ami.amazon-linux-2.id
instance_type = "t2.micro"
key_name = var.key_name
subnet_id = data.aws_cloudformation_export.PublicSubnetA.value
vpc_security_group_ids = [aws_security_group.bastionsg.id]
}