mirror of
https://github.com/ghndrx/terraform.git
synced 2026-02-13 00:05:06 +00:00
seperate east/west
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
output "vpc_id" {
|
||||
value = aws_vpc.vpc_us.id
|
||||
}
|
||||
@@ -13,4 +13,4 @@ output "us_east_subnet_2_id" {
|
||||
output "us_east_subnet_3_id" {
|
||||
description = "The ID of the third US East subnet"
|
||||
value = aws_subnet.us_east_subnet_3.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,30 @@
|
||||
provider "aws" {
|
||||
region = var.region
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
resource "aws_subnet" "us_east_subnet_1" {
|
||||
vpc_id = var.vpc_id
|
||||
vpc_id = var.vpc_id_east_1
|
||||
cidr_block = var.us_east_subnet_1_cidr_block
|
||||
availability_zone = var.us_east_subnet_1_az
|
||||
tags = {
|
||||
Name = "${var.region}_${var.us_east_subnet_1_az}_subnet"
|
||||
}
|
||||
|
||||
depends_on = [var.vpc_id]
|
||||
}
|
||||
|
||||
resource "aws_subnet" "us_east_subnet_2" {
|
||||
vpc_id = var.vpc_id
|
||||
vpc_id = var.vpc_id_east_1
|
||||
cidr_block = var.us_east_subnet_2_cidr_block
|
||||
availability_zone = var.us_east_subnet_2_az
|
||||
tags = {
|
||||
Name = "${var.region}_${var.us_east_subnet_2_az}_subnet"
|
||||
}
|
||||
|
||||
depends_on = [var.vpc_id]
|
||||
}
|
||||
|
||||
resource "aws_subnet" "us_east_subnet_3" {
|
||||
vpc_id = var.vpc_id
|
||||
vpc_id = var.vpc_id_east_1
|
||||
cidr_block = var.us_east_subnet_3_cidr_block
|
||||
availability_zone = var.us_east_subnet_3_az
|
||||
tags = {
|
||||
Name = "${var.region}_${var.us_east_subnet_3_az}_subnet"
|
||||
}
|
||||
|
||||
depends_on = [var.vpc_id]
|
||||
}
|
||||
@@ -16,18 +16,19 @@ variable "region" {
|
||||
|
||||
|
||||
variable "us_east_subnet_1_cidr_block" {
|
||||
default = "10.0.4.0/24"
|
||||
default = "10.1.4.0/24"
|
||||
}
|
||||
|
||||
variable "us_east_subnet_2_cidr_block" {
|
||||
default = "10.0.5.0/24"
|
||||
default = "10.1.5.0/24"
|
||||
}
|
||||
|
||||
variable "us_east_subnet_3_cidr_block" {
|
||||
default = "10.0.6.0/24"
|
||||
default = "10.1.6.0/24"
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
variable "vpc_id_east_1" {
|
||||
description = "The ID of the VPC"
|
||||
type = string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
provider "aws" {
|
||||
region = "us-west-2"
|
||||
}
|
||||
|
||||
resource "aws_subnet" "us_west_subnet_1" {
|
||||
vpc_id = var.vpc_id
|
||||
vpc_id = var.vpc_id_west_2
|
||||
cidr_block = var.us_west_subnet_1_cidr_block
|
||||
availability_zone = var.us_west_subnet_1_az
|
||||
tags = {
|
||||
Name = "${var.region}_${var.us_west_subnet_1_az}_subnet"
|
||||
}
|
||||
depends_on = [var.vpc_id_west_2]
|
||||
}
|
||||
|
||||
resource "aws_subnet" "us_west_subnet_2" {
|
||||
vpc_id = var.vpc_id
|
||||
vpc_id = var.vpc_id_west_2
|
||||
cidr_block = var.us_west_subnet_2_cidr_block
|
||||
availability_zone = var.us_west_subnet_2_az
|
||||
tags = {
|
||||
Name = "${var.region}_${var.us_west_subnet_2_az}_subnet"
|
||||
}
|
||||
depends_on = [var.vpc_id_west_2]
|
||||
}
|
||||
|
||||
resource "aws_subnet" "us_west_subnet_3" {
|
||||
vpc_id = var.vpc_id
|
||||
vpc_id = var.vpc_id_west_2
|
||||
cidr_block = var.us_west_subnet_3_cidr_block
|
||||
availability_zone = var.us_west_subnet_3_az
|
||||
tags = {
|
||||
Name = "${var.region}_${var.us_west_subnet_3_az}_subnet"
|
||||
}
|
||||
depends_on = [var.vpc_id_west_2]
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ variable "region" {
|
||||
default = "us-west-2"
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
|
||||
variable "vpc_id_west_2" {
|
||||
description = "The ID of the VPC"
|
||||
type = string
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
vpc_cidr_block = "10.0.0.0/16"
|
||||
|
||||
us_east_subnet_1_id = ""
|
||||
us_east_subnet_2_id = ""
|
||||
us_east_subnet_3_id = ""
|
||||
us_west_subnet_1_id = ""
|
||||
us_west_subnet_2_id = ""
|
||||
us_west_subnet_3_id = ""
|
||||
8
aws/aws_simple/modules/vpc/vpc-east/outputs.tf
Normal file
8
aws/aws_simple/modules/vpc/vpc-east/outputs.tf
Normal file
@@ -0,0 +1,8 @@
|
||||
output "vpc_id_east_1" {
|
||||
value = aws_vpc.vpc_us_east_1.id
|
||||
}
|
||||
|
||||
output "vpc_cidr_block" {
|
||||
description = "The CIDR block of the VPC"
|
||||
value = aws_vpc.vpc_us_east_1.cidr_block
|
||||
}
|
||||
2
aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars
Normal file
2
aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars
Normal file
@@ -0,0 +1,2 @@
|
||||
vpc_cidr_block = "10.1.0.0/16"
|
||||
region = "us-east-1"
|
||||
23
aws/aws_simple/modules/vpc/vpc-east/variables.tf
Normal file
23
aws/aws_simple/modules/vpc/vpc-east/variables.tf
Normal file
@@ -0,0 +1,23 @@
|
||||
variable "vpc_cidr_block" {
|
||||
default = "10.1.0.0/16"
|
||||
}
|
||||
|
||||
variable "us_east_subnet_1_id" {
|
||||
description = "The ID of the first US East subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "us_east_subnet_2_id" {
|
||||
description = "The ID of the second US East subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "us_east_subnet_3_id" {
|
||||
description = "The ID of the third US East subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "The region to deploy to"
|
||||
type = string
|
||||
}
|
||||
42
aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf
Normal file
42
aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf
Normal file
@@ -0,0 +1,42 @@
|
||||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
resource "aws_vpc" "vpc_us_east_1" {
|
||||
cidr_block = var.vpc_cidr_block
|
||||
tags = {
|
||||
Name = "vpc_us_east_1"
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
|
||||
# Create aws internet gateway
|
||||
resource "aws_internet_gateway" "my_igw_east_1" {
|
||||
vpc_id = aws_vpc.vpc_us_east_1.id
|
||||
}
|
||||
|
||||
# Create route table entries for the east subnets
|
||||
resource "aws_route_table" "us_east_route_table" {
|
||||
vpc_id = aws_vpc.vpc_us_east_1.id
|
||||
}
|
||||
|
||||
resource "aws_route" "us_east_route" {
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.my_igw_east_1.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_east_subnet_1_association" {
|
||||
subnet_id = var.us_east_subnet_1_id
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_east_subnet_2_association" {
|
||||
subnet_id = var.us_east_subnet_2_id
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_east_subnet_3_association" {
|
||||
subnet_id = var.us_east_subnet_3_id
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
}
|
||||
8
aws/aws_simple/modules/vpc/vpc-west/outputs.tf
Normal file
8
aws/aws_simple/modules/vpc/vpc-west/outputs.tf
Normal file
@@ -0,0 +1,8 @@
|
||||
output "vpc_id_west_2" {
|
||||
value = aws_vpc.vpc_us_west_2.id
|
||||
}
|
||||
|
||||
output "vpc_cidr_block" {
|
||||
description = "The CIDR block of the VPC"
|
||||
value = aws_vpc.vpc_us_west_2.cidr_block
|
||||
}
|
||||
2
aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars
Normal file
2
aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars
Normal file
@@ -0,0 +1,2 @@
|
||||
vpc_cidr_block = "10.0.0.0/16"
|
||||
region = "us-west-2"
|
||||
@@ -2,21 +2,6 @@ variable "vpc_cidr_block" {
|
||||
default = "10.0.0.0/16"
|
||||
}
|
||||
|
||||
variable "us_east_subnet_1_id" {
|
||||
description = "The ID of the first US East subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "us_east_subnet_2_id" {
|
||||
description = "The ID of the second US East subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "us_east_subnet_3_id" {
|
||||
description = "The ID of the third US East subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "us_west_subnet_1_id" {
|
||||
description = "The ID of the first US West subnet"
|
||||
type = string
|
||||
@@ -30,4 +15,9 @@ variable "us_west_subnet_2_id" {
|
||||
variable "us_west_subnet_3_id" {
|
||||
description = "The ID of the third US West subnet"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "The region to deploy to"
|
||||
type = string
|
||||
}
|
||||
46
aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf
Normal file
46
aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf
Normal file
@@ -0,0 +1,46 @@
|
||||
provider "aws" {
|
||||
region = var.region
|
||||
}
|
||||
|
||||
#Create aws vpc
|
||||
resource "aws_vpc" "vpc_us_west_2" {
|
||||
cidr_block = var.vpc_cidr_block
|
||||
tags = {
|
||||
Name = "vpc_us_west_1"
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
|
||||
# Create aws internet gateway
|
||||
resource "aws_internet_gateway" "my_igw_west_2" {
|
||||
vpc_id = aws_vpc.vpc_us_west_2.id
|
||||
}
|
||||
|
||||
# Create route table entries for the west subnets
|
||||
resource "aws_route_table" "us_west_route_table" {
|
||||
vpc_id = aws_vpc.vpc_us_west_2.id
|
||||
}
|
||||
|
||||
resource "aws_route" "us_west_route" {
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.my_igw_west_2.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_west_subnet_1_association" {
|
||||
subnet_id = var.us_west_subnet_1_id
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_west_subnet_2_association" {
|
||||
subnet_id = var.us_west_subnet_2_id
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_west_subnet_3_association" {
|
||||
subnet_id = var.us_west_subnet_3_id
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#Create aws vpc
|
||||
resource "aws_vpc" "vpc_us" {
|
||||
cidr_block = var.vpc_cidr_block
|
||||
tags = {
|
||||
Name = "vpc_us"
|
||||
Environment = "production"
|
||||
}
|
||||
}
|
||||
# Create aws internet gateway
|
||||
resource "aws_internet_gateway" "my_igw" {
|
||||
vpc_id = aws_vpc.vpc_us.id
|
||||
}
|
||||
|
||||
# Create route table entries for the west subnets
|
||||
resource "aws_route_table" "us_west_route_table" {
|
||||
vpc_id = aws_vpc.vpc_us.id
|
||||
}
|
||||
|
||||
# Create route table entries for the east subnets
|
||||
resource "aws_route_table" "us_east_route_table" {
|
||||
vpc_id = aws_vpc.vpc_us.id
|
||||
}
|
||||
|
||||
resource "aws_route" "us_west_route" {
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.my_igw.id
|
||||
}
|
||||
|
||||
resource "aws_route" "us_east_route" {
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.my_igw.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_west_subnet_1_association" {
|
||||
subnet_id = var.us_west_subnet_1_id
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_west_subnet_2_association" {
|
||||
subnet_id = var.us_west_subnet_2_id
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_west_subnet_3_association" {
|
||||
subnet_id = var.us_west_subnet_3_id
|
||||
route_table_id = aws_route_table.us_west_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_east_subnet_1_association" {
|
||||
subnet_id = var.us_east_subnet_1_id
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_east_subnet_2_association" {
|
||||
subnet_id = var.us_east_subnet_2_id
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "us_east_subnet_3_association" {
|
||||
subnet_id = var.us_east_subnet_3_id
|
||||
route_table_id = aws_route_table.us_east_route_table.id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user