@@ -430,6 +430,67 @@ resource "aws_security_group_rule" "computed_ingress_with_self" {
430430 var. rules [lookup (var. computed_ingress_with_self [count . index ], " rule" , " _" )][2 ],
431431 )
432432}
433+ # Security group rules with "prefix_list_ids", but without "cidr_blocks", "self" or "source_security_group_id"
434+ resource "aws_security_group_rule" "ingress_with_prefix_list_ids" {
435+ count = var. create ? length (var. ingress_with_prefix_list_ids ) : 0
436+
437+ security_group_id = local. this_sg_id
438+ type = " ingress"
439+
440+ prefix_list_ids = var. ingress_prefix_list_ids
441+ description = lookup (
442+ var. ingress_with_prefix_list_ids [count . index ],
443+ " description" ,
444+ " Ingress Rule" ,
445+ )
446+
447+ from_port = lookup (
448+ var. ingress_with_prefix_list_ids [count . index ],
449+ " from_port" ,
450+ var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][0 ],
451+ )
452+ to_port = lookup (
453+ var. ingress_with_prefix_list_ids [count . index ],
454+ " to_port" ,
455+ var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][1 ],
456+ )
457+ protocol = lookup (
458+ var. ingress_with_prefix_list_ids [count . index ],
459+ " protocol" ,
460+ var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][2 ],
461+ )
462+ }
463+
464+ # Computed - Security group rules with "prefix_list_ids", but without "cidr_blocks", "self" or "source_security_group_id"
465+ resource "aws_security_group_rule" "computed_ingress_with_prefix_list_ids" {
466+ count = var. create ? var. number_of_computed_ingress_with_prefix_list_ids : 0
467+
468+ security_group_id = local. this_sg_id
469+ type = " ingress"
470+
471+ prefix_list_ids = var. ingress_prefix_list_ids
472+ description = lookup (
473+ var. ingress_with_prefix_list_ids [count . index ],
474+ " description" ,
475+ " Ingress Rule" ,
476+ )
477+
478+ from_port = lookup (
479+ var. ingress_with_prefix_list_ids [count . index ],
480+ " from_port" ,
481+ var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][0 ],
482+ )
483+ to_port = lookup (
484+ var. ingress_with_prefix_list_ids [count . index ],
485+ " to_port" ,
486+ var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][1 ],
487+ )
488+ protocol = lookup (
489+ var. ingress_with_prefix_list_ids [count . index ],
490+ " protocol" ,
491+ var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][2 ],
492+ )
493+ }
433494
434495# ################
435496# End of ingress
@@ -807,6 +868,93 @@ resource "aws_security_group_rule" "computed_egress_with_self" {
807868 )
808869}
809870
871+ # Security group rules with "egress_prefix_list_ids", but without "cidr_blocks", "self" or "source_security_group_id"
872+ resource "aws_security_group_rule" "egress_with_prefix_list_ids" {
873+ count = var. create ? length (var. egress_with_prefix_list_ids ) : 0
874+
875+ security_group_id = local. this_sg_id
876+ type = " egress"
877+
878+ prefix_list_ids = var. egress_prefix_list_ids
879+ description = lookup (
880+ var. egress_with_prefix_list_ids [count . index ],
881+ " description" ,
882+ " Egress Rule" ,
883+ )
884+
885+ from_port = lookup (
886+ var. egress_with_prefix_list_ids [count . index ],
887+ " from_port" ,
888+ var. rules [lookup (
889+ var. egress_with_prefix_list_ids [count . index ],
890+ " rule" ,
891+ " _" ,
892+ )][0 ],
893+ )
894+ to_port = lookup (
895+ var. egress_with_prefix_list_ids [count . index ],
896+ " to_port" ,
897+ var. rules [lookup (
898+ var. egress_with_prefix_list_ids [count . index ],
899+ " rule" ,
900+ " _" ,
901+ )][1 ],
902+ )
903+ protocol = lookup (
904+ var. egress_with_prefix_list_ids [count . index ],
905+ " protocol" ,
906+ var. rules [lookup (
907+ var. egress_with_prefix_list_ids [count . index ],
908+ " rule" ,
909+ " _" ,
910+ )][2 ],
911+ )
912+ }
913+
914+ # Computed - Security group rules with "source_security_group_id", but without "cidr_blocks", "self" or "source_security_group_id"
915+ resource "aws_security_group_rule" "computed_egress_with_prefix_list_ids" {
916+ count = var. create ? var. number_of_computed_egress_with_prefix_list_ids : 0
917+
918+ security_group_id = local. this_sg_id
919+ type = " egress"
920+
921+ source_security_group_id = var. computed_egress_with_prefix_list_ids [count . index ][" source_security_group_id" ]
922+ prefix_list_ids = var. egress_prefix_list_ids
923+ description = lookup (
924+ var. computed_egress_with_prefix_list_ids [count . index ],
925+ " description" ,
926+ " Egress Rule" ,
927+ )
928+
929+ from_port = lookup (
930+ var. computed_egress_with_prefix_list_ids [count . index ],
931+ " from_port" ,
932+ var. rules [lookup (
933+ var. computed_egress_with_prefix_list_ids [count . index ],
934+ " rule" ,
935+ " _" ,
936+ )][0 ],
937+ )
938+ to_port = lookup (
939+ var. computed_egress_with_prefix_list_ids [count . index ],
940+ " to_port" ,
941+ var. rules [lookup (
942+ var. computed_egress_with_prefix_list_ids [count . index ],
943+ " rule" ,
944+ " _" ,
945+ )][1 ],
946+ )
947+ protocol = lookup (
948+ var. computed_egress_with_prefix_list_ids [count . index ],
949+ " protocol" ,
950+ var. rules [lookup (
951+ var. computed_egress_with_prefix_list_ids [count . index ],
952+ " rule" ,
953+ " _" ,
954+ )][2 ],
955+ )
956+ }
957+
810958# ###############
811959# End of egress
812960# ###############
0 commit comments