Skip to content

Commit

Permalink
feat!: Support enabling NAU metrics in "aws_vpc" resource (#838)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomasz Charewicz <tomasz.charewicz@ringieraxelspringer.pl>
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
  • Loading branch information
4 people committed Apr 7, 2023
1 parent 7010e70 commit 44e6eaa
Show file tree
Hide file tree
Showing 61 changed files with 3,301 additions and 1,992 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.0
rev: v1.77.1
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand Down
167 changes: 102 additions & 65 deletions README.md

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Upgrade from v3.x to v4.x

If you have any questions regarding this upgrade process, please consult the [`examples`](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/) directory:

If you find a bug, please open an issue with supporting configuration to reproduce.

## List of backwards incompatible changes

- The minimum required Terraform version is now 1.0
- The minimum required AWS provider version is now 4.x (4.35.0 at time of writing)
- `assign_ipv6_address_on_creation` has been removed; use the respective subnet type equivalent instead (i.e. - `public_subnet_assign_ipv6_address_on_creation`)
- `enable_classiclink` has been removed; it is no longer supported by AWS https://github.com/hashicorp/terraform/issues/31730
- `enable_classiclink_dns_support` has been removed; it is no longer supported by AWS https://github.com/hashicorp/terraform/issues/31730

## Additional changes

### Modified

- `map_public_ip_on_launch` now defaults to `false`
- `enable_dns_hostnames` now defaults to `true`
- `enable_dns_support` now defaults to `true`
- `manage_default_security_group` now defaults to `true`
- `manage_default_route_table` now defaults to `true`
- `manage_default_network_acl` now defaults to `true`
- The default name for the default security group, route table, and network ACL has changed to fallback to append `-default` to the VPC name if a specific name is not provided
- The default fallback value for outputs has changed from an empty string to `null`

### Variable and output changes

1. Removed variables:

- `assign_ipv6_address_on_creation` has been removed; use the respective subnet type equivalent instead (i.e. - `public_subnet_assign_ipv6_address_on_creation`)
- `enable_classiclink` has been removed; it is no longer supported by AWS https://github.com/hashicorp/terraform/issues/31730
- `enable_classiclink_dns_support` has been removed; it is no longer supported by AWS https://github.com/hashicorp/terraform/issues/31730

2. Renamed variables:

- None

3. Added variables:

- VPC
- `ipv6_cidr_block_network_border_group`
- `enable_network_address_usage_metrics`
- Subnets
- `*_subnet_enable_dns64` for each subnet type
- `*_subnet_enable_resource_name_dns_aaaa_record_on_launch` for each subnet type
- `*_subnet_enable_resource_name_dns_a_record_on_launch` for each subnet type
- `*_subnet_ipv6_native` for each subnet type
- `*_subnet_private_dns_hostname_type_on_launch` for each subnet type

4. Removed outputs:

- None

5. Renamed outputs:

- None

6. Added outputs:

- None

### State Changes

None
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Note that this example may create resources which can cost money (AWS Elastic IP

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.73 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.35 |

## Providers

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

## Modules

Expand All @@ -43,6 +43,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| Name | Type |
|------|------|
| [aws_security_group.vpc_tls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
| [aws_iam_policy_document.dynamodb_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.generic_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_security_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/security_group) | data source |
Expand Down
37 changes: 18 additions & 19 deletions examples/complete-vpc/main.tf → examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ provider "aws" {
region = local.region
}

data "aws_availability_zones" "available" {}

locals {
name = "ex-${replace(basename(path.cwd), "_", "-")}"
name = "ex-${basename(path.cwd)}"
region = "eu-west-1"

vpc_cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)

tags = {
Example = local.name
GithubRepo = "terraform-aws-vpc"
Expand All @@ -21,15 +26,15 @@ module "vpc" {
source = "../../"

name = local.name
cidr = "10.0.0.0/16"
cidr = local.vpc_cidr

azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.11.0/24", "10.0.12.0/24", "10.0.13.0/24"]
database_subnets = ["10.0.21.0/24", "10.0.22.0/24", "10.0.23.0/24"]
elasticache_subnets = ["10.0.31.0/24", "10.0.32.0/24", "10.0.33.0/24"]
redshift_subnets = ["10.0.41.0/24", "10.0.42.0/24", "10.0.43.0/24"]
intra_subnets = ["10.0.51.0/24", "10.0.52.0/24", "10.0.53.0/24"]
azs = local.azs
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 4)]
database_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 8)]
elasticache_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 12)]
redshift_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 16)]
intra_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 20)]

