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 18, 2024
1 parent 7e514f4 commit 7dc1ed8
Show file tree
Hide file tree
Showing 192 changed files with 704 additions and 8 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,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"
}
]
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
@@ -1,9 +1,4 @@
[
{
"op": "add",
"path": "/handlers/list/handlerSchema/properties/VpcId/format",
"value": "AWS::EC2::VPC.Id"
},
{
"op": "add",
"path": "/properties/VpcId/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/SecurityGroups/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
},
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/SecurityGroups/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/SecurityGroups/format",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"op": "add",
"path": "/properties/Subnets/format",
"value": "AWS::EC2::Subnet.Ids"
},
{
"op": "add",
"path": "/properties/Subnets/items/format",
"value": "AWS::EC2::Subnet.Id"
}
]
Loading

0 comments on commit 7dc1ed8

Please sign in to comment.