@@ -186,33 +186,15 @@ def read(
186
186
- ec2:DescribeSubnets
187
187
- ec2:DescribeNetworkAcls
188
188
"""
189
- ec2 = request .aws_client_factory .ec2
190
- subnet_id = request .desired_state ["SubnetId" ]
191
- subnet = ec2 .describe_subnets (SubnetIds = [subnet_id ])["Subnets" ][0 ]
192
-
193
- model = EC2SubnetProperties (** util .select_attributes (subnet , self .SCHEMA ["properties" ]))
194
-
195
- if "Tags" not in model :
196
- model ["Tags" ] = []
197
-
198
- if "EnableDns64" not in model :
199
- model ["EnableDns64" ] = False
200
-
201
- optional_bool_attrs = ["EnableResourceNameDnsAAAARecord" , "EnableResourceNameDnsARecord" ]
202
- for attr in optional_bool_attrs :
203
- if attr not in model ["PrivateDnsNameOptionsOnLaunch" ]:
204
- model ["PrivateDnsNameOptionsOnLaunch" ][attr ] = False
205
-
206
- network_acl_associations = ec2 .describe_network_acls (
207
- Filters = [{"Name" : "association.subnet-id" , "Values" : [subnet_id ]}]
189
+ models = generate_subnet_read_payload (
190
+ ec2_client = request .aws_client_factory .ec2 ,
191
+ schema = self .SCHEMA ["properties" ],
192
+ subnet_ids = [request .desired_state ["SubnetId" ]],
208
193
)
209
- model ["NetworkAclAssociationId" ] = network_acl_associations ["NetworkAcls" ][0 ][
210
- "NetworkAclId"
211
- ]
212
194
213
195
return ProgressEvent (
214
196
status = OperationStatus .SUCCESS ,
215
- resource_model = model ,
197
+ resource_model = models [ 0 ] ,
216
198
custom_context = request .custom_context ,
217
199
)
218
200
0 commit comments