-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
90 lines (77 loc) · 2.13 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
variable "region" {}
variable "env" {}
variable "account_id" {}
variable "key_path" {}
variable "key_name" {}
variable "ec2_bastion_instance_type" {}
variable "ec2_bastion_user" {}
variable "state_bucket" {}
variable "kms_key_id" {}
variable "ip_allow1" {}
variable "ip_allow2" {}
variable "ip_allow3" {}
variable "ip_allow4" {}
variable "ip_allow5" {}
terraform {
required_version = ">= 0.9.9"
backend "s3" {
encrypt = true
acl = "private"
}
}
provider "aws" {
region = "${var.region}"
profile = "${var.env}"
allowed_account_ids = ["${var.account_id}"]
}
data "terraform_remote_state" "vpc" {
backend = "s3"
config {
region = "${var.region}"
bucket = "${var.state_bucket}"
key = "terraform/vpc/${var.env}.tfstate"
profile = "${var.env}"
encrypt = 1
acl = "private"
kms_key_id = "${var.kms_key_id}"
}
}
module "bastion" {
source = "modules/bastion"
env = "${var.env}"
region = "${var.region}"
instance_type = "${var.ec2_bastion_instance_type}"
bastion_key_name = "${var.key_name}"
bastion_key_path = "${var.key_path}"
vpc_id = "${data.terraform_remote_state.vpc.vpc_id}"
vpc_cidr = "${data.terraform_remote_state.vpc.vpc_cidr}"
subnet_ids = "${data.terraform_remote_state.vpc.public_subnet_ids}"
shell_username = "${var.ec2_bastion_user}"
ip_allow1 = "${var.ip_allow1}"
ip_allow2 = "${var.ip_allow2}"
ip_allow3 = "${var.ip_allow3}"
ip_allow4 = "${var.ip_allow4}"
ip_allow5 = "${var.ip_allow5}"
state_bucket = "${var.state_bucket}"
}
output "environment" {
value = "${var.env}"
}
output "bastion_public_ip" {
value = "${module.bastion.public_ip}"
}
output "bastion_private_ip" {
value = "${module.bastion.private_ip}"
}
output "bastion_user" {
value = "${var.ec2_bastion_user}"
}
output "bastion_ami_image_id" {
value = "${module.bastion.ami_image_id}"
}
output "bastion_ami_creation_date" {
value = "${module.bastion.ami_creation_date}"
}
output "bastion_ami_name" {
value = "${module.bastion.ami_name}"
}