Skip to content

Commit af75ec2

Browse files
authored
More security group fixes (#3928)
* More security group fixes
1 parent 40e40bc commit af75ec2

File tree

72 files changed

+433
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+433
-405
lines changed

scripts/update_schemas_format.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def _create_security_group_ids_patch(type_name: str, ref: str, resolver: RefReso
7070
"AWS::Pipes::Pipe",
7171
"AWS::EC2::NetworkInsightsAnalysis",
7272
"AWS::AutoScaling::LaunchConfiguration",
73+
"AWS::EC2::Instance",
7374
]:
7475
return []
7576

@@ -103,7 +104,12 @@ def _create_security_group_ids_patch(type_name: str, ref: str, resolver: RefReso
103104

104105

105106
def _create_security_group_id(type_name: str, ref: str, resolver: RefResolver):
106-
if type_name in ["AWS::Pipes::Pipe", "AWS::EC2::NetworkInsightsAnalysis"]:
107+
if type_name in [
108+
"AWS::Pipes::Pipe",
109+
"AWS::EC2::NetworkInsightsAnalysis",
110+
"AWS::AutoScaling::LaunchConfiguration",
111+
"AWS::EC2::Instance",
112+
]:
107113
return []
108114

109115
_, resolved = resolver.resolve(ref)
@@ -205,6 +211,24 @@ def _create_patch(value: dict[str, str], ref: Sequence[str], resolver: RefResolv
205211
path="/properties/SecurityGroups/items",
206212
),
207213
],
214+
"AWS::EC2::Instance": [
215+
Patch(
216+
values={"format": "AWS::EC2::SecurityGroup.Names"},
217+
path="/properties/SecurityGroups",
218+
),
219+
Patch(
220+
values={"format": "AWS::EC2::SecurityGroup.Name"},
221+
path="/properties/SecurityGroups/items",
222+
),
223+
Patch(
224+
values={"format": "AWS::EC2::SecurityGroup.Ids"},
225+
path="/properties/SecurityGroupIds",
226+
),
227+
Patch(
228+
values={"format": "AWS::EC2::SecurityGroup.Id"},
229+
path="/properties/SecurityGroupIds/items",
230+
),
231+
],
208232
}
209233

210234

scripts/update_schemas_manually.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ def build_resource_type_patches(resource_patches: ResourcePatch, filename: str):
16961696

16971697
d = []
16981698
with open(output_file, "w+") as fh:
1699-
for patch in resource_patches.patches:
1699+
for patch in sorted(resource_patches.patches, key=lambda x: x.path):
17001700
for k, v in patch.values.items():
17011701
d.append(
17021702
{
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[
22
{
33
"op": "add",
4-
"path": "/properties/Subnets/format",
5-
"value": "AWS::EC2::Subnet.Ids"
4+
"path": "/properties/SecurityGroups/format",
5+
"value": "AWS::EC2::SecurityGroup.Ids"
66
},
77
{
88
"op": "add",
9-
"path": "/properties/Subnets/items/format",
10-
"value": "AWS::EC2::Subnet.Id"
9+
"path": "/properties/SecurityGroups/items/format",
10+
"value": "AWS::EC2::SecurityGroup.Id"
1111
},
1212
{
1313
"op": "add",
14-
"path": "/properties/SecurityGroups/format",
15-
"value": "AWS::EC2::SecurityGroup.Ids"
14+
"path": "/properties/Subnets/format",
15+
"value": "AWS::EC2::Subnet.Ids"
1616
},
1717
{
1818
"op": "add",
19-
"path": "/properties/SecurityGroups/items/format",
20-
"value": "AWS::EC2::SecurityGroup.Id"
19+
"path": "/properties/Subnets/items/format",
20+
"value": "AWS::EC2::Subnet.Id"
2121
}
2222
]
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[
22
{
33
"op": "add",
4-
"path": "/definitions/Source/properties/EksConfiguration/properties/SecurityGroupIds/format",
5-
"value": "AWS::EC2::SecurityGroup.Ids"
4+
"path": "/definitions/SecurityGroupId/format",
5+
"value": "AWS::EC2::SecurityGroup.Id"
66
},
77
{
88
"op": "add",
9-
"path": "/definitions/SecurityGroupId/format",
10-
"value": "AWS::EC2::SecurityGroup.Id"
9+
"path": "/definitions/Source/properties/EksConfiguration/properties/SecurityGroupIds/format",
10+
"value": "AWS::EC2::SecurityGroup.Ids"
1111
}
1212
]
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
[
2+
{
3+
"op": "add",
4+
"path": "/properties/ImageId/format",
5+
"value": "AWS::EC2::Image.Id"
6+
},
27
{
38
"op": "add",
49
"path": "/properties/SecurityGroups/anyOf",
510
"value": [
611
{
7-
"format": "AWS::EC2::SecurityGroup.Id"
12+
"format": "AWS::EC2::SecurityGroup.Ids"
813
},
914
{
10-
"format": "AWS::EC2::SecurityGroup.Name"
15+
"format": "AWS::EC2::SecurityGroup.Names"
1116
}
1217
]
1318
},
@@ -22,10 +27,5 @@
2227
"format": "AWS::EC2::SecurityGroup.Name"
2328
}
2429
]
25-
},
26-
{
27-
"op": "add",
28-
"path": "/properties/ImageId/format",
29-
"value": "AWS::EC2::Image.Id"
3030
}
3131
]

src/cfnlint/data/schemas/patches/extensions/all/aws_batch_computeenvironment/format.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
},
77
{
88
"op": "add",
9-
"path": "/definitions/ComputeResources/properties/Subnets/format",
10-
"value": "AWS::EC2::Subnet.Ids"
9+
"path": "/definitions/ComputeResources/properties/SecurityGroupIds/format",
10+
"value": "AWS::EC2::SecurityGroup.Ids"
1111
},
1212
{
1313
"op": "add",
14-
"path": "/definitions/ComputeResources/properties/Subnets/items/format",
15-
"value": "AWS::EC2::Subnet.Id"
14+
"path": "/definitions/ComputeResources/properties/SecurityGroupIds/items/format",
15+
"value": "AWS::EC2::SecurityGroup.Id"
1616
},
1717
{
1818
"op": "add",
19-
"path": "/definitions/ComputeResources/properties/SecurityGroupIds/format",
20-
"value": "AWS::EC2::SecurityGroup.Ids"
19+
"path": "/definitions/ComputeResources/properties/Subnets/format",
20+
"value": "AWS::EC2::Subnet.Ids"
2121
},
2222
{
2323
"op": "add",
24-
"path": "/definitions/ComputeResources/properties/SecurityGroupIds/items/format",
25-
"value": "AWS::EC2::SecurityGroup.Id"
24+
"path": "/definitions/ComputeResources/properties/Subnets/items/format",
25+
"value": "AWS::EC2::Subnet.Id"
2626
}
2727
]
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[
22
{
33
"op": "add",
4-
"path": "/definitions/VpcConfig/properties/VpcId/format",
5-
"value": "AWS::EC2::VPC.Id"
4+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
5+
"value": "AWS::EC2::SecurityGroup.Ids"
66
},
77
{
88
"op": "add",
9-
"path": "/properties/ImageId/format",
10-
"value": "AWS::EC2::Image.Id"
9+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
10+
"value": "AWS::EC2::SecurityGroup.Id"
1111
},
1212
{
1313
"op": "add",
@@ -21,12 +21,12 @@
2121
},
2222
{
2323
"op": "add",
24-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
25-
"value": "AWS::EC2::SecurityGroup.Ids"
24+
"path": "/definitions/VpcConfig/properties/VpcId/format",
25+
"value": "AWS::EC2::VPC.Id"
2626
},
2727
{
2828
"op": "add",
29-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
30-
"value": "AWS::EC2::SecurityGroup.Id"
29+
"path": "/properties/ImageId/format",
30+
"value": "AWS::EC2::Image.Id"
3131
}
3232
]
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
[
22
{
33
"op": "add",
4-
"path": "/definitions/VpcConfig/properties/VpcId/format",
5-
"value": "AWS::EC2::VPC.Id"
4+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
5+
"value": "AWS::EC2::SecurityGroup.Ids"
6+
},
7+
{
8+
"op": "add",
9+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
10+
"value": "AWS::EC2::SecurityGroup.Id"
611
},
712
{
813
"op": "add",
@@ -16,12 +21,7 @@
1621
},
1722
{
1823
"op": "add",
19-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
20-
"value": "AWS::EC2::SecurityGroup.Ids"
21-
},
22-
{
23-
"op": "add",
24-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
25-
"value": "AWS::EC2::SecurityGroup.Id"
24+
"path": "/definitions/VpcConfig/properties/VpcId/format",
25+
"value": "AWS::EC2::VPC.Id"
2626
}
2727
]
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[
22
{
33
"op": "add",
4-
"path": "/definitions/VpcConfig/properties/Subnets/format",
5-
"value": "AWS::EC2::Subnet.Ids"
4+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
5+
"value": "AWS::EC2::SecurityGroup.Ids"
66
},
77
{
88
"op": "add",
9-
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
10-
"value": "AWS::EC2::Subnet.Id"
9+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
10+
"value": "AWS::EC2::SecurityGroup.Id"
1111
},
1212
{
1313
"op": "add",
14-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
15-
"value": "AWS::EC2::SecurityGroup.Ids"
14+
"path": "/definitions/VpcConfig/properties/Subnets/format",
15+
"value": "AWS::EC2::Subnet.Ids"
1616
},
1717
{
1818
"op": "add",
19-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
20-
"value": "AWS::EC2::SecurityGroup.Id"
19+
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
20+
"value": "AWS::EC2::Subnet.Id"
2121
}
2222
]
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[
22
{
33
"op": "add",
4-
"path": "/definitions/VpcConfig/properties/Subnets/format",
5-
"value": "AWS::EC2::Subnet.Ids"
4+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
5+
"value": "AWS::EC2::SecurityGroup.Ids"
66
},
77
{
88
"op": "add",
9-
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
10-
"value": "AWS::EC2::Subnet.Id"
9+
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
10+
"value": "AWS::EC2::SecurityGroup.Id"
1111
},
1212
{
1313
"op": "add",
14-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/format",
15-
"value": "AWS::EC2::SecurityGroup.Ids"
14+
"path": "/definitions/VpcConfig/properties/Subnets/format",
15+
"value": "AWS::EC2::Subnet.Ids"
1616
},
1717
{
1818
"op": "add",
19-
"path": "/definitions/VpcConfig/properties/SecurityGroupIds/items/format",
20-
"value": "AWS::EC2::SecurityGroup.Id"
19+
"path": "/definitions/VpcConfig/properties/Subnets/items/format",
20+
"value": "AWS::EC2::Subnet.Id"
2121
}
2222
]
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
[
2-
{
3-
"op": "add",
4-
"path": "/properties/VpcId/format",
5-
"value": "AWS::EC2::VPC.Id"
6-
},
72
{
83
"op": "add",
94
"path": "/properties/SecurityGroupIds/format",
@@ -13,5 +8,10 @@
138
"op": "add",
149
"path": "/properties/SecurityGroupIds/items/format",
1510
"value": "AWS::EC2::SecurityGroup.Id"
11+
},
12+
{
13+
"op": "add",
14+
"path": "/properties/VpcId/format",
15+
"value": "AWS::EC2::VPC.Id"
1616
}
1717
]
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
[
2-
{
3-
"op": "add",
4-
"path": "/properties/VpcId/format",
5-
"value": "AWS::EC2::VPC.Id"
6-
},
72
{
83
"op": "add",
94
"path": "/properties/SecurityGroupIds/format",
@@ -13,5 +8,10 @@
138
"op": "add",
149
"path": "/properties/SecurityGroupIds/items/format",
1510
"value": "AWS::EC2::SecurityGroup.Id"
11+
},
12+
{
13+
"op": "add",
14+
"path": "/properties/VpcId/format",
15+
"value": "AWS::EC2::VPC.Id"
1616
}
1717
]

0 commit comments

Comments
 (0)