private_subnet_names = ["Private Subnet One", "Private Subnet Two"]
# public_subnet_names omitted to show default name generation for all three subnets
Expand All @@ -38,16 +43,10 @@ module "vpc" {
redshift_subnet_names = ["Redshift Subnet One", "Redshift Subnet Two", "Redshift Subnet Three"]
intra_subnet_names = []

create_database_subnet_group = false

manage_default_network_acl = true
default_network_acl_tags = { Name = "${local.name}-default" }

manage_default_route_table = true
default_route_table_tags = { Name = "${local.name}-default" }

manage_default_security_group = true
default_security_group_tags = { Name = "${local.name}-default" }
create_database_subnet_group = false
manage_default_network_acl = false
manage_default_route_table = false
manage_default_security_group = false

enable_dns_hostnames = true
enable_dns_support = true
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.73"
version = ">= 4.35"
}
}
}
7 changes: 4 additions & 3 deletions examples/ipam-vpc/README.md → examples/ipam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Note that this example may create resources which can cost money (AWS Elastic IP

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.73 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.35 |

## Providers

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

## Modules

Expand All @@ -54,6 +54,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| [aws_vpc_ipam_pool.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_pool) | resource |
| [aws_vpc_ipam_pool_cidr.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_pool_cidr) | resource |
| [aws_vpc_ipam_preview_next_cidr.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipam_preview_next_cidr) | resource |
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |

## Inputs

Expand Down
6 changes: 4 additions & 2 deletions examples/ipam-vpc/main.tf → examples/ipam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ provider "aws" {
region = local.region
}

data "aws_availability_zones" "available" {}

locals {
name = "ex-${replace(basename(path.cwd), "_", "-")}"
name = "ex-${basename(path.cwd)}"
region = "eu-west-1"

azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
azs = slice(data.aws_availability_zones.available.names, 0, 3)
preview_partition = cidrsubnets(aws_vpc_ipam_preview_next_cidr.this.cidr, 2, 2, 2)

tags = {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/ipv6/versions.tf → examples/ipam/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.73"
version = ">= 4.35"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ Note that this example may create resources which can cost money (AWS Elastic IP

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.73 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.35 |

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.35 |

## Modules

Expand All @@ -34,7 +36,9 @@ No providers.

## Resources

No resources.
| Name | Type |
|------|------|
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |

## Inputs

Expand Down
49 changes: 49 additions & 0 deletions examples/ipv6-dualstack/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
provider "aws" {
region = local.region
}

data "aws_availability_zones" "available" {}

locals {
name = "ex-${basename(path.cwd)}"
region = "eu-west-1"

vpc_cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)

tags = {
Example = local.name
GithubRepo = "terraform-aws-vpc"
GithubOrg = "terraform-aws-modules"
}
}

################################################################################
# VPC Module
################################################################################

module "vpc" {
source = "../.."

name = local.name
cidr = local.vpc_cidr

azs = local.azs
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 4)]
database_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 8)]

enable_nat_gateway = false

create_database_subnet_route_table = true
create_database_internet_gateway_route = true

enable_ipv6 = true
public_subnet_assign_ipv6_address_on_creation = true

public_subnet_ipv6_prefixes = [0, 1, 2]
private_subnet_ipv6_prefixes = [3, 4, 5]
database_subnet_ipv6_prefixes = [6, 7, 8]

tags = local.tags
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.73"
version = ">= 4.35"
}
}
}
Loading

0 comments on commit 44e6eaa

Please sign in to comment.