Skip to content

Commit 5ffe8fc

Browse files
committed
feat: added the ability to configure public access block
1 parent 891e534 commit 5ffe8fc

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
480480
| <a name="input_enable_dns_request_logging"></a> [enable\_dns\_request\_logging](#input\_enable\_dns\_request\_logging) | Enable logging of DNS requests | `bool` | `false` | no |
481481
| <a name="input_enable_dynamodb_endpoint"></a> [enable\_dynamodb\_endpoint](#input\_enable\_dynamodb\_endpoint) | Enable DynamoDB VPC Gateway endpoint | `bool` | `true` | no |
482482
| <a name="input_enable_private_endpoints"></a> [enable\_private\_endpoints](#input\_enable\_private\_endpoints) | Indicates the network should provision private endpoints | `list(string)` | `[]` | no |
483+
| <a name="input_enable_public_access_block"></a> [enable\_public\_access\_block](#input\_enable\_public\_access\_block) | Enable VPC public access block should be enabled | `bool` | `false` | no |
483484
| <a name="input_enable_route53_resolver_rules"></a> [enable\_route53\_resolver\_rules](#input\_enable\_route53\_resolver\_rules) | Automatically associates any shared route53 resolver rules with the VPC | `bool` | `true` | no |
484485
| <a name="input_enable_s3_endpoint"></a> [enable\_s3\_endpoint](#input\_enable\_s3\_endpoint) | Enable S3 VPC Gateway endpoint | `bool` | `true` | no |
485486
| <a name="input_enable_ssm"></a> [enable\_ssm](#input\_enable\_ssm) | Indicates we should provision SSM private endpoints | `bool` | `false` | no |
@@ -492,6 +493,7 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
492493
| <a name="input_nat_gateway_mode"></a> [nat\_gateway\_mode](#input\_nat\_gateway\_mode) | The configuration mode of the NAT gateways | `string` | `"none"` | no |
493494
| <a name="input_private_subnet_netmask"></a> [private\_subnet\_netmask](#input\_private\_subnet\_netmask) | The netmask for the private subnets | `number` | `0` | no |
494495
| <a name="input_private_subnet_tags"></a> [private\_subnet\_tags](#input\_private\_subnet\_tags) | Additional tags for the private subnets | `map(string)` | `{}` | no |
496+
| <a name="input_public_access_block_mode"></a> [public\_access\_block\_mode](#input\_public\_access\_block\_mode) | Indicates the mode for the VPC public access block (i.e allow-egress or allow-bidirectional) | `string` | `"ingress"` | no |
495497
| <a name="input_public_subnet_netmask"></a> [public\_subnet\_netmask](#input\_public\_subnet\_netmask) | The netmask for the public subnets | `number` | `0` | no |
496498
| <a name="input_public_subnet_tags"></a> [public\_subnet\_tags](#input\_public\_subnet\_tags) | Additional tags for the public subnets | `map(string)` | `{}` | no |
497499
| <a name="input_subnets"></a> [subnets](#input\_subnets) | Additional subnets to create in the network, keyed by the subnet name | `any` | `{}` | no |

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ module "nacls" {
3232

3333
depends_on = [module.vpc]
3434
}
35+
36+
## Configure the public access block if required
37+
resource "aws_vpc_block_public_access_exclusion" "public_access" {
38+
count = var.enable_public_access_block ? 1 : 0
39+
40+
vpc_id = module.vpc.vpc_attributes.id
41+
internet_gateway_exclusion_mode = var.public_access_block_mode
42+
}

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ variable "enable_dns_request_logging" {
4040
default = false
4141
}
4242

43+
variable "enable_public_access_block" {
44+
description = "Enable VPC public access block should be enabled"
45+
type = bool
46+
default = false
47+
}
48+
49+
variable "public_access_block_mode" {
50+
description = "Indicates the mode for the VPC public access block (i.e allow-egress or allow-bidirectional)"
51+
type = string
52+
default = "ingress"
53+
}
54+
4355
variable "enable_private_endpoints" {
4456
description = "Indicates the network should provision private endpoints"
4557
type = list(string)

0 commit comments

Comments
 (0)