Skip to content

Commit

Permalink
add custom subnet example
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaucier-sf committed May 19, 2023
1 parent 16882bc commit 67034ad
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 54 deletions.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions example/README.md → examples/custom-subnets/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Overview
The default behavior of the referenced module is to create the public and private subnets dynamically via VPC CIDR and the Availability Zone count.
This example shows how to pass in custom subnet configuration, overriding the default behavior of the module.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

Expand All @@ -14,7 +18,7 @@ No providers.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_network"></a> [network](#module\_network) | ../. | n/a |
| <a name="module_network"></a> [network](#module\_network) | ../../. | n/a |
| <a name="module_tags"></a> [tags](#module\_tags) | git::https://github.com/sourcefuse/terraform-aws-refarch-tags.git | 1.1.0 |

## Resources
Expand All @@ -28,9 +32,8 @@ No resources.
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | List of availability zones to deploy resources in. | `list(string)` | <pre>[<br> "us-east-1a",<br> "us-east-1b"<br>]</pre> | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Name of the environment, i.e. dev, stage, prod | `string` | `"dev"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace of the project, i.e. refarch | `string` | `"example"` | no |
| <a name="input_profile"></a> [profile](#input\_profile) | AWS profile | `string` | `"default"` | no |
| <a name="input_region"></a> [region](#input\_region) | AWS Region | `string` | `"us-east-1"` | no |
| <a name="input_vpc_ipv4_primary_cidr_block"></a> [vpc\_ipv4\_primary\_cidr\_block](#input\_vpc\_ipv4\_primary\_cidr\_block) | IPv4 CIDR block for the VPC to use. | `string` | `"10.9.0.0/16"` | no |
| <a name="input_vpc_ipv4_primary_cidr_block"></a> [vpc\_ipv4\_primary\_cidr\_block](#input\_vpc\_ipv4\_primary\_cidr\_block) | IPv4 CIDR block for the VPC to use. | `string` | `"10.0.0.0/16"` | no |

## Outputs

Expand Down
35 changes: 31 additions & 4 deletions example/main.tf → examples/custom-subnets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ terraform {
}

provider "aws" {
region = var.region
profile = var.profile
region = var.region
}

module "tags" {
Expand All @@ -32,14 +31,41 @@ module "tags" {
## network
################################################################
module "network" {
source = "../."
source = "../../."

namespace = var.namespace
environment = var.environment
availability_zones = var.availability_zones
vpc_ipv4_primary_cidr_block = var.vpc_ipv4_primary_cidr_block
client_vpn_enabled = true
tags = module.tags.tags

## custom subnets
custom_subnets_enabled = true
custom_private_subnets = [
{
name = "${var.namespace}-${var.environment}-private-${var.region}a"
availability_zone = "${var.region}a"
cidr_block = "10.0.0.0/19"
},
{
name = "${var.namespace}-${var.environment}-private-${var.region}b"
availability_zone = "${var.region}b"
cidr_block = "10.0.64.0/19"
}
]
custom_public_subnets = [
{
name = "${var.namespace}-${var.environment}-public-${var.region}a"
availability_zone = "${var.region}a"
cidr_block = "10.0.96.0/20"
},
{
name = "${var.namespace}-${var.environment}-public-${var.region}b"
availability_zone = "${var.region}b"
cidr_block = "10.0.112.0/20"
}
]

client_vpn_authorization_rules = [
{
target_network_cidr = var.vpc_ipv4_primary_cidr_block
Expand All @@ -48,4 +74,5 @@ module "network" {
}
]

tags = module.tags.tags
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ variable "namespace" {
default = "example"
}

variable "profile" {
type = string
description = "AWS profile"
default = "default"
}

################################################################
## network
################################################################
Expand All @@ -40,5 +34,5 @@ variable "availability_zones" {
variable "vpc_ipv4_primary_cidr_block" {
type = string
description = "IPv4 CIDR block for the VPC to use."
default = "10.9.0.0/16"
default = "10.0.0.0/16"
}

0 comments on commit 67034ad

Please sign in to comment.