Skip to content

Commit 247fc3c

Browse files
Adjust module for 2 new resources aws_vpc_block_public_access_options, aws_vpc_block_public_access_exclusion
1 parent 573f574 commit 247fc3c

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ Full contributing [guidelines are covered here](.github/contributing.md).
256256
| Name | Version |
257257
|------|---------|
258258
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
259-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.46 |
259+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.79 |
260260

261261
## Providers
262262

263263
| Name | Version |
264264
|------|---------|
265-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.46 |
265+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.79 |
266266

267267
## Modules
268268

@@ -341,6 +341,8 @@ No modules.
341341
| [aws_subnet.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
342342
| [aws_subnet.redshift](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
343343
| [aws_vpc.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
344+
| [aws_vpc_block_public_access_exclusion.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_block_public_access_exclusion) | resource |
345+
| [aws_vpc_block_public_access_options.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_block_public_access_options) | resource |
344346
| [aws_vpc_dhcp_options.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_dhcp_options) | resource |
345347
| [aws_vpc_dhcp_options_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_dhcp_options_association) | resource |
346348
| [aws_vpc_ipv4_cidr_block_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_ipv4_cidr_block_association) | resource |
@@ -470,6 +472,8 @@ No modules.
470472
| <a name="input_flow_log_traffic_type"></a> [flow\_log\_traffic\_type](#input\_flow\_log\_traffic\_type) | The type of traffic to capture. Valid values: ACCEPT, REJECT, ALL | `string` | `"ALL"` | no |
471473
| <a name="input_igw_tags"></a> [igw\_tags](#input\_igw\_tags) | Additional tags for the internet gateway | `map(string)` | `{}` | no |
472474
| <a name="input_instance_tenancy"></a> [instance\_tenancy](#input\_instance\_tenancy) | A tenancy option for instances launched into the VPC | `string` | `"default"` | no |
475+
| <a name="input_internet_gateway_block_enabled"></a> [internet\_gateway\_block\_enabled](#input\_internet\_gateway\_block\_enabled) | Enable AWS VPC Block Public Access Options. Default is `false` | `bool` | `false` | no |
476+
| <a name="input_internet_gateway_block_mode"></a> [internet\_gateway\_block\_mode](#input\_internet\_gateway\_block\_mode) | Block mode. Needs to be one of `block-bidirectional`, `block-ingress`, `off`. Default is `off` | `string` | `"off"` | no |
473477
| <a name="input_intra_acl_tags"></a> [intra\_acl\_tags](#input\_intra\_acl\_tags) | Additional tags for the intra subnets network ACL | `map(string)` | `{}` | no |
474478
| <a name="input_intra_dedicated_network_acl"></a> [intra\_dedicated\_network\_acl](#input\_intra\_dedicated\_network\_acl) | Whether to use dedicated network ACL (not default) and custom rules for intra subnets | `bool` | `false` | no |
475479
| <a name="input_intra_inbound_acl_rules"></a> [intra\_inbound\_acl\_rules](#input\_intra\_inbound\_acl\_rules) | Intra subnets inbound network ACLs | `list(map(string))` | <pre>[<br/> {<br/> "cidr_block": "0.0.0.0/0",<br/> "from_port": 0,<br/> "protocol": "-1",<br/> "rule_action": "allow",<br/> "rule_number": 100,<br/> "to_port": 0<br/> }<br/>]</pre> | no |
@@ -581,6 +585,7 @@ No modules.
581585
| <a name="input_single_nat_gateway"></a> [single\_nat\_gateway](#input\_single\_nat\_gateway) | Should be true if you want to provision a single shared NAT Gateway across all of your private networks | `bool` | `false` | no |
582586
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
583587
| <a name="input_use_ipam_pool"></a> [use\_ipam\_pool](#input\_use\_ipam\_pool) | Determines whether IPAM pool is used for CIDR allocation | `bool` | `false` | no |
588+
| <a name="input_vpc_block_public_access_exclusions"></a> [vpc\_block\_public\_access\_exclusions](#input\_vpc\_block\_public\_access\_exclusions) | List of VPC Block Public Access Exclusions | `map(any)` | `{}` | no |
584589
| <a name="input_vpc_flow_log_iam_policy_name"></a> [vpc\_flow\_log\_iam\_policy\_name](#input\_vpc\_flow\_log\_iam\_policy\_name) | Name of the IAM policy | `string` | `"vpc-flow-log-to-cloudwatch"` | no |
585590
| <a name="input_vpc_flow_log_iam_policy_use_name_prefix"></a> [vpc\_flow\_log\_iam\_policy\_use\_name\_prefix](#input\_vpc\_flow\_log\_iam\_policy\_use\_name\_prefix) | Determines whether the name of the IAM policy (`vpc_flow_log_iam_policy_name`) is used as a prefix | `bool` | `true` | no |
586591
| <a name="input_vpc_flow_log_iam_role_name"></a> [vpc\_flow\_log\_iam\_role\_name](#input\_vpc\_flow\_log\_iam\_role\_name) | Name to use on the VPC Flow Log IAM role created | `string` | `"vpc-flow-log-role"` | no |

main.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,36 @@ resource "aws_vpc_ipv4_cidr_block_association" "this" {
5959
cidr_block = element(var.secondary_cidr_blocks, count.index)
6060
}
6161

62+
resource "aws_vpc_block_public_access_options" "this" {
63+
count = var.internet_gateway_block_enabled ? 1 : 0
64+
65+
internet_gateway_block_mode = var.internet_gateway_block_mode
66+
}
67+
68+
resource "aws_vpc_block_public_access_exclusion" "this" {
69+
for_each = var.vpc_block_public_access_exclusions
70+
71+
vpc_id = each.value.exclude_vpc ? local.vpc_id : null
72+
73+
subnet_id = each.value.exclude_subnet ? lookup(
74+
{
75+
private = aws_subnet.private[*].id,
76+
public = aws_subnet.public[*].id,
77+
database = aws_subnet.database[*].id,
78+
redshift = aws_subnet.redshift[*].id,
79+
elasticache = aws_subnet.elasticache[*].id,
80+
intra = aws_subnet.intra[*].id,
81+
outpost = aws_subnet.outpost[*].id
82+
},
83+
each.value.subnet_type,
84+
null
85+
)[each.value.subnet_index] : null
86+
87+
internet_gateway_exclusion_mode = each.value.internet_gateway_exclusion_mode
88+
89+
tags = var.tags
90+
}
91+
6292
################################################################################
6393
# DHCP Options Set
6494
################################################################################

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ variable "tags" {
116116
default = {}
117117
}
118118

119+
variable "internet_gateway_block_enabled" {
120+
description = "Enable AWS VPC Block Public Access Options. Default is `false`"
121+
type = bool
122+
default = false
123+
}
124+
125+
variable "internet_gateway_block_mode" {
126+
description = "Block mode. Needs to be one of `block-bidirectional`, `block-ingress`, `off`. Default is `off`"
127+
type = string
128+
default = "off"
129+
}
130+
131+
variable "vpc_block_public_access_exclusions" {
132+
description = "List of VPC Block Public Access Exclusions"
133+
type = map(any)
134+
default = {}
135+
}
136+
119137
################################################################################
120138
# DHCP Options Set
121139
################################################################################

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.46"
7+
version = ">= 5.79"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)