@@ -134,6 +134,16 @@ func (a *sgAdapter) adaptSecurityGroup(resource *terraform.Block, module terrafo
134
134
}
135
135
}
136
136
137
+ for _ , r := range module .GetReferencingResources (resource , "aws_vpc_security_group_ingress_rule" , "security_group_id" ) {
138
+ a .sgRuleIDs .Resolve (r .ID ())
139
+ ingressRules = append (ingressRules , adaptSingleSGRule (r ))
140
+ }
141
+
142
+ for _ , r := range module .GetReferencingResources (resource , "aws_vpc_security_group_egress_rule" , "security_group_id" ) {
143
+ a .sgRuleIDs .Resolve (r .ID ())
144
+ egressRules = append (egressRules , adaptSingleSGRule (r ))
145
+ }
146
+
137
147
return ec2.SecurityGroup {
138
148
Metadata : resource .GetMetadata (),
139
149
Description : descriptionVal ,
@@ -178,6 +188,24 @@ func adaptSGRule(resource *terraform.Block, modules terraform.Modules) ec2.Secur
178
188
}
179
189
}
180
190
191
+ func adaptSingleSGRule (resource * terraform.Block ) ec2.SecurityGroupRule {
192
+ description := resource .GetAttribute ("description" ).AsStringValueOrDefault ("" , resource )
193
+
194
+ var cidrs []iacTypes.StringValue
195
+ if ipv4 := resource .GetAttribute ("cidr_ipv4" ); ipv4 .IsNotNil () {
196
+ cidrs = append (cidrs , ipv4 .AsStringValueOrDefault ("" , resource ))
197
+ }
198
+ if ipv6 := resource .GetAttribute ("cidr_ipv6" ); ipv6 .IsNotNil () {
199
+ cidrs = append (cidrs , ipv6 .AsStringValueOrDefault ("" , resource ))
200
+ }
201
+
202
+ return ec2.SecurityGroupRule {
203
+ Metadata : resource .GetMetadata (),
204
+ Description : description ,
205
+ CIDRs : cidrs ,
206
+ }
207
+ }
208
+
181
209
func (a * naclAdapter ) adaptNetworkACL (resource * terraform.Block , module * terraform.Module ) ec2.NetworkACL {
182
210
var networkRules []ec2.NetworkACLRule
183
211
rulesBlocks := module .GetReferencingResources (resource , "aws_network_acl_rule" , "network_acl_id" )
0 commit comments