Skip to content

Commit

Permalink
Add the wonderful examples from matthiasr's PR located at terraform-a…
Browse files Browse the repository at this point in the history
…ws-modules#162 all credit goes to them for this wonderful example
  • Loading branch information
JohnnyC08 committed Aug 30, 2018
1 parent f606f49 commit 5498428
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/secondary-cidr-blocks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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_secondary_cidr_blocks | Secondary CIDR blocks |
| vpc_id | VPC |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
25 changes: 25 additions & 0 deletions examples/secondary-cidr-blocks/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
provider "aws" {
region = "eu-west-1"
}
module "vpc" {
source = "../../"
name = "secondary-cidr-blocks-example"
cidr = "10.0.0.0/16"
secondary_cidrs = ["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"
}
}
29 changes: 29 additions & 0 deletions examples/secondary-cidr-blocks/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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 = "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}"]
}

0 comments on commit 5498428

Please sign in to comment.