Skip to content

Commit

Permalink
Cleanup patching of format keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Jan 23, 2025
1 parent 5b8b7b7 commit 8e4f1ed
Show file tree
Hide file tree
Showing 246 changed files with 299 additions and 295 deletions.
8 changes: 6 additions & 2 deletions docs/format_keyword.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ In `cfn-lint`, we have extended the `format` keyword to support custom formats t

This format ensures that the value is a valid VPC ID, which is a string of the pattern `vpc-[0-9a-f]{8}` or `vpc-[0-9a-f]{17}`.

### AWS::EC2::SecurityGroup.GroupId
### AWS::EC2::SecurityGroup.Id

This format validates that the value is a valid Security Group ID, which is a string of the pattern `sg-[0-9a-f]{8}` or `sg-[0-9a-f]{17}`.

### AWS::EC2::SecurityGroup.GroupName
### AWS::EC2::SecurityGroup.Ids

This format validates that the value is a valid list of Security Group IDs, which is a string of the pattern `sg-[0-9a-f]{8}` or `sg-[0-9a-f]{17}`.

### AWS::EC2::SecurityGroup.Name

This format validates that the value is a valid Security Group Name, which must be a string of 1 to 255 characters, starting with a letter, and containing only letters, numbers, and certain special characters.

Expand Down
16 changes: 8 additions & 8 deletions scripts/update_schemas_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _create_security_group_ids_patch(type_name: str, ref: str, resolver: RefReso
path=ref[1:],
),
_create_patch(
{"format": "AWS::EC2::SecurityGroup.GroupId"},
{"format": "AWS::EC2::SecurityGroup.Id"},
items_path,
resolver=resolver,
),
Expand All @@ -110,7 +110,7 @@ def _create_security_group_id(type_name: str, ref: str, resolver: RefResolver):

return [
_create_patch(
{"format": "AWS::EC2::SecurityGroup.GroupId"},
{"format": "AWS::EC2::SecurityGroup.Id"},
ref,
resolver=resolver,
)
Expand All @@ -129,7 +129,7 @@ def _create_security_group_name(type_name: str, ref: str, resolver: RefResolver)

return [
_create_patch(
{"format": "AWS::EC2::SecurityGroup.GroupName"},
{"format": "AWS::EC2::SecurityGroup.Name"},
ref,
resolver=resolver,
)
Expand All @@ -150,27 +150,27 @@ def _create_patch(value: dict[str, str], ref: Sequence[str], resolver: RefResolv
_manual_patches = {
"AWS::EC2::SecurityGroup": [
Patch(
values={"format": "AWS::EC2::SecurityGroup.GroupId"},
values={"format": "AWS::EC2::SecurityGroup.Id"},
path="/properties/GroupId",
),
Patch(
values={"format": "AWS::EC2::SecurityGroup.GroupName"},
values={"format": "AWS::EC2::SecurityGroup.Name"},
path="/properties/GroupName",
),
Patch(
values={"format": "AWS::EC2::SecurityGroup.GroupId"},
values={"format": "AWS::EC2::SecurityGroup.Id"},
path="/properties/Id",
),
],
"AWS::EC2::SecurityGroupIngress": [
Patch(
values={"format": "AWS::EC2::SecurityGroup.GroupId"},
values={"format": "AWS::EC2::SecurityGroup.Id"},
path="/properties/GroupId",
),
],
"AWS::EC2::SecurityGroupEgress": [
Patch(
values={"format": "AWS::EC2::SecurityGroup.GroupId"},
values={"format": "AWS::EC2::SecurityGroup.Id"},
path="/properties/GroupId",
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{
"op": "add",
"path": "/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/definitions/SecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{
"op": "add",
"path": "/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
{
"op": "add",
"path": "/definitions/ComputeResources/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{
"op": "add",
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
Expand All @@ -37,6 +37,6 @@
{
"op": "add",
"path": "/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{
"op": "add",
"path": "/definitions/SecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"op": "add",
"path": "/definitions/LaunchTemplateData/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
Expand All @@ -27,6 +27,6 @@
{
"op": "add",
"path": "/definitions/LaunchTemplateData/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
{
"op": "add",
"path": "/properties/GroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
"path": "/properties/GroupName/format",
"value": "AWS::EC2::SecurityGroup.GroupName"
"value": "AWS::EC2::SecurityGroup.Name"
},
{
"op": "add",
"path": "/properties/Id/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
Expand All @@ -22,16 +22,16 @@
{
"op": "add",
"path": "/definitions/Egress/properties/DestinationSecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
"path": "/definitions/Ingress/properties/SourceSecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
"path": "/definitions/Ingress/properties/SourceSecurityGroupName/format",
"value": "AWS::EC2::SecurityGroup.GroupName"
"value": "AWS::EC2::SecurityGroup.Name"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"op": "add",
"path": "/properties/GroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
"path": "/properties/DestinationSecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{
"op": "add",
"path": "/properties/GroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
"path": "/properties/SourceSecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
},
{
"op": "add",
"path": "/properties/SourceSecurityGroupName/format",
"value": "AWS::EC2::SecurityGroup.GroupName"
"value": "AWS::EC2::SecurityGroup.Name"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
{
"op": "add",
"path": "/definitions/GroupIdentifier/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/definitions/SecurityGroupId/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/properties/DefaultSecurityGroup/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
{
"op": "add",
"path": "/definitions/AwsVpcConfiguration/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{
"op": "add",
"path": "/properties/SecurityGroups/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/definitions/ResourcesVpcConfig/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"op": "add",
"path": "/properties/SecurityGroupIds/items/format",
"value": "AWS::EC2::SecurityGroup.GroupId"
"value": "AWS::EC2::SecurityGroup.Id"
}
]
Loading

0 comments on commit 8e4f1ed

Please sign in to comment.