You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add variables for network ACLs
Add variables for specifying network ACLs for public, private, and
intra subnets. The ACLs are defined in a list, with sets of seven
elements for the rule number, rule action, from port, to port,
protocol, and cidr block.
* Add variables for network ACL tags
Add variables to specify additional tags for public, private, and intra
network ACL resources.
* Add resources for network ACLs
Add aws_network_acl and aws_network_acl_rule resources to specify
inbound and outbound network ACL rules for public, private, and intra
subnets.
* Add resource for default network ACL
Add a aws_default_network_acl resource to adopt the default network ACL
in the VPC.
* Adjust spacing to match code style
Remove the empty lines after comment blocks for network ACLs to match
the style of the rest of this module.
* Copy simple-vpc example as network-acls
Copy the simple-vpc example and adapt it to demonstrate the
configuration of network ACLs. A set of inbound and outbound ACLs are
specified in main.tf.
* Rename variables from _acls to _acl_rules
Clarify the variables for specifying ACL rules by renaming them from
*_acls to *_acl_rules. The values are used to create rules, not create
ACLs.
* Add nacl resources and variables for other subnets
Add aws_network_acl and aws_network_acl_rule resources for database,
redshift, and elasticache subnets, along with corresponding variables.
This provides network ACL coverage to all subnet types produced by this
module.
* Create ACLs only if there are subnets
For each subnet type, only create ACL resources if there are subnets
defined. For example, if database_subnets is empty, then don't create
ACL resources for database subnets.
* Add missing variables for ACL tags
Add the missing variable declarations for database_acl_tags,
redshift_acl_tags, and elasticache_acl_tags.
* Make ACL singular in description for _acl_tags
A single ACL is created for each of the subnet types. Update the
variable descriptions to reflect this.
* Convert rules to nested list of maps
Convert the NACL rule specifications from a list of lists to a list of
maps, as suggested by @jczerniak. This improves the readability of
rules.
* Restructure example config to use locals
Restructure the network ACL rules in the network-acls example to use
local variables to specify the rules, split between default and custom
rules.
* Follow-up for #174
Sponsored by [Cloudcraft - the best way to draw AWS diagrams](https://cloudcraft.co/?utm_source=terraform-aws-vpc)
26
28
@@ -165,6 +167,14 @@ Sometimes it is handy to have public access to RDS instances (it is not recommen
165
167
enable_dns_support = true
166
168
```
167
169
170
+
## Network Access Control Lists (ACL or NACL)
171
+
172
+
This module can manage network ACL and rules. Once VPC is created, AWS creates the default network ACL, which can be controlled using this module (`manage_default_network_acl = true`).
173
+
174
+
Also, each type of subnet may have its own network ACL with custom rules per subnet. Eg, set `public_dedicated_network_acl = true` to use dedicated network ACL for the public subnets; set values of `public_inbound_acl_rules` and `public_outbound_acl_rules` to specify all the NACL rules you need to have on public subnets (see `variables.tf` for default values and structures).
175
+
176
+
By default, all subnets are associated with the default network ACL.
177
+
168
178
## Public access to Redshift cluster
169
179
170
180
Sometimes it is handy to have public access to Redshift clusters (for example if you need to access it by Kinesis - VPC endpoint for Kinesis is not yet supported by Redshift) by specifying these arguments:
@@ -182,6 +192,7 @@ Terraform version 0.10.3 or newer is required for this module to work.
* Few tests and edge cases examples: [#46](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-46-no-private-subnets), [#44](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-44-asymmetric-private-subnets), [#108](https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/examples/issue-108-route-already-exists)
186
197
187
198
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -205,11 +216,19 @@ Terraform version 0.10.3 or newer is required for this module to work.
205
216
| create\_redshift\_subnet\_group | Controls if redshift subnet group should be created | string |`"true"`| no |
206
217
| create\_redshift\_subnet\_route\_table | Controls if separate route table for redshift should be created | string |`"false"`| no |
207
218
| create\_vpc | Controls if VPC should be created (it affects almost all resources) | string |`"true"`| no |
219
+
| database\_acl\_tags | Additional tags for the database subnets network ACL | map |`{}`| no |
220
+
| database\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for database subnets | string |`"false"`| no |
| database\_route\_table\_tags | Additional tags for the database route tables | map |`{}`| no |
209
224
| database\_subnet\_group\_tags | Additional tags for the database subnet group | map |`{}`| no |
210
225
| database\_subnet\_suffix | Suffix to append to database subnets name | string |`"db"`| no |
211
226
| database\_subnet\_tags | Additional tags for the database subnets | map |`{}`| no |
212
227
| database\_subnets | A list of database subnets | list |`[]`| no |
228
+
| default\_network\_acl\_egress | List of maps of egress rules to set on the Default Network ACL | list |`[ { "action": "allow", "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_no": 100, "to_port": 0 }, { "action": "allow", "from_port": 0, "ipv6_cidr_block": "::/0", "protocol": "-1", "rule_no": 101, "to_port": 0 } ]`| no |
229
+
| default\_network\_acl\_ingress | List of maps of ingress rules to set on the Default Network ACL | list |`[ { "action": "allow", "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_no": 100, "to_port": 0 }, { "action": "allow", "from_port": 0, "ipv6_cidr_block": "::/0", "protocol": "-1", "rule_no": 101, "to_port": 0 } ]`| no |
230
+
| default\_network\_acl\_name | Name to be used on the Default Network ACL | string |`""`| no |
231
+
| default\_network\_acl\_tags | Additional tags for the Default Network ACL | map |`{}`| no |
213
232
| default\_vpc\_enable\_classiclink | Should be true to enable ClassicLink in the Default VPC | string |`"false"`| no |
214
233
| default\_vpc\_enable\_dns\_hostnames | Should be true to enable DNS hostnames in the Default VPC | string |`"false"`| no |
215
234
| default\_vpc\_enable\_dns\_support | Should be true to enable DNS support in the Default VPC | string |`"true"`| no |
@@ -233,6 +252,10 @@ Terraform version 0.10.3 or newer is required for this module to work.
233
252
| ecr\_dkr\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for ECR DKR endpoint | string |`"false"`| no |
234
253
| ecr\_dkr\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for ECR DKR endpoint | list |`[]`| no |
235
254
| ecr\_dkr\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for ECR dkr endpoint. If omitted, private subnets will be used. | list |`[]`| no |
255
+
| elasticache\_acl\_tags | Additional tags for the elasticache subnets network ACL | map |`{}`| no |
256
+
| elasticache\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for elasticache subnets | string |`"false"`| no |
| elasticache\_route\_table\_tags | Additional tags for the elasticache route tables | map |`{}`| no |
237
260
| elasticache\_subnet\_suffix | Suffix to append to elasticache subnets name | string |`"elasticache"`| no |
238
261
| elasticache\_subnet\_tags | Additional tags for the elasticache subnets | map |`{}`| no |
@@ -255,26 +278,43 @@ Terraform version 0.10.3 or newer is required for this module to work.
255
278
| external\_nat\_ip\_ids | List of EIP IDs to be assigned to the NAT Gateways (used in combination with reuse_nat_ips) | list |`[]`| no |
256
279
| igw\_tags | Additional tags for the internet gateway | map |`{}`| no |
257
280
| instance\_tenancy | A tenancy option for instances launched into the VPC | string |`"default"`| no |
281
+
| intra\_acl\_tags | Additional tags for the intra subnets network ACL | map |`{}`| no |
282
+
| intra\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for intra subnets | string |`"false"`| no |
283
+
| intra\_inbound\_acl\_rules | Intra subnets inbound network ACLs | list |`[ { "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_action": "allow", "rule_number": 100, "to_port": 0 } ]`| no |
284
+
| intra\_outbound\_acl\_rules | Intra subnets outbound network ACLs | list |`[ { "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_action": "allow", "rule_number": 100, "to_port": 0 } ]`| no |
258
285
| intra\_route\_table\_tags | Additional tags for the intra route tables | map |`{}`| no |
259
286
| intra\_subnet\_suffix | Suffix to append to intra subnets name | string |`"intra"`| no |
260
287
| intra\_subnet\_tags | Additional tags for the intra subnets | map |`{}`| no |
261
288
| intra\_subnets | A list of intra subnets | list |`[]`| no |
289
+
| manage\_default\_network\_acl | Should be true to adopt and manage Default Network ACL | string |`"false"`| no |
262
290
| manage\_default\_vpc | Should be true to adopt and manage Default VPC | string |`"false"`| no |
263
291
| map\_public\_ip\_on\_launch | Should be false if you do not want to auto-assign public IP on launch | string |`"true"`| no |
264
292
| name | Name to be used on all the resources as identifier | string |`""`| no |
265
293
| nat\_eip\_tags | Additional tags for the NAT EIP | map |`{}`| no |
266
294
| nat\_gateway\_tags | Additional tags for the NAT gateways | map |`{}`| no |
267
295
| one\_nat\_gateway\_per\_az | Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs`. | string |`"false"`| no |
296
+
| private\_acl\_tags | Additional tags for the private subnets network ACL | map |`{}`| no |
297
+
| private\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for private subnets | string |`"false"`| no |
| private\_route\_table\_tags | Additional tags for the private route tables | map |`{}`| no |
269
301
| private\_subnet\_suffix | Suffix to append to private subnets name | string |`"private"`| no |
270
302
| private\_subnet\_tags | Additional tags for the private subnets | map |`{}`| no |
271
303
| private\_subnets | A list of private subnets inside the VPC | list |`[]`| no |
272
304
| propagate\_private\_route\_tables\_vgw | Should be true if you want route table propagation | string |`"false"`| no |
273
305
| propagate\_public\_route\_tables\_vgw | Should be true if you want route table propagation | string |`"false"`| no |
306
+
| public\_acl\_tags | Additional tags for the public subnets network ACL | map |`{}`| no |
307
+
| public\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for public subnets | string |`"false"`| no |
308
+
| public\_inbound\_acl\_rules | Public subnets inbound network ACLs | list |`[ { "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_action": "allow", "rule_number": 100, "to_port": 0 } ]`| no |
309
+
| public\_outbound\_acl\_rules | Public subnets outbound network ACLs | list |`[ { "cidr_block": "0.0.0.0/0", "from_port": 0, "protocol": "-1", "rule_action": "allow", "rule_number": 100, "to_port": 0 } ]`| no |
274
310
| public\_route\_table\_tags | Additional tags for the public route tables | map |`{}`| no |
275
311
| public\_subnet\_suffix | Suffix to append to public subnets name | string |`"public"`| no |
276
312
| public\_subnet\_tags | Additional tags for the public subnets | map |`{}`| no |
277
313
| public\_subnets | A list of public subnets inside the VPC | list |`[]`| no |
314
+
| redshift\_acl\_tags | Additional tags for the redshift subnets network ACL | map |`{}`| no |
315
+
| redshift\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for redshift subnets | string |`"false"`| no |
Configuration in this directory creates set of VPC resources along with network ACLs for public subnets.
4
+
5
+
There is a public and private subnet created per availability zone in addition to single NAT Gateway shared between all 3 availability zones.
6
+
7
+
Network ACL rules for inbound and outbound traffic are defined as the following:
8
+
1. Public subnets will have network ACL rules provided
9
+
1. Private subnets will be associated with the default network ACL rules (IPV4-only ingress and egress is open for all)
10
+
1. Elasticache subnets will use the default network ACL (created and managed by AWS)
11
+
12
+
## Usage
13
+
14
+
To run this example you need to execute:
15
+
16
+
```bash
17
+
$ terraform init
18
+
$ terraform plan
19
+
$ terraform apply
20
+
```
21
+
22
+
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
23
+
24
+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
25
+
## Outputs
26
+
27
+
| Name | Description |
28
+
|------|-------------|
29
+
| default\_network\_acl\_id | The ID of the default network ACL |
30
+
| elasticache\_network\_acl\_id | ID of the elasticache network ACL |
31
+
| nat\_public\_ips | List of public Elastic IPs created for AWS NAT Gateway |
32
+
| private\_network\_acl\_id | ID of the private network ACL |
33
+
| private\_subnets | List of IDs of private subnets |
34
+
| public\_network\_acl\_id | ID of the public network ACL |
35
+
| public\_subnets | List of IDs of public subnets |
0 commit comments