-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from joshuamkite/feature/mantenance
Feature/maintenance
- Loading branch information
Showing
10 changed files
with
144 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Contributing to this module | ||
|
||
I am always happy to consider contributions to the code offered here. Please feel free to raise issues or pull requests. All proposed code changes must be tested before submission! | ||
|
||
Thanks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This example shows a complete setup for a new `bastion` service with all needed parts: | ||
|
||
* a new VPC, | ||
* private subnet(s) inside the VPC, | ||
* an internet gateway and route tables. | ||
|
||
Before applying, create a key pair in the requested region named 'bastion-demo'. | ||
|
||
Because of Terraform limitations (v0.11.x) it can't compute count/length of new resources so it can't generate the `aws_subnets` data block in [`security_group.tf`](../../security_group.tf). A hack is to first create the VPC and then the rest of the bastion host: comment out the `ssh-bastion-service` module, `terraform apply`, uncomment and `apply` again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
provider "aws" { | ||
region = "${var.aws-region}" | ||
} | ||
|
||
data "aws_availability_zones" "available" {} | ||
|
||
resource "aws_vpc" "bastion" { | ||
cidr_block = "${var.cidr-start}.0.0/16" | ||
enable_dns_hostnames = true | ||
|
||
tags = { | ||
Name = "bastion-${var.environment-name}-vpc" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "bastion" { | ||
count = 1 | ||
|
||
availability_zone = "${data.aws_availability_zones.available.names[count.index]}" | ||
cidr_block = "${var.cidr-start}.${count.index}.0/24" | ||
vpc_id = "${aws_vpc.bastion.id}" | ||
|
||
tags = { | ||
Name = "bastion-${var.environment-name}-subnet-${count.index}" | ||
} | ||
} | ||
|
||
resource "aws_internet_gateway" "bastion" { | ||
vpc_id = "${aws_vpc.bastion.id}" | ||
|
||
tags = { | ||
Name = "bastion-${var.environment-name}-ig" | ||
} | ||
} | ||
|
||
resource "aws_route_table" "bastion" { | ||
vpc_id = "${aws_vpc.bastion.id}" | ||
|
||
tags = { | ||
Name = "bastion-${var.environment-name}-rt" | ||
} | ||
} | ||
|
||
resource "aws_route" "bastion-ipv4-out" { | ||
route_table_id = "${aws_route_table.bastion.id}" | ||
destination_cidr_block = "0.0.0.0/0" | ||
gateway_id = "${aws_internet_gateway.bastion.id}" | ||
} | ||
|
||
resource "aws_route_table_association" "bastion" { | ||
count = 1 | ||
|
||
subnet_id = "${aws_subnet.bastion.*.id[count.index]}" | ||
route_table_id = "${aws_route_table.bastion.id}" | ||
} | ||
|
||
variable "everyone-cidr" { | ||
default = "0.0.0.0/0" | ||
description = "Everyone" | ||
} | ||
|
||
# To create the bastion service, subnets need to already exist | ||
# This is currently a limitation of Terraform: https://github.com/hashicorp/terraform/issues/12570 | ||
# Comment out the bastion service, apply, uncomment and apply again | ||
module "ssh-bastion-service" { | ||
source = "joshuamkite/ssh-bastion-service/aws" | ||
version = "4.5" | ||
|
||
aws_region = "${var.aws-region}" | ||
aws_profile = "${var.aws-profile}" | ||
|
||
environment_name = "${var.environment-name}" | ||
vpc = "${aws_vpc.bastion.id}" | ||
|
||
subnets_asg = ["${aws_subnet.bastion.*.id}"] | ||
subnets_lb = ["${aws_subnet.bastion.*.id}"] | ||
|
||
cidr_blocks_whitelist_service = ["${var.everyone-cidr}"] | ||
|
||
public_ip = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
variable "aws-profile" { | ||
default = "" | ||
} | ||
|
||
variable "aws-region" { | ||
default = "eu-west-1" | ||
description = "Default AWS region" | ||
} | ||
|
||
variable "cidr-start" { | ||
default = "10.50" | ||
description = "Default CIDR block" | ||
} | ||
|
||
variable "environment-name" { | ||
default = "demo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters