Skip to content

Commit

Permalink
Add logic for subnet IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Oct 21, 2024
1 parent 672f1bd commit 90cec42
Show file tree
Hide file tree
Showing 273 changed files with 6,085 additions and 2,500 deletions.
47 changes: 47 additions & 0 deletions scripts/update_schemas_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,35 @@ def _descend(instance: Any, keywords: Sequence[str]) -> Iterator[deque[str]]:
return


def _create_subnet_ids_patch(type_name: str, ref: str, resolver: RefResolver):

_, resolved = resolver.resolve(ref)
if "$ref" in resolved:
return _create_subnet_ids_patch(
type_name=type_name,
ref=resolved["$ref"],
resolver=resolver,
)
items = resolved.get("items")
if items:
if "$ref" in items:
items_path = items["$ref"]
else:
items_path = ref + "/items"

return [
Patch(
values={"format": "AWS::EC2::Subnet.Ids"},
path=ref[1:],
),
_create_patch(
{"format": "AWS::EC2::Subnet.Id"},
items_path,
resolver=resolver,
),
]


def _create_security_group_ids_patch(type_name: str, ref: str, resolver: RefResolver):
if type_name in ["AWS::Pipes::Pipe", "AWS::EC2::NetworkInsightsAnalysis"]:
return []
Expand Down Expand Up @@ -184,6 +213,24 @@ def main():
)
)

for path in _descend(obj, ["Subnets"]):
if path[-2] == "properties":
resource_patches.extend(
_create_subnet_ids_patch(
resource_type, "#/" + "/".join(path), resolver
)
)

for path in _descend(obj, ["SubnetId"]):
if path[-2] == "properties":
resource_patches.append(
_create_patch(
value={"format": "AWS::EC2::Subnet.Id"},
ref="#/" + "/".join(path),
resolver=resolver,
)
)

for path in _descend(obj, ["SecurityGroupIds", "SecurityGroups"]):
if path[-2] == "properties":
resource_patches.extend(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"91ff8d94668bdd12d0c5f0e4f14e9176\"", "url": "https://schema.cloudformation.me-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"6b272784ab5ee64380e1afbeff2dc2b7\"", "url": "https://schema.cloudformation.me-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"f103d1dd0afbd815a9f9452338f22e1e\"", "url": "https://schema.cloudformation.us-gov-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"f81509de348a0967be7f3e7522c853f8\"", "url": "https://schema.cloudformation.us-gov-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"9e3e41525c2aa18c4cc835f5dd2d54ca\"", "url": "https://schema.cloudformation.me-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"ec6886f703876cc995c20fcc1a63ceb8\"", "url": "https://schema.cloudformation.me-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"c5af86b97e6c01fbc4f631ae9e48c113\"", "url": "https://schema.cloudformation.us-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"962d970ff4a0e8eaac7e22be166b04d9\"", "url": "https://schema.cloudformation.us-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"a3cb83ca57cb8fcb4d2523412ec7eb56\"", "url": "https://schema.cloudformation.ap-southeast-5.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"284f5207b99c05c18851ec7d6dca40fc\"", "url": "https://schema.cloudformation.ap-southeast-5.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"3d8f7db562c312c673ef927e94cb9637\"", "url": "https://schema.cloudformation.eu-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"955b95eb824351800bb6c104fa55a21a\"", "url": "https://schema.cloudformation.eu-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"c6c77e3ae0f3e5bfda471412e05b1452\"", "url": "https://schema.cloudformation.ap-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"e240ca4edfd903c608f93464cb673784\"", "url": "https://schema.cloudformation.ap-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"b7afcb326fee1a5f4c6e3fcfeeeef393\"", "url": "https://schema.cloudformation.ap-southeast-4.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"6dcc26e7d356a0da18166bfa43aa3ce7\"", "url": "https://schema.cloudformation.ap-southeast-4.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"fb11515c75cabbbf3ce02b42e5e40d46\"", "url": "https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"6e785910b27a142d4eb246dc436e963e\"", "url": "https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"6f754221de81bebeae31e1b6a2586746\"", "url": "https://schema.cloudformation.ap-southeast-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"475eabbb5e5612f7dfdd4f0d49c5b195\"", "url": "https://schema.cloudformation.ap-southeast-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"2eedaced886b01dd58140d251c1a9439\"", "url": "https://schema.cloudformation.ap-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"23876adf542952c6010ec5b9174f72bd\"", "url": "https://schema.cloudformation.ap-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"572e3015be10b15781cad51a1334c3ae\"", "url": "https://schema.cloudformation.sa-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"1ee37da9fb13d6e676b7f42949e1313b\"", "url": "https://schema.cloudformation.sa-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"ad8cd9bfb2c0cbc3666c6b5e725b54cc\"", "url": "https://schema.cloudformation.ap-southeast-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"d9f86ac6ec362b7593a9e1e7eacfeb3b\"", "url": "https://schema.cloudformation.ap-southeast-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"eaec1f6e0715031b8648f854d31220cd\"", "url": "https://schema.cloudformation.ca-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"57bff1a398d853571fbd5d1db37a9c13\"", "url": "https://schema.cloudformation.ca-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"00baef4fed5e67c3d2389ddaf1502a4d\"", "url": "https://schema.cloudformation.eu-central-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"21ae68e324bc48627edc4f8aad6751f1\"", "url": "https://schema.cloudformation.eu-central-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"2cf246c47d91e09951a6bfc341e42282\"", "url": "https://schema.cloudformation.eu-north-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"0b82384a3134d6f50ca215076c9a2e20\"", "url": "https://schema.cloudformation.eu-north-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"a3c0dedebf9f60843f595761933f0c5a\"", "url": "https://schema.cloudformation.ca-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"a726e0e4b51dd1c9f8368a7bc5d1f103\"", "url": "https://schema.cloudformation.ca-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"1bfedd2bd6f5634d23e095e6909c9cfd\"", "url": "https://schema.cloudformation.ap-northeast-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"26a1a2313341b664b9f17a39a65df8e5\"", "url": "https://schema.cloudformation.ap-northeast-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"31eab6eadaa72210fb859f02c52512d8\"", "url": "https://schema.cloudformation.us-west-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"1c0ca2f252ceb9e694f30bf61c0e3cd8\"", "url": "https://schema.cloudformation.us-west-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"4e2076de55c138d08e92068d214db681\"", "url": "https://schema.cloudformation.ap-south-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"f1eb75d4e17234a3747d778c0afc0e06\"", "url": "https://schema.cloudformation.ap-south-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"fdeed46f6265a3c88384e782fabf6f8f\"", "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"48c3487c81c327708f2fd4e8467014ec\"", "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"83afcd963703374755dc76b0ce5b7656\"", "url": "https://schema.cloudformation.il-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"74a926e7b633254339f1fab711eabd99\"", "url": "https://schema.cloudformation.il-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"c0c62bd6273dba67fec9dfb881604be5\"", "url": "https://schema.cloudformation.eu-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"fd7c4fe81940185ac6dec367ba6e5e32\"", "url": "https://schema.cloudformation.eu-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"9f01c74202fe43ce076c7c755940b17b\"", "url": "https://schema.cloudformation.ap-northeast-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"26b2184acde767f88f95f7f07414919e\"", "url": "https://schema.cloudformation.ap-northeast-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"op": "add",
"path": "/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/properties/SecurityGroups/format",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
"path": "/definitions/ComputeResources/properties/ImageId/format",
"value": "AWS::EC2::Image.Id"
},
{
"op": "add",
"path": "/definitions/ComputeResources/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/ComputeResources/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/ComputeResources/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"op": "add",
"path": "/properties/ImageId/format",
"value": "AWS::EC2::Image.Id"
},
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
"path": "/definitions/VpcConfig/properties/VpcId/format",
"value": "AWS::EC2::VPC.Id"
},
{
"op": "add",
"path": "/properties/ImageId/format",
"value": "AWS::EC2::Image.Id"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
"path": "/definitions/VpcConfig/properties/VpcId/format",
"value": "AWS::EC2::VPC.Id"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/definitions/FleetLaunchTemplateOverridesRequest/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"path": "/properties/ImageId/format",
"value": "AWS::EC2::Image.Id"
},
{
"op": "add",
"path": "/definitions/NetworkInterface/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"path": "/definitions/LaunchTemplateData/properties/ImageId/format",
"value": "AWS::EC2::Image.Id"
},
{
"op": "add",
"path": "/definitions/NetworkInterface/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/LaunchTemplateData/properties/SecurityGroupIds/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"op": "add",
"path": "/properties/VpcId/format",
"value": "AWS::EC2::VPC.Id"
},
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
"path": "/definitions/SpotFleetLaunchSpecification/properties/ImageId/format",
"value": "AWS::EC2::Image.Id"
},
{
"op": "add",
"path": "/definitions/InstanceNetworkInterfaceSpecification/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/LaunchTemplateOverrides/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/SpotFleetLaunchSpecification/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/SpotFleetLaunchSpecification/properties/SecurityGroups/format",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"op": "add",
"path": "/properties/VpcId/format",
"value": "AWS::EC2::VPC.Id"
},
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/properties/SubnetId/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Loading

0 comments on commit 90cec42

Please sign in to comment.