Skip to content

v1.4.2: fix nacl limit by adding flags #13

Merged
merged 1 commit into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Versions

## Version 1.x

* v1.0.0 -- 20210502
- initial creation

Expand Down Expand Up @@ -74,3 +76,13 @@
* (no version) -- 20211119
- add example for full-setup

* v1.4.2 -- 20220109
- add common/versions.tf to prep for tf 0.13+
- common/defaults.tf
- add 10/8 to enteprise list and make the default, due to a max of 40 nacl entries in a nacl
- nacls-rules
- add variable enable_rules (boolean) to create or not create the rule
- peers
- add variables enable_nacl_entry_self and enable_nacl_entry_peer to determine whether to create the rule local/remote (default false)

## Version 2.x
2 changes: 1 addition & 1 deletion common/defaults.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ locals {
#---
"nacl_all_cidr_blocks" = {
"all" = ["0.0.0.0/0"]
"enterprise" = ["148.129.0.0/16", "172.16.0.0/12", "192.168.0.0/16"]
"enterprise" = ["148.129.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "10.0.0.0/8"]
"vpc" = []
"endpoints" = []
"additional" = []
Expand Down
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "1.4.1"
_module_version = "1.4.2"
}
22 changes: 22 additions & 0 deletions common/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# for tf 0.13+, ignored in tf 0.12
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.66.0"
}
null = {
source = "hashicorp/null"
version = ">= 3.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.0"
}
template = {
source = "hashicorp/template"
version = ">= 2.0"
}
}
# required_version = ">= 0.13"
}
23 changes: 23 additions & 0 deletions examples/dns-vpc-region-vpcN/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Requirements

No requirements.

## Providers

No providers.

## Modules

No modules.

## Resources

No resources.

## Inputs

No inputs.

## Outputs

No outputs.
23 changes: 23 additions & 0 deletions examples/dns-vpc-region/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Requirements

No requirements.

## Providers

No providers.

## Modules

No modules.

## Resources

No resources.

## Inputs

No inputs.

## Outputs

No outputs.
31 changes: 31 additions & 0 deletions examples/dns-vpc-region/apps/dns/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Requirements

No requirements.

