Skip to content

Commit 825c416

Browse files
authored
Switch EC2 subnet requiredXor to requiredOr (#3970)
1 parent 8a10a56 commit 825c416

File tree

5 files changed

+108
-9
lines changed

5 files changed

+108
-9
lines changed

scripts/update_schemas_manually.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@
16451645
patches=[
16461646
Patch(
16471647
values={
1648-
"requiredXor": [
1648+
"requiredOr": [
16491649
"CidrBlock",
16501650
"Ipv4IpamPoolId",
16511651
"Ipv6IpamPoolId",
@@ -1654,6 +1654,10 @@
16541654
"dependentExcluded": {
16551655
"AvailabilityZone": ["AvailabilityZoneId"],
16561656
"AvailabilityZoneId": ["AvailabilityZone"],
1657+
"CidrBlock": ["Ipv4IpamPoolId"],
1658+
"Ipv4IpamPoolId": ["CidrBlock"],
1659+
"Ipv6CidrBlock": ["Ipv6IpamPoolId"],
1660+
"Ipv6IpamPoolId": ["Ipv6CidrBlock"],
16571661
},
16581662
"dependentRequired": {
16591663
"Ipv4IpamPoolId": ["Ipv4NetmaskLength"],

src/cfnlint/data/schemas/patches/extensions/all/aws_ec2_subnet/manual.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"op": "add",
4-
"path": "/requiredXor",
4+
"path": "/requiredOr",
55
"value": [
66
"CidrBlock",
77
"Ipv4IpamPoolId",
@@ -18,6 +18,18 @@
1818
],
1919
"AvailabilityZoneId": [
2020
"AvailabilityZone"
21+
],
22+
"CidrBlock": [
23+
"Ipv4IpamPoolId"
24+
],
25+
"Ipv4IpamPoolId": [
26+
"CidrBlock"
27+
],
28+
"Ipv6CidrBlock": [
29+
"Ipv6IpamPoolId"
30+
],
31+
"Ipv6IpamPoolId": [
32+
"Ipv6CidrBlock"
2133
]
2234
}
2335
},

src/cfnlint/data/schemas/providers/us_east_1/aws-ec2-subnet.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
],
4040
"AvailabilityZoneId": [
4141
"AvailabilityZone"
42+
],
43+
"CidrBlock": [
44+
"Ipv4IpamPoolId"
45+
],
46+
"Ipv4IpamPoolId": [
47+
"CidrBlock"
48+
],
49+
"Ipv6CidrBlock": [
50+
"Ipv6IpamPoolId"
51+
],
52+
"Ipv6IpamPoolId": [
53+
"Ipv6CidrBlock"
4254
]
4355
},
4456
"dependentRequired": {
@@ -150,7 +162,7 @@
150162
"required": [
151163
"VpcId"
152164
],
153-
"requiredXor": [
165+
"requiredOr": [
154166
"CidrBlock",
155167
"Ipv4IpamPoolId",
156168
"Ipv6IpamPoolId",

test/fixtures/results/integration/aws-ec2-subnet.json

+64-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
{
3131
"Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml",
32-
"Id": "8a479670-ef8c-81bb-a143-73f819ee56b7",
32+
"Id": "2fc1386e-f7b8-9825-c2d8-377a5c34d4e8",
3333
"Level": "Error",
3434
"Location": {
3535
"End": {
@@ -46,13 +46,13 @@
4646
"LineNumber": 13
4747
}
4848
},
49-
"Message": "Only one of ['CidrBlock', 'Ipv4IpamPoolId', 'Ipv6IpamPoolId', 'Ipv6CidrBlock'] is a required property",
49+
"Message": "One of ['CidrBlock', 'Ipv4IpamPoolId', 'Ipv6IpamPoolId', 'Ipv6CidrBlock'] is a required property",
5050
"ParentId": null,
5151
"Rule": {
52-
"Description": "Make sure that Resources properties that are required exist. Along with other properties not being specified",
53-
"Id": "E3014",
54-
"ShortDescription": "Validate only one of a set of required properties are specified",
55-
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#requiredxor"
52+
"Description": "Make sure at least one of the resource properties are included",
53+
"Id": "E3058",
54+
"ShortDescription": "Validate at least one of the properties are required",
55+
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#requiredor"
5656
}
5757
},
5858
{
@@ -82,5 +82,63 @@
8282
"ShortDescription": "Validate that when a property is specified that other properties should be included",
8383
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentrequired"
8484
}
85+
},
86+
{
87+
"Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml",
88+
"Id": "1b4bb4da-747d-c5ab-e0fa-74c10a41c69f",
89+
"Level": "Error",
90+
"Location": {
91+
"End": {
92+
"ColumnNumber": 16,
93+
"LineNumber": 30
94+
},
95+
"Path": [
96+
"Resources",
97+
"Subnet5",
98+
"Properties",
99+
"CidrBlock"
100+
],
101+
"Start": {
102+
"ColumnNumber": 7,
103+
"LineNumber": 30
104+
}
105+
},
106+
"Message": "'CidrBlock' should not be included with 'Ipv4IpamPoolId'",
107+
"ParentId": null,
108+
"Rule": {
109+
"Description": "When certain properties are specified other properties should not be included",
110+
"Id": "E3020",
111+
"ShortDescription": "Validate that when a property is specified another property should be excluded",
112+
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentexcluded"
113+
}
114+
},
115+
{
116+
"Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml",
117+
"Id": "7f4a7ce0-e099-2c50-bf8e-123df33df353",
118+
"Level": "Error",
119+
"Location": {
120+
"End": {
121+
"ColumnNumber": 21,
122+
"LineNumber": 31
123+
},
124+
"Path": [
125+
"Resources",
126+
"Subnet5",
127+
"Properties",
128+
"Ipv4IpamPoolId"
129+
],
130+
"Start": {
131+
"ColumnNumber": 7,
132+
"LineNumber": 31
133+
}
134+
},
135+
"Message": "'Ipv4IpamPoolId' should not be included with 'CidrBlock'",
136+
"ParentId": null,
137+
"Rule": {
138+
"Description": "When certain properties are specified other properties should not be included",
139+
"Id": "E3020",
140+
"ShortDescription": "Validate that when a property is specified another property should be excluded",
141+
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentexcluded"
142+
}
85143
}
86144
]

test/fixtures/templates/integration/aws-ec2-subnet.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@ Resources:
1717
Properties:
1818
VpcId: !Ref Vpc
1919
Ipv4IpamPoolId: test
20+
Subnet4:
21+
Type: AWS::EC2::Subnet
22+
Properties:
23+
VpcId: !Ref Vpc
24+
CidrBlock: 10.0.1.0/24
25+
Ipv6CidrBlock: ::1/128
26+
Subnet5:
27+
Type: AWS::EC2::Subnet
28+
Properties:
29+
VpcId: !Ref Vpc
30+
CidrBlock: 10.0.1.0/24
31+
Ipv4IpamPoolId: test
32+
Ipv4NetmaskLength: 10

0 commit comments

Comments
 (0)