Skip to content

Commit

Permalink
Merge pull request #121 from pablo19sc/main
Browse files Browse the repository at this point in the history
minor edits - map_public_ip_on_launch & tgw attachment tags
  • Loading branch information
tbulding authored Oct 25, 2023
2 parents 964d3f1 + 0a974e0 commit ebb6422
Show file tree
Hide file tree
Showing 31 changed files with 89 additions and 167 deletions.
8 changes: 4 additions & 4 deletions README.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions examples/cloud_wan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,27 @@ This example shows how you can use this module with `core_network` subnets, and
| 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_aws"></a> [aws](#requirement\_aws) | >= 5.22.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.27.0 |
| <a name="provider_aws.awsnvirginia"></a> [aws.awsnvirginia](#provider\_aws.awsnvirginia) | >= 4.27.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.22.0 |
| <a name="provider_aws.awsnvirginia"></a> [aws.awsnvirginia](#provider\_aws.awsnvirginia) | >= 5.22.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_ireland_vpc"></a> [ireland\_vpc](#module\_ireland\_vpc) | aws-ia/vpc/aws | >= 4.2.0 |
| <a name="module_nvirginia_vpc"></a> [nvirginia\_vpc](#module\_nvirginia\_vpc) | aws-ia/vpc/aws | >= 4.2.0 |
| <a name="module_ireland_vpc"></a> [ireland\_vpc](#module\_ireland\_vpc) | ../.. | n/a |
| <a name="module_nvirginia_vpc"></a> [nvirginia\_vpc](#module\_nvirginia\_vpc) | ../.. | n/a |

## Resources

| Name | Type |
|------|------|
| [aws_networkmanager_core_network.core_network](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/networkmanager_core_network) | resource |
| [aws_networkmanager_core_network_policy_attachment.core_network_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/networkmanager_core_network_policy_attachment) | resource |
| [aws_networkmanager_global_network.global_network](https://registry.terraform.io/providers/hashicorp/aws/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 |

Expand Down
2 changes: 1 addition & 1 deletion examples/cloud_wan/cwan_policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data "aws_networkmanager_core_network_policy_document" "policy" {
segments {
name = "prod"
description = "Segment for production traffic"
require_attachment_acceptance = true
require_attachment_acceptance = false
}

segments {
Expand Down
20 changes: 6 additions & 14 deletions examples/cloud_wan/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# VPC module (North Virginia)
module "nvirginia_vpc" {
source = "aws-ia/vpc/aws"
version = ">= 4.2.0"
source = "../.."

providers = { aws = aws.awsnvirginia }

Expand Down Expand Up @@ -31,8 +30,7 @@ module "nvirginia_vpc" {
netmask = 28
assign_ipv6_cidr = true
appliance_mode_support = true
require_acceptance = true
accept_attachment = true
require_acceptance = false

tags = {
env = "prod"
Expand All @@ -43,8 +41,7 @@ module "nvirginia_vpc" {

# VPC module (Ireland)
module "ireland_vpc" {
source = "aws-ia/vpc/aws"
version = ">= 4.2.0"
source = "../.."

providers = { aws = aws.awsireland }

Expand Down Expand Up @@ -94,15 +91,10 @@ resource "aws_networkmanager_core_network" "core_network" {
description = "Core Network - VPC module"
global_network_id = aws_networkmanager_global_network.global_network.id

create_base_policy = true
base_policy_document = data.aws_networkmanager_core_network_policy_document.policy.json

tags = {
Name = "Core Network - VPC module"
}
}

# Core Network policy attachment
resource "aws_networkmanager_core_network_policy_attachment" "core_network_policy_attachment" {
provider = aws.awsnvirginia

core_network_id = aws_networkmanager_core_network.core_network.id
policy_document = data.aws_networkmanager_core_network_policy_document.policy.json
}
2 changes: 1 addition & 1 deletion examples/cloud_wan/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.27.0"
version = ">= 5.22.0"
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions examples/ipam/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module "vpc" {
# source = "aws-ia/vpc/aws"
# version = ">= 3.0.2"
source = "../.."

name = "ipam-vpc"
Expand Down
6 changes: 3 additions & 3 deletions examples/ipv6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This example shows how you can create dual-stack and IPv6-only subnets in your A
| 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_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |

## Providers

Expand All @@ -26,7 +26,7 @@ No providers.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_vpc"></a> [vpc](#module\_vpc) | aws-ia/vpc/aws | >= 4.2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | ../.. | n/a |

## Resources

Expand All @@ -36,7 +36,7 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Regions to create in Cloud WAN's core network. | `string` | `"eu-west-2"` | no |
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Region. | `string` | `"eu-west-2"` | no |

## Outputs

Expand Down
3 changes: 1 addition & 2 deletions examples/ipv6/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# VPC module
module "vpc" {
source = "aws-ia/vpc/aws"
version = ">= 4.2.0"
source = "../.."

name = "vpc-ipv6-generated"
cidr_block = "10.0.0.0/16"
Expand Down
2 changes: 1 addition & 1 deletion examples/ipv6/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.27.0"
version = ">= 5.0.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ipv6/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

variable "aws_region" {
description = "AWS Regions to create in Cloud WAN's core network."
description = "AWS Region."
type = string

default = "eu-west-2"
Expand Down
17 changes: 6 additions & 11 deletions examples/public_private_flow_logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ At this point, only cloud-watch logs are support, pending: https://github.com/aw
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.73.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.73.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_vpc"></a> [vpc](#module\_vpc) | aws-ia/vpc/aws | >= 4.2.0 |
| <a name="module_vpc1"></a> [vpc1](#module\_vpc1) | ../.. | n/a |
| <a name="module_vpc2"></a> [vpc2](#module\_vpc2) | ../.. | n/a |

## Resources

Expand All @@ -34,15 +35,9 @@ At this point, only cloud-watch logs are support, pending: https://github.com/aw

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | KMS Key ID | `string` | `null` | no |
| <a name="input_vpc_flow_logs"></a> [vpc\_flow\_logs](#input\_vpc\_flow\_logs) | Whether or not to create VPC flow logs and which type. Options: "cloudwatch", "s3", "none". | <pre>object({<br> log_destination = optional(string)<br> iam_role_arn = optional(string)<br> kms_key_id = optional(string)<br><br> log_destination_type = string<br> retention_in_days = optional(number)<br> tags = optional(map(string))<br> traffic_type = optional(string)<br> destination_options = optional(object({<br> file_format = optional(string)<br> hive_compatible_partitions = optional(bool)<br> per_hour_partition = optional(bool)<br> }))<br> })</pre> | <pre>{<br> "kms_key_id": null,<br> "log_destination_type": "cloud-watch-logs",<br> "retention_in_days": 180<br>}</pre> | no |
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Region. | `string` | `"eu-west-1"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_private_subnets"></a> [private\_subnets](#output\_private\_subnets) | Map of private subnet attributes grouped by az. |
| <a name="output_private_subnets_tags_length"></a> [private\_subnets\_tags\_length](#output\_private\_subnets\_tags\_length) | Count of private subnet tags for a single az. |
| <a name="output_public_subnets"></a> [public\_subnets](#output\_public\_subnets) | Map of public subnet attributes grouped by az. |
| <a name="output_public_subnets_tags_length"></a> [public\_subnets\_tags\_length](#output\_public\_subnets\_tags\_length) | Count of public subnet tags for a single az. |
No outputs.
<!-- END_TF_DOCS -->
39 changes: 29 additions & 10 deletions examples/public_private_flow_logs/main.tf
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
data "aws_availability_zones" "current" {}

module "vpc" {
source = "aws-ia/vpc/aws"
version = ">= 4.2.0"
module "vpc1" {
source = "../.."

name = "flowlogs"
cidr_block = "10.0.0.0/20"
name = "vpc-cw-logs"
cidr_block = "10.0.0.0/16"
az_count = 2

subnets = {
public = {
name_prefix = "my-public" # omit to prefix with "public"
netmask = 24
nat_gateway_configuration = "all_azs" # options: "single_az", "none"
nat_gateway_configuration = "all_azs"
tags = {
subnet_type = "public"
}
}

private = {
# omitting name_prefix defaults value to "private"
# name_prefix = "private"
netmask = 24
connect_to_public_natgw = true
}
}

vpc_flow_logs = var.vpc_flow_logs
vpc_flow_logs = {
log_destination_type = "cloud-watch-logs"
retention_in_days = 180
}
}

module "vpc2" {
source = "../.."

name = "vpc-s3-logs"
cidr_block = "10.0.0.0/16"
az_count = 2

subnets = {
endpoints = { netmask = 24 }
workloads = { netmask = 24 }
}

vpc_flow_logs = {
log_destination_type = "s3"
destination_options = {
file_format = "parquet"
}
}
}
20 changes: 0 additions & 20 deletions examples/public_private_flow_logs/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
output "public_subnets" {
description = "Map of public subnet attributes grouped by az."
value = module.vpc.public_subnet_attributes_by_az
}

output "private_subnets" {
description = "Map of private subnet attributes grouped by az."
value = module.vpc.private_subnet_attributes_by_az
}

## Used for Testing, do not delete

output "public_subnets_tags_length" {
description = "Count of public subnet tags for a single az."
value = length(module.vpc.public_subnet_attributes_by_az[data.aws_availability_zones.current.names[0]].tags)
}

output "private_subnets_tags_length" {
description = "Count of private subnet tags for a single az."
value = length(module.vpc.private_subnet_attributes_by_az["private/${data.aws_availability_zones.current.names[0]}"].tags)
}
2 changes: 1 addition & 1 deletion examples/public_private_flow_logs/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.73.0"
version = ">= 5.0.0"
}
}
}
30 changes: 3 additions & 27 deletions examples/public_private_flow_logs/variables.tf
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
variable "kms_key_id" {
description = "KMS Key ID"
variable "aws_region" {
description = "AWS Region."
type = string
default = null
}

variable "vpc_flow_logs" {
description = "Whether or not to create VPC flow logs and which type. Options: \"cloudwatch\", \"s3\", \"none\"."

type = object({
log_destination = optional(string)
iam_role_arn = optional(string)
kms_key_id = optional(string)

log_destination_type = string
retention_in_days = optional(number)
tags = optional(map(string))
traffic_type = optional(string)
destination_options = optional(object({
file_format = optional(string)
hive_compatible_partitions = optional(bool)
per_hour_partition = optional(bool)
}))
})
default = {
log_destination_type = "cloud-watch-logs"
retention_in_days = 180
kms_key_id = null
}
default = "eu-west-1"
}
13 changes: 0 additions & 13 deletions examples/secondary_cidr/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
data "aws_region" "current" {}

module "secondary" {
# source = "aws-ia/vpc/aws"
# version = ">= 3.0.2"
source = "../.."

name = "secondary-cidr"
Expand All @@ -14,17 +12,6 @@ module "secondary" {

vpc_secondary_cidr_natgw = var.natgw_id_per_az

# If referencing another instantiation of this module, you can use the output natgw_id_per_az, example:
# vpc_secondary_cidr_natgw = module.vpc.natgw_id_per_az

# underly structure is:
# {
# az : {
# id : "nat-asdf"
# }
# }
# but preferably you should just pass the module output natgw_id_per_az

subnets = {
private = {
name_prefix = "secondary-private-natgw-connected"
Expand Down
6 changes: 3 additions & 3 deletions examples/transit_gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ This example shows how you can use this module with `transit_gateway` subnets, a
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.72.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_vpc"></a> [vpc](#module\_vpc) | aws-ia/vpc/aws | >= 4.2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | ../.. | n/a |

## Resources

Expand Down
3 changes: 1 addition & 2 deletions examples/transit_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ resource "aws_ec2_managed_prefix_list" "example" {
}

module "vpc" {
source = "aws-ia/vpc/aws"
version = ">= 4.2.0"
source = "../.."

name = "tgw"
cidr_block = "10.0.0.0/16"
Expand Down
2 changes: 1 addition & 1 deletion examples/transit_gateway/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.72.0"
version = ">= 5.0.0"
}
}
}
Expand Down
Loading

0 comments on commit ebb6422

Please sign in to comment.