## Providers

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

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_cloudwatch_log_group.dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_route53_resolver_query_log_config.dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_query_log_config) | resource |
| [aws_route53_resolver_query_log_config_association.dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_query_log_config_association) | resource |
| [aws_vpc.all_vpcs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
| [aws_vpcs.all_vpcs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpcs) | data source |

## Inputs

No inputs.

## Outputs

No outputs.
1 change: 1 addition & 0 deletions flowlogs-role/versions.tf
1 change: 1 addition & 0 deletions flowlogs/versions.tf
10 changes: 8 additions & 2 deletions nacl-rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ module "nacls_enterprise" {

## Requirements

No requirements.
| Name | Version |
|------|---------|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.66.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
| <a name="requirement_template"></a> [template](#requirement\_template) | >= 2.0 |

## Providers

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

## Modules

Expand All @@ -56,6 +61,7 @@ No modules.
| <a name="input_account_alias"></a> [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no |
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no |
| <a name="input_cidr_blocks"></a> [cidr\_blocks](#input\_cidr\_blocks) | List of CIDR blocks for selected rules | `list(string)` | `[]` | no |
| <a name="input_enable_rules"></a> [enable\_rules](#input\_enable\_rules) | Flag to determine whether to create the rules (default: true) | `bool` | `true` | no |
| <a name="input_merge_cidr_blocks"></a> [merge\_cidr\_blocks](#input\_merge\_cidr\_blocks) | Map of names to list of CIDR blocks | `map(list(string))` | `{}` | no |
| <a name="input_named_cidr_blocks"></a> [named\_cidr\_blocks](#input\_named\_cidr\_blocks) | List of CIDR block names from defaults for selected rules: (all, enterprise, vpc, ...) | `list(string)` | `[]` | no |
| <a name="input_network_acl_id"></a> [network\_acl\_id](#input\_network\_acl\_id) | Network ACL ID to which to apply the rules | `string` | n/a | yes |
Expand Down
4 changes: 2 additions & 2 deletions nacl-rules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ locals {
}

resource "aws_network_acl_rule" "in" {
for_each = { for r in local.r3_in : r.label => r }
for_each = var.enable_rules ? { for r in local.r3_in : r.label => r } : {}
network_acl_id = var.network_acl_id
rule_number = each.value.rule_number
egress = each.value.egress
Expand All @@ -122,7 +122,7 @@ resource "aws_network_acl_rule" "in" {
}

resource "aws_network_acl_rule" "out" {
for_each = { for r in local.r3_out : r.label => r }
for_each = var.enable_rules ? { for r in local.r3_out : r.label => r } : {}
network_acl_id = var.network_acl_id
rule_number = each.value.rule_number
egress = each.value.egress
Expand Down
7 changes: 7 additions & 0 deletions nacl-rules/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ variable "rule_increment" {
type = number
default = 10
}

variable "enable_rules" {
description = "Flag to determine whether to create the rules (default: true)"
type = bool
default = true
}

1 change: 1 addition & 0 deletions nacl-rules/versions.tf
1 change: 1 addition & 0 deletions nacls/versions.tf
19 changes: 16 additions & 3 deletions peer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ for `vpc_index=2` (aka, vpc2), the rule number in the NACL rule at `rule_number

`vpc_cidr_block` and `peer_vpc_cidr_block` are retrieved from the VPC itself, so it too is optional.

We have hit the maximum number of NACL entries in a rule (40) using this per-VPC rule creation method.
As of version 1.4.2, this will be disabld by default, and it will use the entire 10/8 address space as
added in another location. This in essence renders the tracking of the peer pairs for and setting nalcs
for any peers within the 10/8 obsolete. We may come upon a need to create nacl entries for DENY
and we will address this at that time.

# Usage

```hcl
Expand Down Expand Up @@ -72,14 +78,19 @@ module "peer_services" {

## Requirements

No requirements.
| Name | Version |
|------|---------|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.66.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
| <a name="requirement_template"></a> [template](#requirement\_template) | >= 2.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws.peer"></a> [aws.peer](#provider\_aws.peer) | n/a |
| <a name="provider_aws.self"></a> [aws.self](#provider\_aws.self) | n/a |
| <a name="provider_aws.peer"></a> [aws.peer](#provider\_aws.peer) | >= 3.66.0 |
| <a name="provider_aws.self"></a> [aws.self](#provider\_aws.self) | >= 3.66.0 |

## Modules

Expand Down Expand Up @@ -123,6 +134,7 @@ No requirements.
| <a name="input_override_prefixes"></a> [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no |
| <a name="input_peer_account_alias"></a> [peer\_account\_alias](#input\_peer\_account\_alias) | Peer AWS Account Alias | `string` | `""` | no |
| <a name="input_peer_account_id"></a> [peer\_account\_id](#input\_peer\_account\_id) | Peer AWS Account ID | `string` | `""` | no |
| <a name="input_peer_enable_rules"></a> [peer\_enable\_rules](#input\_peer\_enable\_rules) | Flag to control creating NACL entries/rules on peer (default: false) | `bool` | `false` | no |
| <a name="input_peer_network_acl_filter"></a> [peer\_network\_acl\_filter](#input\_peer\_network\_acl\_filter) | Peer VPC Network ACL filter list | `list(string)` | `[]` | no |
| <a name="input_peer_network_acl_ids"></a> [peer\_network\_acl\_ids](#input\_peer\_network\_acl\_ids) | Peer VPC Network ACL IDs | `list(string)` | `[]` | no |
| <a name="input_peer_route_table_filter"></a> [peer\_route\_table\_filter](#input\_peer\_route\_table\_filter) | Peer VPC route table search filter list (default: services) | `list(string)` | <pre>[<br> "route-*-services",<br> "route-*-services-private*"<br>]</pre> | no |
Expand All @@ -141,6 +153,7 @@ No requirements.
| <a name="input_route_table_ids"></a> [route\_table\_ids](#input\_route\_table\_ids) | Self VPC route table IDs (default: all *private* route tables at self VPC) | `list(string)` | `[]` | no |
| <a name="input_rule_increment"></a> [rule\_increment](#input\_rule\_increment) | Rule number increment per new CIDR block | `number` | `1` | no |
| <a name="input_rule_number"></a> [rule\_number](#input\_rule\_number) | Starting rule number within the rule | `number` | `null` | no |
| <a name="input_self_enable_rules"></a> [self\_enable\_rules](#input\_self\_enable\_rules) | Flag to control creating NACL entries/rules on self (default: false) | `bool` | `false` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no |
| <a name="input_vpc_cidr_block"></a> [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | Self VPC CIDR Block (default: obtain from self VPC) | `string` | `""` | no |
| <a name="input_vpc_environment"></a> [vpc\_environment](#input\_vpc\_environment) | VPC environment purpose (infrastructure, common, shared, dev, stage, ite, prod) | `string` | `null` | no |
Expand Down
8 changes: 8 additions & 0 deletions peer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
*
* `vpc_cidr_block` and `peer_vpc_cidr_block` are retrieved from the VPC itself, so it too is optional.
*
* We have hit the maximum number of NACL entries in a rule (40) using this per-VPC rule creation method.
* As of version 1.4.2, this will be disabld by default, and it will use the entire 10/8 address space as
* added in another location. This in essence renders the tracking of the peer pairs for and setting nalcs
* for any peers within the 10/8 obsolete. We may come upon a need to create nacl entries for DENY
* and we will address this at that time.
*
* # Usage
*
* ```hcl
Expand Down Expand Up @@ -185,6 +191,7 @@ module "nacl_rule_self" {
rule_definitions = {}
named_cidr_blocks = ["vpc"]
merge_cidr_blocks = { "vpc" = [local.peer_cidr_block] }
enable_rules = var.self_enable_rules
rules = ["all_inbound", "all_outbound"]
rule_number = var.rule_number
rule_increment = var.rule_increment
Expand All @@ -208,6 +215,7 @@ module "nacl_rule_peer" {
rule_definitions = {}
named_cidr_blocks = ["vpc"]
merge_cidr_blocks = { "vpc" = [local.self_cidr_block] }
enable_rules = var.peer_enable_rules
rules = ["all_inbound", "all_outbound"]
rule_number = var.peer_rule_number
rule_increment = var.peer_rule_increment
Expand Down
18 changes: 0 additions & 18 deletions peer/requirements.tf

This file was deleted.

6 changes: 6 additions & 0 deletions peer/variables.peer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ variable "peer_rule_increment" {
type = number
default = 1
}

variable "peer_enable_rules" {
description = "Flag to control creating NACL entries/rules on peer (default: false)"
type = bool
default = false
}
6 changes: 6 additions & 0 deletions peer/variables.self.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ variable "rule_increment" {
type = number
default = 1
}

variable "self_enable_rules" {
description = "Flag to control creating NACL entries/rules on self (default: false)"
type = bool
default = false
}
1 change: 1 addition & 0 deletions peer/versions.tf
1 change: 1 addition & 0 deletions routing/versions.tf
1 change: 1 addition & 0 deletions security-groups/versions.tf
1 change: 1 addition & 0 deletions subnets/versions.tf
1 change: 1 addition & 0 deletions vpc-interface-endpoint/versions.tf
1 change: 1 addition & 0 deletions vpc/versions.tf
1 change: 1 addition & 0 deletions vpn/versions.tf