This repository was archived by the owner on Jul 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +114
-1
lines changed Expand file tree Collapse file tree 4 files changed +114
-1
lines changed Original file line number Diff line number Diff line change 1+ variable "region" {
2+ description = " The region to put resources in"
3+ default = " us-east-1"
4+ }
5+
6+ variable "az" {
7+ description = " The availability zone to put resources in"
8+ default = " us-east-1c"
9+ }
10+
11+ variable "key_name" {
12+ description = " The keypair used to ssh into the asg intances"
13+ default = " shida-east-1"
14+ }
15+
16+ provider "aws" {
17+ region = var. region
18+ }
19+
20+ module "vpc" {
21+ source = " ../../modules/vpc-scenario-1"
22+ azs = [var . az ]
23+ name_prefix = " bastion-test"
24+ cidr = " 192.168.0.0/16"
25+ public_subnet_cidrs = [" 192.168.0.0/16" ]
26+ region = var. region
27+ map_on_launch = false
28+ }
29+
30+ module "bastion" {
31+ source = " ../../modules/bastion"
32+ region = var. region
33+ key_name = var. key_name
34+ public_subnet_id = module. vpc . public_subnet_ids [0 ]
35+ identifier = " test"
36+ vpc_id = module. vpc . vpc_id
37+ }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ module "snasg" {
3737 key_name = var. key_name
3838 subnet_id = module. vpc . public_subnet_ids [0 ]
3939 security_group_ids = [aws_security_group . eiptest . id ]
40- assign_eip = true
40+ assign_eip = false # true case is tested in bastion-test example
4141}
4242
4343module "ubuntu-ami" {
Original file line number Diff line number Diff line change 1+ # SSH Bastion
2+
3+ This is a module to provide a bastion to access the inside of a VPC from Internet.
Original file line number Diff line number Diff line change 1+ variable "vpc_id" {
2+ type = string
3+ description = " ID of the VPC."
4+ }
5+
6+ variable "identifier" {
7+ type = string
8+ description = " Identifier of related resources."
9+ }
10+
11+ variable "region" {
12+ type = string
13+ description = " AWS region for this bastion to be in."
14+ }
15+
16+ variable "key_name" {
17+ type = string
18+ description = " SSH key pair name for the bastion."
19+ }
20+
21+ variable "public_subnet_id" {
22+ type = string
23+ description = " The subnet for the bastion. The subnet must be able to access Internet."
24+ }
25+
26+ variable "instance_type" {
27+ type = string
28+ default = " t2.nano"
29+ description = " Bastion instance type."
30+ }
31+
32+ variable "egress_cidrs" {
33+ type = list (string )
34+ default = [" 0.0.0.0/0" ]
35+ description = " Egress subnets that bastion can access."
36+ }
37+
38+ module "instance" {
39+ source = " ../single-node-asg"
40+ name_prefix = var. identifier
41+ name_suffix = " bastion"
42+ ami = module. ubuntu-ami . id
43+ instance_type = var. instance_type
44+ region = var. region
45+ key_name = var. key_name
46+ subnet_id = var. public_subnet_id
47+ security_group_ids = [aws_security_group . bastion . id ]
48+ assign_eip = true
49+ }
50+
51+ resource "aws_security_group" "bastion" {
52+ name = " ${ var . identifier } -bastion"
53+ vpc_id = var. vpc_id
54+
55+ ingress {
56+ from_port = 22
57+ to_port = 22
58+ protocol = " tcp"
59+ cidr_blocks = [" 0.0.0.0/0" ]
60+ }
61+
62+ egress {
63+ from_port = 0
64+ to_port = 0
65+ protocol = " -1"
66+ cidr_blocks = var. egress_cidrs
67+ }
68+ }
69+
70+ module "ubuntu-ami" {
71+ source = " ../../modules/ami-ubuntu"
72+ release = " 18.04"
73+ }
You can’t perform that action at this time.
0 commit comments