-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add secondary CIDR block support (#163)
* Add secondary CIDR block support using a local variable to derive the vpc id to ensure the CIDR block operations are applied before the CIDR operations * Add secondary cidr block outputs to module output * Add the wonderful examples from matthiasr's PR located at #162 all credit goes to them for this wonderful example * From copy and paste accidentally used variable name that differed from these variables * Resolve typo in secondary_cidr_blocks * Fixed README formatting * Followups for #161 * Added local.vpc_id with description
- Loading branch information
1 parent
553d76a
commit d722430
Showing
7 changed files
with
139 additions
and
18 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
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,32 @@ | ||
# Simple VPC with secondary CIDR blocks | ||
|
||
Configuration in this directory creates set of VPC resources across multiple CIDR blocks. | ||
|
||
There is a public and private subnet created per availability zone in addition to single NAT Gateway shared between all 3 availability zones. | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
``` | ||
|
||
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| nat_public_ips | NAT gateways | | ||
| private_subnets | Subnets | | ||
| public_subnets | List of IDs of public subnets | | ||
| vpc_cidr_block | CIDR blocks | | ||
| vpc_id | VPC | | ||
| vpc_secondary_cidr_blocks | List of secondary CIDR blocks of the VPC | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
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,33 @@ | ||
provider "aws" { | ||
region = "eu-west-1" | ||
} | ||
|
||
module "vpc" { | ||
source = "../../" | ||
|
||
name = "secondary-cidr-blocks-example" | ||
|
||
cidr = "10.0.0.0/16" | ||
secondary_cidr_blocks = ["10.1.0.0/16", "10.2.0.0/16"] | ||
|
||
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"] | ||
private_subnets = ["10.0.1.0/24", "10.1.2.0/24", "10.2.3.0/24"] | ||
public_subnets = ["10.0.101.0/24", "10.1.102.0/24", "10.2.103.0/24"] | ||
|
||
assign_generated_ipv6_cidr_block = true | ||
enable_nat_gateway = true | ||
single_nat_gateway = true | ||
|
||
public_subnet_tags = { | ||
Name = "overridden-name-public" | ||
} | ||
|
||
tags = { | ||
Owner = "user" | ||
Environment = "dev" | ||
} | ||
|
||
vpc_tags = { | ||
Name = "vpc-name" | ||
} | ||
} |
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,33 @@ | ||
# VPC | ||
output "vpc_id" { | ||
description = "The ID of the VPC" | ||
value = "${module.vpc.vpc_id}" | ||
} | ||
|
||
# CIDR blocks | ||
output "vpc_cidr_block" { | ||
description = "The CIDR block of the VPC" | ||
value = ["${module.vpc.vpc_cidr_block}"] | ||
} | ||
|
||
output "vpc_secondary_cidr_blocks" { | ||
description = "List of secondary CIDR blocks of the VPC" | ||
value = ["${module.vpc.vpc_secondary_cidr_blocks}"] | ||
} | ||
|
||
# Subnets | ||
output "private_subnets" { | ||
description = "List of IDs of private subnets" | ||
value = ["${module.vpc.private_subnets}"] | ||
} | ||
|
||
output "public_subnets" { | ||
description = "List of IDs of public subnets" | ||
value = ["${module.vpc.public_subnets}"] | ||
} | ||
|
||
# NAT gateways | ||
output "nat_public_ips" { | ||
description = "List of public Elastic IPs created for AWS NAT Gateway" | ||
value = ["${module.vpc.nat_public_ips}"] | ||
} |
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