@@ -202,7 +202,7 @@ resource "aws_security_group_rule" "ingress_with_cidr_blocks" {
202
202
join (" ," , var. ingress_cidr_blocks ),
203
203
),
204
204
))
205
- prefix_list_ids = var . ingress_prefix_list_ids
205
+
206
206
description = lookup (
207
207
var. ingress_with_cidr_blocks [count . index ],
208
208
" description" ,
@@ -214,11 +214,13 @@ resource "aws_security_group_rule" "ingress_with_cidr_blocks" {
214
214
" from_port" ,
215
215
var. rules [lookup (var. ingress_with_cidr_blocks [count . index ], " rule" , " _" )][0 ],
216
216
)
217
+
217
218
to_port = lookup (
218
219
var. ingress_with_cidr_blocks [count . index ],
219
220
" to_port" ,
220
221
var. rules [lookup (var. ingress_with_cidr_blocks [count . index ], " rule" , " _" )][1 ],
221
222
)
223
+
222
224
protocol = lookup (
223
225
var. ingress_with_cidr_blocks [count . index ],
224
226
" protocol" ,
@@ -241,7 +243,7 @@ resource "aws_security_group_rule" "computed_ingress_with_cidr_blocks" {
241
243
join (" ," , var. ingress_cidr_blocks ),
242
244
),
243
245
))
244
- prefix_list_ids = var . ingress_prefix_list_ids
246
+
245
247
description = lookup (
246
248
var. computed_ingress_with_cidr_blocks [count . index ],
247
249
" description" ,
@@ -257,6 +259,7 @@ resource "aws_security_group_rule" "computed_ingress_with_cidr_blocks" {
257
259
" _" ,
258
260
)][0 ],
259
261
)
262
+
260
263
to_port = lookup (
261
264
var. computed_ingress_with_cidr_blocks [count . index ],
262
265
" to_port" ,
@@ -266,6 +269,7 @@ resource "aws_security_group_rule" "computed_ingress_with_cidr_blocks" {
266
269
" _" ,
267
270
)][1 ],
268
271
)
272
+
269
273
protocol = lookup (
270
274
var. computed_ingress_with_cidr_blocks [count . index ],
271
275
" protocol" ,
@@ -437,7 +441,15 @@ resource "aws_security_group_rule" "ingress_with_prefix_list_ids" {
437
441
security_group_id = local. this_sg_id
438
442
type = " ingress"
439
443
440
- prefix_list_ids = var. ingress_prefix_list_ids
444
+ prefix_list_ids = compact (split (
445
+ " ," ,
446
+ lookup (
447
+ var. ingress_with_prefix_list_ids [count . index ],
448
+ " prefix_list_ids" ,
449
+ join (" ," , var. ingress_prefix_list_ids )
450
+ )
451
+ ))
452
+
441
453
description = lookup (
442
454
var. ingress_with_prefix_list_ids [count . index ],
443
455
" description" ,
@@ -449,11 +461,13 @@ resource "aws_security_group_rule" "ingress_with_prefix_list_ids" {
449
461
" from_port" ,
450
462
var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][0 ],
451
463
)
464
+
452
465
to_port = lookup (
453
466
var. ingress_with_prefix_list_ids [count . index ],
454
467
" to_port" ,
455
468
var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][1 ],
456
469
)
470
+
457
471
protocol = lookup (
458
472
var. ingress_with_prefix_list_ids [count . index ],
459
473
" protocol" ,
@@ -468,7 +482,15 @@ resource "aws_security_group_rule" "computed_ingress_with_prefix_list_ids" {
468
482
security_group_id = local. this_sg_id
469
483
type = " ingress"
470
484
471
- prefix_list_ids = var. ingress_prefix_list_ids
485
+ prefix_list_ids = compact (split (
486
+ " ," ,
487
+ lookup (
488
+ var. ingress_with_prefix_list_ids [count . index ],
489
+ " prefix_list_ids" ,
490
+ join (" ," , var. ingress_prefix_list_ids )
491
+ )
492
+ ))
493
+
472
494
description = lookup (
473
495
var. ingress_with_prefix_list_ids [count . index ],
474
496
" description" ,
@@ -480,11 +502,13 @@ resource "aws_security_group_rule" "computed_ingress_with_prefix_list_ids" {
480
502
" from_port" ,
481
503
var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][0 ],
482
504
)
505
+
483
506
to_port = lookup (
484
507
var. ingress_with_prefix_list_ids [count . index ],
485
508
" to_port" ,
486
509
var. rules [lookup (var. ingress_with_prefix_list_ids [count . index ], " rule" , " _" )][1 ],
487
510
)
511
+
488
512
protocol = lookup (
489
513
var. ingress_with_prefix_list_ids [count . index ],
490
514
" protocol" ,
@@ -639,7 +663,7 @@ resource "aws_security_group_rule" "egress_with_cidr_blocks" {
639
663
join (" ," , var. egress_cidr_blocks ),
640
664
),
641
665
))
642
- prefix_list_ids = var . egress_prefix_list_ids
666
+
643
667
description = lookup (
644
668
var. egress_with_cidr_blocks [count . index ],
645
669
" description" ,
@@ -651,11 +675,13 @@ resource "aws_security_group_rule" "egress_with_cidr_blocks" {
651
675
" from_port" ,
652
676
var. rules [lookup (var. egress_with_cidr_blocks [count . index ], " rule" , " _" )][0 ],
653
677
)
678
+
654
679
to_port = lookup (
655
680
var. egress_with_cidr_blocks [count . index ],
656
681
" to_port" ,
657
682
var. rules [lookup (var. egress_with_cidr_blocks [count . index ], " rule" , " _" )][1 ],
658
683
)
684
+
659
685
protocol = lookup (
660
686
var. egress_with_cidr_blocks [count . index ],
661
687
" protocol" ,
@@ -678,7 +704,7 @@ resource "aws_security_group_rule" "computed_egress_with_cidr_blocks" {
678
704
join (" ," , var. egress_cidr_blocks ),
679
705
),
680
706
))
681
- prefix_list_ids = var . egress_prefix_list_ids
707
+
682
708
description = lookup (
683
709
var. computed_egress_with_cidr_blocks [count . index ],
684
710
" description" ,
@@ -694,6 +720,7 @@ resource "aws_security_group_rule" "computed_egress_with_cidr_blocks" {
694
720
" _" ,
695
721
)][0 ],
696
722
)
723
+
697
724
to_port = lookup (
698
725
var. computed_egress_with_cidr_blocks [count . index ],
699
726
" to_port" ,
@@ -703,6 +730,7 @@ resource "aws_security_group_rule" "computed_egress_with_cidr_blocks" {
703
730
" _" ,
704
731
)][1 ],
705
732
)
733
+
706
734
protocol = lookup (
707
735
var. computed_egress_with_cidr_blocks [count . index ],
708
736
" protocol" ,
@@ -875,7 +903,15 @@ resource "aws_security_group_rule" "egress_with_prefix_list_ids" {
875
903
security_group_id = local. this_sg_id
876
904
type = " egress"
877
905
878
- prefix_list_ids = var. egress_prefix_list_ids
906
+ prefix_list_ids = compact (split (
907
+ " ," ,
908
+ lookup (
909
+ var. egress_with_prefix_list_ids [count . index ],
910
+ " prefix_list_ids" ,
911
+ join (" ," , var. egress_prefix_list_ids )
912
+ ))
913
+ )
914
+
879
915
description = lookup (
880
916
var. egress_with_prefix_list_ids [count . index ],
881
917
" description" ,
@@ -891,6 +927,7 @@ resource "aws_security_group_rule" "egress_with_prefix_list_ids" {
891
927
" _" ,
892
928
)][0 ],
893
929
)
930
+
894
931
to_port = lookup (
895
932
var. egress_with_prefix_list_ids [count . index ],
896
933
" to_port" ,
@@ -900,6 +937,7 @@ resource "aws_security_group_rule" "egress_with_prefix_list_ids" {
900
937
" _" ,
901
938
)][1 ],
902
939
)
940
+
903
941
protocol = lookup (
904
942
var. egress_with_prefix_list_ids [count . index ],
905
943
" protocol" ,
@@ -919,7 +957,16 @@ resource "aws_security_group_rule" "computed_egress_with_prefix_list_ids" {
919
957
type = " egress"
920
958
921
959
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
960
+
961
+ prefix_list_ids = compact (split (
962
+ " ," ,
963
+ lookup (
964
+ var. computed_egress_with_prefix_list_ids [count . index ],
965
+ " prefix_list_ids" ,
966
+ join (" ," , var. egress_prefix_list_ids )
967
+ )
968
+ ))
969
+
923
970
description = lookup (
924
971
var. computed_egress_with_prefix_list_ids [count . index ],
925
972
" description" ,
@@ -935,6 +982,7 @@ resource "aws_security_group_rule" "computed_egress_with_prefix_list_ids" {
935
982
" _" ,
936
983
)][0 ],
937
984
)
985
+
938
986
to_port = lookup (
939
987
var. computed_egress_with_prefix_list_ids [count . index ],
940
988
" to_port" ,
@@ -944,6 +992,7 @@ resource "aws_security_group_rule" "computed_egress_with_prefix_list_ids" {
944
992
" _" ,
945
993
)][1 ],
946
994
)
995
+
947
996
protocol = lookup (
948
997
var. computed_egress_with_prefix_list_ids [count . index ],
949
998
" protocol" ,
0 commit comments