Skip to content

Commit 26c10f3

Browse files
feat: Add support for security group referencing to transit-gateway module (#133)
Co-authored-by: Anton Babenko <[email protected]>
1 parent 77279c9 commit 26c10f3

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ No modules.
111111
| <a name="input_enable_default_route_table_propagation"></a> [enable\_default\_route\_table\_propagation](#input\_enable\_default\_route\_table\_propagation) | Whether resource attachments automatically propagate routes to the default propagation route table | `bool` | `true` | no |
112112
| <a name="input_enable_dns_support"></a> [enable\_dns\_support](#input\_enable\_dns\_support) | Should be true to enable DNS support in the TGW | `bool` | `true` | no |
113113
| <a name="input_enable_multicast_support"></a> [enable\_multicast\_support](#input\_enable\_multicast\_support) | Whether multicast support is enabled | `bool` | `false` | no |
114+
| <a name="input_enable_sg_referencing_support"></a> [enable\_sg\_referencing\_support](#input\_enable\_sg\_referencing\_support) | Indicates whether to enable security group referencing support | `bool` | `true` | no |
114115
| <a name="input_enable_vpn_ecmp_support"></a> [enable\_vpn\_ecmp\_support](#input\_enable\_vpn\_ecmp\_support) | Whether VPN Equal Cost Multipath Protocol support is enabled | `bool` | `true` | no |
115116
| <a name="input_name"></a> [name](#input\_name) | Name to be used on all the resources as identifier | `string` | `""` | no |
116117
| <a name="input_ram_allow_external_principals"></a> [ram\_allow\_external\_principals](#input\_ram\_allow\_external\_principals) | Indicates whether principals outside your organization can be associated with a resource share. | `bool` | `false` | no |

examples/complete/main.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ module "tgw" {
2929
# When "true" there is no need for RAM resources if using multiple AWS accounts
3030
enable_auto_accept_shared_attachments = true
3131

32+
# When "true", SG referencing support is enabled at the Transit Gateway level
33+
enable_sg_referencing_support = true
34+
3235
# When "true", allows service discovery through IGMP
3336
enable_multicast_support = false
3437

3538
vpc_attachments = {
3639
vpc1 = {
37-
vpc_id = module.vpc1.vpc_id
38-
subnet_ids = module.vpc1.private_subnets
39-
dns_support = true
40-
ipv6_support = true
40+
vpc_id = module.vpc1.vpc_id
41+
subnet_ids = module.vpc1.private_subnets
42+
security_group_referencing_support = true
43+
dns_support = true
44+
ipv6_support = true
4145

4246
transit_gateway_default_route_table_association = false
4347
transit_gateway_default_route_table_propagation = false

main.tf

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ locals {
2828
resource "aws_ec2_transit_gateway" "this" {
2929
count = var.create_tgw ? 1 : 0
3030

31-
description = coalesce(var.description, var.name)
32-
amazon_side_asn = var.amazon_side_asn
33-
default_route_table_association = var.enable_default_route_table_association ? "enable" : "disable"
34-
default_route_table_propagation = var.enable_default_route_table_propagation ? "enable" : "disable"
35-
auto_accept_shared_attachments = var.enable_auto_accept_shared_attachments ? "enable" : "disable"
36-
multicast_support = var.enable_multicast_support ? "enable" : "disable"
37-
vpn_ecmp_support = var.enable_vpn_ecmp_support ? "enable" : "disable"
38-
dns_support = var.enable_dns_support ? "enable" : "disable"
39-
transit_gateway_cidr_blocks = var.transit_gateway_cidr_blocks
31+
description = coalesce(var.description, var.name)
32+
amazon_side_asn = var.amazon_side_asn
33+
default_route_table_association = var.enable_default_route_table_association ? "enable" : "disable"
34+
default_route_table_propagation = var.enable_default_route_table_propagation ? "enable" : "disable"
35+
auto_accept_shared_attachments = var.enable_auto_accept_shared_attachments ? "enable" : "disable"
36+
multicast_support = var.enable_multicast_support ? "enable" : "disable"
37+
vpn_ecmp_support = var.enable_vpn_ecmp_support ? "enable" : "disable"
38+
dns_support = var.enable_dns_support ? "enable" : "disable"
39+
transit_gateway_cidr_blocks = var.transit_gateway_cidr_blocks
40+
security_group_referencing_support = var.enable_sg_referencing_support ? "enable" : "disable"
4041

4142
timeouts {
4243
create = try(var.timeouts.create, null)
@@ -73,6 +74,7 @@ resource "aws_ec2_transit_gateway_vpc_attachment" "this" {
7374
dns_support = try(each.value.dns_support, true) ? "enable" : "disable"
7475
ipv6_support = try(each.value.ipv6_support, false) ? "enable" : "disable"
7576
appliance_mode_support = try(each.value.appliance_mode_support, false) ? "enable" : "disable"
77+
security_group_referencing_support = try(each.value.security_group_referencing_support, false) ? "enable" : "disable"
7678
transit_gateway_default_route_table_association = try(each.value.transit_gateway_default_route_table_association, true)
7779
transit_gateway_default_route_table_propagation = try(each.value.transit_gateway_default_route_table_propagation, true)
7880

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ variable "tgw_default_route_table_tags" {
9292
default = {}
9393
}
9494

95+
variable "enable_sg_referencing_support" {
96+
description = "Indicates whether to enable security group referencing support"
97+
type = bool
98+
default = true
99+
}
100+
95101
################################################################################
96102
# VPC Attachment
97103
################################################################################

0 commit comments

Comments
 (0)