Skip to content

Commit 2fecc9a

Browse files
authored
Update requiredXor for Vpc and Subnets (#3734)
1 parent ced6ec3 commit 2fecc9a

File tree

10 files changed

+172
-1
lines changed

10 files changed

+172
-1
lines changed

scripts/update_schemas_manually.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,10 @@
898898
path="/",
899899
values={
900900
"requiredXor": ["CidrBlock", "Ipv4IpamPoolId"],
901-
"dependentRequired": {"Ipv4IpamPoolId": ["Ipv4NetmaskLength"]},
901+
"dependentRequired": {
902+
"Ipv4IpamPoolId": ["Ipv4NetmaskLength"],
903+
"Ipv4NetmaskLength": ["Ipv4IpamPoolId"],
904+
},
902905
},
903906
),
904907
],
@@ -1631,10 +1634,15 @@
16311634
patches=[
16321635
Patch(
16331636
values={
1637+
"requiredXor": ["CidrBlock", "Ipv4IpamPoolId"],
16341638
"dependentExcluded": {
16351639
"AvailabilityZone": ["AvailabilityZoneId"],
16361640
"AvailabilityZoneId": ["AvailabilityZone"],
16371641
},
1642+
"dependentRequired": {
1643+
"Ipv4IpamPoolId": ["Ipv4NetmaskLength"],
1644+
"Ipv4NetmaskLength": ["Ipv4IpamPoolId"],
1645+
},
16381646
},
16391647
path="/",
16401648
),

scripts/update_snapshot_results.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cfn-lint test/fixtures/templates/integration/getatt-types.yaml -e -c I --format
99
cfn-lint test/fixtures/templates/integration/aws-ec2-networkinterface.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-networkinterface.json
1010
cfn-lint test/fixtures/templates/integration/aws-ec2-instance.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-instance.json
1111
cfn-lint test/fixtures/templates/integration/aws-ec2-launchtemplate.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-launchtemplate.json
12+
cfn-lint test/fixtures/templates/integration/aws-ec2-subnet.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-subnet.json
1213
cfn-lint test/fixtures/templates/integration/aws-dynamodb-table.yaml -e -c I --format json > test/fixtures/results/integration/aws-dynamodb-table.json
1314

1415
# public/

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"op": "add",
4+
"path": "/requiredXor",
5+
"value": [
6+
"CidrBlock",
7+
"Ipv4IpamPoolId"
8+
]
9+
},
210
{
311
"op": "add",
412
"path": "/dependentExcluded",
@@ -10,5 +18,17 @@
1018
"AvailabilityZone"
1119
]
1220
}
21+
},
22+
{
23+
"op": "add",
24+
"path": "/dependentRequired",
25+
"value": {
26+
"Ipv4IpamPoolId": [
27+
"Ipv4NetmaskLength"
28+
],
29+
"Ipv4NetmaskLength": [
30+
"Ipv4IpamPoolId"
31+
]
32+
}
1333
}
1434
]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"value": {
1414
"Ipv4IpamPoolId": [
1515
"Ipv4NetmaskLength"
16+
],
17+
"Ipv4NetmaskLength": [
18+
"Ipv4IpamPoolId"
1619
]
1720
}
1821
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"AvailabilityZone"
4242
]
4343
},
44+
"dependentRequired": {
45+
"Ipv4IpamPoolId": [
46+
"Ipv4NetmaskLength"
47+
],
48+
"Ipv4NetmaskLength": [
49+
"Ipv4IpamPoolId"
50+
]
51+
},
4452
"primaryIdentifier": [
4553
"/properties/SubnetId"
4654
],
@@ -134,6 +142,10 @@
134142
"required": [
135143
"VpcId"
136144
],
145+
"requiredXor": [
146+
"CidrBlock",
147+
"Ipv4IpamPoolId"
148+
],
137149
"tagging": {
138150
"cloudFormationSystemTags": true,
139151
"tagOnCreate": true,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"AvailabilityZone"
4242
]
4343
},
44+
"dependentRequired": {
45+
"Ipv4IpamPoolId": [
46+
"Ipv4NetmaskLength"
47+
],
48+
"Ipv4NetmaskLength": [
49+
"Ipv4IpamPoolId"
50+
]
51+
},
4452
"primaryIdentifier": [
4553
"/properties/SubnetId"
4654
],
@@ -135,6 +143,10 @@
135143
"required": [
136144
"VpcId"
137145
],
146+
"requiredXor": [
147+
"CidrBlock",
148+
"Ipv4IpamPoolId"
149+
],
138150
"tagging": {
139151
"cloudFormationSystemTags": true,
140152
"tagOnCreate": true,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
"dependentRequired": {
3030
"Ipv4IpamPoolId": [
3131
"Ipv4NetmaskLength"
32+
],
33+
"Ipv4NetmaskLength": [
34+
"Ipv4IpamPoolId"
3235
]
3336
},
3437
"primaryIdentifier": [
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[
2+
{
3+
"Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml",
4+
"Id": "5c96f1f9-9dfc-31e7-f24b-9e08af46c98f",
5+
"Level": "Error",
6+
"Location": {
7+
"End": {
8+
"ColumnNumber": 15,
9+
"LineNumber": 7
10+
},
11+
"Path": [
12+
"Resources",
13+
"Subnet1",
14+
"Properties"
15+
],
16+
"Start": {
17+
"ColumnNumber": 5,
18+
"LineNumber": 7
19+
}
20+
},
21+
"Message": "'Ipv4IpamPoolId' is a dependency of 'Ipv4NetmaskLength'",
22+
"ParentId": null,
23+
"Rule": {
24+
"Description": "When certain properties are specified it results in other properties to be required",
25+
"Id": "E3021",
26+
"ShortDescription": "Validate that when a property is specified that other properties should be included",
27+
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentrequired"
28+
}
29+
},
30+
{
31+
"Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml",
32+
"Id": "5c12a390-4b88-f609-d6d6-bd7fa2250f99",
33+
"Level": "Error",
34+
"Location": {
35+
"End": {
36+
"ColumnNumber": 15,
37+
"LineNumber": 13
38+
},
39+
"Path": [
40+
"Resources",
41+
"Subnet2",
42+
"Properties"
43+
],
44+
"Start": {
45+
"ColumnNumber": 5,
46+
"LineNumber": 13
47+
}
48+
},
49+
"Message": "Only one of ['CidrBlock', 'Ipv4IpamPoolId'] is a required property",
50+
"ParentId": null,
51+
"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"
56+
}
57+
},
58+
{
59+
"Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml",
60+
"Id": "7a696880-e120-60b6-93b9-a57a48d71189",
61+
"Level": "Error",
62+
"Location": {
63+
"End": {
64+
"ColumnNumber": 15,
65+
"LineNumber": 17
66+
},
67+
"Path": [
68+
"Resources",
69+
"Subnet3",
70+
"Properties"
71+
],
72+
"Start": {
73+
"ColumnNumber": 5,
74+
"LineNumber": 17
75+
}
76+
},
77+
"Message": "'Ipv4NetmaskLength' is a dependency of 'Ipv4IpamPoolId'",
78+
"ParentId": null,
79+
"Rule": {
80+
"Description": "When certain properties are specified it results in other properties to be required",
81+
"Id": "E3021",
82+
"ShortDescription": "Validate that when a property is specified that other properties should be included",
83+
"Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentrequired"
84+
}
85+
}
86+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Parameters:
2+
Vpc:
3+
Type: AWS::EC2::VPC::Id
4+
Resources:
5+
Subnet1:
6+
Type: AWS::EC2::Subnet
7+
Properties:
8+
VpcId: !Ref Vpc
9+
CidrBlock: 10.0.0.0/24
10+
Ipv4NetmaskLength: 10
11+
Subnet2:
12+
Type: AWS::EC2::Subnet
13+
Properties:
14+
VpcId: !Ref Vpc
15+
Subnet3:
16+
Type: AWS::EC2::Subnet
17+
Properties:
18+
VpcId: !Ref Vpc
19+
Ipv4IpamPoolId: test

test/integration/test_integration_templates.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ class TestQuickStartTemplates(BaseCliTestCase):
7777
),
7878
"exit_code": 2,
7979
},
80+
{
81+
"filename": ("test/fixtures/templates/integration/aws-ec2-subnet.yaml"),
82+
"results_filename": (
83+
"test/fixtures/results/integration/aws-ec2-subnet.json"
84+
),
85+
"exit_code": 2,
86+
},
8087
{
8188
"filename": ("test/fixtures/templates/integration/aws-dynamodb-table.yaml"),
8289
"results_filename": (

0 commit comments

Comments
 (0)