forked from terraform-aws-modules/terraform-aws-vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
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 terraform-aws-modules#92 from pablo19sc/main
Adding Cloud WAN support
- Loading branch information
Showing
26 changed files
with
805 additions
and
28 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
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,10 @@ | ||
# Creating AWS Cloud WAN's VPC attachment | ||
|
||
This example shows how you can use this module with `core_network` subnets, and AWS Cloud WAN's VPC attachment. This examples creates the following: | ||
|
||
* Global Network and Core Network. | ||
* Core Network's policy (in `cwan_policy.tf`), creating two segments (prod and nonprod) in two AWS Regions (*us-east-1* and *eu-west-1*). The *prod* segments needs acceptance for the attachments. | ||
* The VPC module creates the following (in two AWS Regions): | ||
* Two sets of subnets (workloads and core_network) | ||
* Cloud WAN's VPC attachment - with attachment acceptance for the VPC to associate to the *prod* segment. | ||
* Routing to Core Network (0.0.0.0/0) in workload subnets. |
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,21 @@ | ||
formatter: markdown | ||
header-from: .header.md | ||
settings: | ||
anchor: true | ||
color: true | ||
default: true | ||
escape: true | ||
html: true | ||
indent: 2 | ||
required: true | ||
sensitive: true | ||
type: true | ||
lockfile: false | ||
|
||
sort: | ||
enabled: true | ||
by: required | ||
|
||
output: | ||
file: README.md | ||
mode: replace |
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,57 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
# Creating AWS Cloud WAN's VPC attachment | ||
|
||
This example shows how you can use this module with `core_network` subnets, and AWS Cloud WAN's VPC attachment. This examples creates the following: | ||
|
||
* Global Network and Core Network. | ||
* Core Network's policy (in `cwan_policy.tf`), creating two segments (prod and nonprod) in two AWS Regions (*us-east-1* and *eu-west-1*). The *prod* segments needs acceptance for the attachments. | ||
* The VPC module creates the following (in two AWS Regions): | ||
* Two sets of subnets (workloads and core\_network) | ||
* Cloud WAN's VPC attachment - with attachment acceptance for the VPC to associate to the *prod* segment. | ||
* Routing to Core Network (0.0.0.0/0) in workload subnets. | ||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.27.0 | | ||
| <a name="requirement_awscc"></a> [awscc](#requirement\_awscc) | >= 0.36.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.27.0 | | ||
| <a name="provider_awscc.awsccnvirginia"></a> [awscc.awsccnvirginia](#provider\_awscc.awsccnvirginia) | >= 0.36.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_ireland_vpc"></a> [ireland\_vpc](#module\_ireland\_vpc) | aws-ia/vpc/aws | >= 3.0.2 | | ||
| <a name="module_nvirginia_vpc"></a> [nvirginia\_vpc](#module\_nvirginia\_vpc) | aws-ia/vpc/aws | >= 3.0.2 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [awscc_networkmanager_core_network.core_network](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/networkmanager_core_network) | resource | | ||
| [awscc_networkmanager_global_network.global_network](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/networkmanager_global_network) | resource | | ||
| [aws_networkmanager_core_network_policy_document.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/networkmanager_core_network_policy_document) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_cloud_wan_regions"></a> [cloud\_wan\_regions](#input\_cloud\_wan\_regions) | AWS Regions to create in Cloud WAN's core network. | <pre>object({<br> nvirginia = string<br> ireland = string<br> })</pre> | <pre>{<br> "ireland": "eu-west-1",<br> "nvirginia": "us-east-1"<br>}</pre> | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_core_network"></a> [core\_network](#output\_core\_network) | Core Network ID. | | ||
| <a name="output_core_network_vpc_attachments"></a> [core\_network\_vpc\_attachments](#output\_core\_network\_vpc\_attachments) | Core Network VPC attachments. | | ||
| <a name="output_global_network"></a> [global\_network](#output\_global\_network) | Global Network ID. | | ||
| <a name="output_vpcs"></a> [vpcs](#output\_vpcs) | VPCs created. | | ||
<!-- END_TF_DOCS --> |
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,63 @@ | ||
|
||
data "aws_networkmanager_core_network_policy_document" "policy" { | ||
core_network_configuration { | ||
vpn_ecmp_support = true | ||
asn_ranges = ["64515-64520"] | ||
|
||
edge_locations { | ||
location = var.cloud_wan_regions.nvirginia | ||
asn = 64515 | ||
} | ||
|
||
edge_locations { | ||
location = var.cloud_wan_regions.ireland | ||
asn = 64516 | ||
} | ||
} | ||
|
||
segments { | ||
name = "prod" | ||
description = "Segment for production traffic" | ||
require_attachment_acceptance = true | ||
} | ||
|
||
segments { | ||
name = "nonprod" | ||
description = "Segment for non-production traffic" | ||
require_attachment_acceptance = false | ||
} | ||
|
||
attachment_policies { | ||
rule_number = 100 | ||
condition_logic = "or" | ||
|
||
conditions { | ||
type = "tag-value" | ||
operator = "equals" | ||
key = "env" | ||
value = "prod" | ||
} | ||
|
||
action { | ||
association_method = "constant" | ||
segment = "prod" | ||
} | ||
} | ||
|
||
attachment_policies { | ||
rule_number = 200 | ||
condition_logic = "or" | ||
|
||
conditions { | ||
type = "tag-value" | ||
operator = "equals" | ||
key = "env" | ||
value = "nonprod" | ||
} | ||
|
||
action { | ||
association_method = "constant" | ||
segment = "nonprod" | ||
} | ||
} | ||
} |
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,94 @@ | ||
|
||
# VPC module (North Virginia) | ||
module "nvirginia_vpc" { | ||
source = "aws-ia/vpc/aws" | ||
version = ">= 3.0.2" | ||
|
||
providers = { | ||
aws = aws.awsnvirginia | ||
awscc = awscc.awsccnvirginia | ||
} | ||
|
||
name = "nvirginia-vpc" | ||
cidr_block = "10.0.0.0/24" | ||
az_count = 2 | ||
|
||
core_network = { | ||
id = awscc_networkmanager_core_network.core_network.core_network_id | ||
arn = awscc_networkmanager_core_network.core_network.core_network_arn | ||
} | ||
core_network_routes = { | ||
workload = "0.0.0.0/0" | ||
} | ||
|
||
subnets = { | ||
workload = { netmask = 28 } | ||
core_network = { | ||
netmask = 28 | ||
ipv6_support = false | ||
require_acceptance = true | ||
accept_attachment = true | ||
|
||
tags = { | ||
env = "prod" | ||
} | ||
} | ||
} | ||
} | ||
|
||
# VPC module (Ireland) | ||
module "ireland_vpc" { | ||
source = "aws-ia/vpc/aws" | ||
version = ">= 3.0.2" | ||
|
||
providers = { | ||
aws = aws.awsireland | ||
awscc = awscc.awsccireland | ||
} | ||
|
||
name = "ireland-vpc" | ||
cidr_block = "10.0.1.0/24" | ||
az_count = 2 | ||
|
||
core_network = { | ||
id = awscc_networkmanager_core_network.core_network.core_network_id | ||
arn = awscc_networkmanager_core_network.core_network.core_network_arn | ||
} | ||
core_network_routes = { | ||
workload = "0.0.0.0/0" | ||
} | ||
|
||
subnets = { | ||
workload = { netmask = 28 } | ||
core_network = { | ||
netmask = 28 | ||
ipv6_support = false | ||
require_acceptance = false | ||
|
||
tags = { | ||
env = "nonprod" | ||
} | ||
} | ||
} | ||
} | ||
|
||
# Global Network | ||
resource "awscc_networkmanager_global_network" "global_network" { | ||
provider = awscc.awsccnvirginia | ||
|
||
description = "Global Network - VPC module" | ||
} | ||
|
||
# Core Network | ||
resource "awscc_networkmanager_core_network" "core_network" { | ||
provider = awscc.awsccnvirginia | ||
|
||
description = "Core Network - VPC module" | ||
global_network_id = awscc_networkmanager_global_network.global_network.id | ||
policy_document = jsonencode(jsondecode(data.aws_networkmanager_core_network_policy_document.policy.json)) | ||
|
||
tags = [{ | ||
key = "Name", | ||
value = "Core Network - VPC module" | ||
}] | ||
} |
Oops, something went wrong.