Skip to content

Commit ee03be5

Browse files
authored
Merge pull request #74 from aws-ia/b-rm-unecessary-outputs
rm unecessary outputs
2 parents 4a65b30 + 8f158b1 commit ee03be5

File tree

9 files changed

+33
-53
lines changed

9 files changed

+33
-53
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ minimum_pre_commit_version: "2.6.0"
55

66
repos:
77
- repo: https://github.com/aws-ia/pre-commit-configs
8-
rev: 82b2dd4f3c3c8b064ce15c7cc518e14c43f6a068 # frozen: v1.4.1
8+
# To update run:
9+
# pre-commit autoupdate --freeze
10+
rev: 0733cc52fa0fc8809c727fee4fccb324ceb994d0 # frozen: v1.6.0
911
hooks:
1012
- id: aws-ia-meta-hook

.tflint.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
plugin "aws" {
55
enabled = true
6-
version = "0.14.0"
6+
version = "0.15.0"
77
source = "github.com/terraform-linters/tflint-ruleset-aws"
88
}
99

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,8 @@ Please see our [developer documentation](https://github.com/aws-ia/terraform-aws
255255
| <a name="output_nat_gateway_attributes_by_az"></a> [nat\_gateway\_attributes\_by\_az](#output\_nat\_gateway\_attributes\_by\_az) | Map of nat gateway resource attributes by AZ.<br><br>Example:<pre>nat_gateway_attributes_by_az = {<br> "us-east-1a" = {<br> "allocation_id" = "eipalloc-0e8b20303eea88b13"<br> "connectivity_type" = "public"<br> "id" = "nat-0fde39f9550f4abb5"<br> "network_interface_id" = "eni-0d422727088bf9a86"<br> "private_ip" = "10.0.3.40"<br> "public_ip" = <><br> "subnet_id" = "subnet-0f11c92e439c8ab4a"<br> "tags" = tomap({<br> "Name" = "nat-my-public-us-east-1a"<br> })<br> "tags_all" = tomap({<br> "Name" = "nat-my-public-us-east-1a"<br> })<br> }<br> "us-east-1b" = { ... }<br>}</pre> |
256256
| <a name="output_private_subnet_attributes_by_az"></a> [private\_subnet\_attributes\_by\_az](#output\_private\_subnet\_attributes\_by\_az) | Map of all private subnets containing their attributes.<br><br>Example:<pre>private_subnet_attributes = {<br> "private/us-east-1a" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-04a86315c4839b519"<br> "assign_ipv6_address_on_creation" = false<br> ...<br> <all attributes of subnet: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#attributes-reference><br> }<br> "us-east-1b" = {...)<br>}</pre> |
257257
| <a name="output_public_subnet_attributes_by_az"></a> [public\_subnet\_attributes\_by\_az](#output\_public\_subnet\_attributes\_by\_az) | Map of all public subnets containing their attributes.<br><br>Example:<pre>public_subnet_attributes = {<br> "us-east-1a" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-04a86315c4839b519"<br> "assign_ipv6_address_on_creation" = false<br> ...<br> <all attributes of subnet: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#attributes-reference><br> }<br> "us-east-1b" = {...)<br>}</pre> |
258-
| <a name="output_public_subnet_cidrs_by_az"></a> [public\_subnet\_cidrs\_by\_az](#output\_public\_subnet\_cidrs\_by\_az) | Map of public subnet resource attributes grouped by AZ.<br><br>Example:<pre>public_subnets = {<br> "us-east-1a" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-028d7f65ccc12ff98"<br> "vpc_id" = "vpc-05601d7778af1ba9c"<br> ...<br> }<br> "us-east-1b" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-0091597b2b4c78dda"<br> ...<br> }</pre> |
259258
| <a name="output_rt_attributes_by_type_by_az"></a> [rt\_attributes\_by\_type\_by\_az](#output\_rt\_attributes\_by\_type\_by\_az) | Map of route tables by type => az => route table attributes. Example usage: module.vpc.route\_table\_by\_subnet\_type.private.id<br><br>Example:<pre>route_table_attributes_by_type_by_az = {<br> "private" = {<br> "us-east-1a" = {<br> "id" = "rtb-0e77040c0598df003"<br> "route_table_id" = "rtb-0e77040c0598df003"<br> "tags" = tolist([<br> {<br> "key" = "Name"<br> "value" = "private-us-east-1a"<br> },<br> ])<br> "vpc_id" = "vpc-033e054f49409592a"<br> }<br> "us-east-1b" = { ... }<br> "public" = { ... }</pre> |
260259
| <a name="output_tgw_subnet_attributes_by_az"></a> [tgw\_subnet\_attributes\_by\_az](#output\_tgw\_subnet\_attributes\_by\_az) | Map of all tgw subnets containing their attributes.<br><br>Example:<pre>tgw_subnet_attributes = {<br> "us-east-1a" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-04a86315c4839b519"<br> "assign_ipv6_address_on_creation" = false<br> ...<br> <all attributes of subnet: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#attributes-reference><br> }<br> "us-east-1b" = {...)<br>}</pre> |
261-
| <a name="output_tgw_subnet_cidrs_by_az"></a> [tgw\_subnet\_cidrs\_by\_az](#output\_tgw\_subnet\_cidrs\_by\_az) | Map of transit gateway subnet resource attributes grouped by AZ.<br><br>Example:<pre>tgw_subnets = {<br> "us-east-1a" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-028d7f65ccc12ff98"<br> "vpc_id" = "vpc-05601d7778af1ba9c"<br> ...<br> }<br> "us-east-1b" = {<br> "arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-0091597b2b4c78dda"<br> ...<br> }</pre> |
262260
| <a name="output_transit_gateway_attachment_id"></a> [transit\_gateway\_attachment\_id](#output\_transit\_gateway\_attachment\_id) | Transit gateway attachment id. |
263261
| <a name="output_vpc_attributes"></a> [vpc\_attributes](#output\_vpc\_attributes) | VPC resource attributes. Full output of aws\_vpc. |
264262
<!-- END_TF_DOCS -->

data.tf

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@ locals {
33

44
# references to module.calculate_subnets output
55
calculated_subnets = module.calculate_subnets.subnets_by_type
6-
subnet_keys = keys(var.subnets)
76

8-
# default names if no name_prefix is passed
7+
##################################################################
8+
# Subnet names
9+
# A subnet's name is the subnet key by default but can be overrided by `name_prefix`.
10+
# Subnet names are used for Name tags.
11+
# resource name labels always use subnet key
12+
subnet_keys = keys(var.subnets)
913
subnet_names = { for type, v in var.subnets : type => try(v.name_prefix, type) }
1014

15+
##################################################################
16+
# Internal variables for mapping user input from var.subnets to HCL useful values
17+
# Notes:
18+
# - subnets map contains arbitrary amount of subnet "keys" which are both defined as the subnets type and default name (unless name_prefix is provided).
19+
# - resource name labels for subnet use the key as private subnet keys are constructed
20+
1121
singleton_subnet_types = ["public", "transit_gateway"]
1222
private_subnet_names = setsubtract(local.subnet_keys, local.singleton_subnet_types)
1323

@@ -21,7 +31,8 @@ locals {
2131
private_subnets_tgw_routed = [for type in local.private_subnet_names : type if can(var.subnets[type].route_to_transit_gateway)]
2232
private_subnet_key_names_tgw_routed = [for subnet in local.private_per_az : subnet if contains(local.private_subnets_tgw_routed, split("/", subnet)[0])]
2333

24-
# NAT configurations options, selected based on nat_gateway_configuration
34+
##################################################################
35+
# NAT configurations options, maps user string input to HCL usable values. selected based on nat_gateway_configuration
2536
# null = none
2637
# all = local.azs
2738
# single = local.azs[0]
@@ -34,6 +45,13 @@ locals {
3445
# options defined by `local.nat_options`
3546
nat_configuration = contains(local.subnet_keys, "public") ? local.nat_options[try(var.subnets.public.nat_gateway_configuration, "none")] : local.nat_options["none"]
3647

48+
49+
##################################################################
50+
# Feature toggles for whether:
51+
# - create or reference a VPC
52+
# - get cidr block value from AWS IPAM
53+
# - create flow logs
54+
3755
# # if var.vpc_id is passed, assume create = `false` and cidr comes from data.aws_vpc
3856
create_vpc = var.vpc_id == null ? true : false
3957
vpc = local.create_vpc ? aws_vpc.main[0] : data.awscc_ec2_vpc.main[0]

examples/ipam/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ output "public_subnets" {
55

66
output "private_subnets" {
77
description = "Map of private subnet attributes grouped by az."
8-
value = module.vpc.private_subnet_cidrs_by_az
8+
value = module.vpc.private_subnet_attributes_by_az
99
}

examples/public_private_flow_logs/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module "vpc" {
44

55
name = "multi-az-vpc"
66
cidr_block = "10.0.0.0/20"
7-
az_count = 3
7+
az_count = 2
88

99
subnets = {
1010
public = {
@@ -26,4 +26,8 @@ module "vpc" {
2626
retention_in_days = 180
2727
kms_key_id = var.kms_key_id
2828
}
29+
30+
tags = {
31+
"key" = "value"
32+
}
2933
}

examples/public_private_flow_logs/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ output "public_subnets" {
55

66
output "private_subnets" {
77
description = "Map of private subnet attributes grouped by az."
8-
value = module.vpc.private_subnet_cidrs_by_az
8+
value = module.vpc.private_subnet_attributes_by_az
99
}

examples/secondary_cidr/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ output "public_subnets" {
55

66
output "private_subnets" {
77
description = "Map of private subnet attributes grouped by az."
8-
value = module.secondary.private_subnet_cidrs_by_az
8+
value = module.secondary.private_subnet_attributes_by_az
99
}

outputs.tf

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,6 @@ output "vpc_attributes" {
33
value = local.vpc
44
}
55

6-
output "public_subnet_cidrs_by_az" {
7-
value = try(aws_subnet.public, null)
8-
description = <<-EOF
9-
Map of public subnet resource attributes grouped by AZ.
10-
11-
Example:
12-
```
13-
public_subnets = {
14-
"us-east-1a" = {
15-
"arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-028d7f65ccc12ff98"
16-
"vpc_id" = "vpc-05601d7778af1ba9c"
17-
...
18-
}
19-
"us-east-1b" = {
20-
"arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-0091597b2b4c78dda"
21-
...
22-
}
23-
```
24-
EOF
25-
}
26-
27-
output "tgw_subnet_cidrs_by_az" {
28-
value = try(aws_subnet.tgw, null)
29-
description = <<-EOF
30-
Map of transit gateway subnet resource attributes grouped by AZ.
31-
32-
Example:
33-
```
34-
tgw_subnets = {
35-
"us-east-1a" = {
36-
"arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-028d7f65ccc12ff98"
37-
"vpc_id" = "vpc-05601d7778af1ba9c"
38-
...
39-
}
40-
"us-east-1b" = {
41-
"arn" = "arn:aws:ec2:us-east-1:<>:subnet/subnet-0091597b2b4c78dda"
42-
...
43-
}
44-
```
45-
EOF
46-
}
47-
486
output "transit_gateway_attachment_id" {
497
description = "Transit gateway attachment id."
508
value = try(aws_ec2_transit_gateway_vpc_attachment.tgw[0].id, null)

0 commit comments

Comments
 (0)