Skip to content

Commit 362a393

Browse files
authored
Update custom resource schema (#3966)
* Update custom resource schema * Update the schema validation for custom resources
1 parent 0b7c42b commit 362a393

File tree

10 files changed

+213
-8
lines changed

10 files changed

+213
-8
lines changed

scripts/update_snapshot_results.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cfn-lint test/fixtures/templates/integration/aws-ec2-instance.yaml -e -c I --for
1313
cfn-lint test/fixtures/templates/integration/aws-ec2-launchtemplate.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-launchtemplate.json
1414
cfn-lint test/fixtures/templates/integration/aws-ec2-subnet.yaml -e -c I --format json > test/fixtures/results/integration/aws-ec2-subnet.json
1515
cfn-lint test/fixtures/templates/integration/aws-dynamodb-table.yaml -e -c I --format json > test/fixtures/results/integration/aws-dynamodb-table.json
16+
cfn-lint test/fixtures/templates/integration/custom-resources.yaml -e -c I --format json > test/fixtures/results/integration/custom-resources.json
1617

1718
# public/
1819
cfn-lint test/fixtures/templates/public/lambda-poller.yaml -e -c I --format json > test/fixtures/results/public/lambda-poller.json

src/cfnlint/data/schemas/patches/providers/all/aws_cloudformation_customresource/additionalproperties.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"op": "add",
4+
"path": "/patternProperties",
5+
"value": {
6+
".*": {
7+
"type": [
8+
"string",
9+
"integer",
10+
"number",
11+
"array",
12+
"object"
13+
]
14+
}
15+
}
16+
}
17+
]

src/cfnlint/data/schemas/providers/us_east_1/aws-cloudformation-customresource.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
{
2-
"additionalProperties": true,
2+
"additionalProperties": false,
33
"createOnlyProperties": [
44
"/properties/ServiceToken"
55
],
6+
"patternProperties": {
7+
".*": {
8+
"type": [
9+
"string",
10+
"integer",
11+
"number",
12+
"array",
13+
"object"
14+
]
15+
}
16+
},
617
"primaryIdentifier": [
718
"/properties/Id"
819
],
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[
2+
{
3+
"Filename": "test/fixtures/templates/integration/custom-resources.yaml",
4+
"Id": "8beb84d0-7cba-9d1d-8455-7646435abda6",
5+
"Level": "Error",
6+
"Location": {
7+
"End": {
8+
"ColumnNumber": 15,
9+
"LineNumber": 12
10+
},
11+
"Path": [
12+
"Resources",
13+
"CustomResource",
14+
"Properties",
15+
"KmsKeyId",
16+
"Fn::GetAtt",
17+
1
18+
],
19+
"Start": {
20+
"ColumnNumber": 7,
21+
"LineNumber": 12
22+
}
23+
},
24+
"Message": "'ArnA' is not one of ['Arn', 'KeyId'] in ['us-east-1']",
25+
"ParentId": null,
26+
"Rule": {
27+
"Description": "Validates that GetAtt parameters are to valid resources and properties of those resources",
28+
"Id": "E1010",
29+
"ShortDescription": "GetAtt validation of parameters",
30+
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html"
31+
}
32+
}
33+
]

test/fixtures/results/quickstart/non_strict/openshift.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,69 @@
241241
"Source": "https://aws.amazon.com/blogs/devops/optimize-aws-cloudformation-templates/"
242242
}
243243
},
244+
{
245+
"Filename": "test/fixtures/templates/quickstart/openshift.yaml",
246+
"Id": "4d08be7f-87eb-7a95-c47e-db51a14f7c1e",
247+
"Level": "Informational",
248+
"Location": {
249+
"End": {
250+
"ColumnNumber": 15,
251+
"LineNumber": 781
252+
},
253+
"Path": [
254+
"Resources",
255+
"GetRSA",
256+
"Properties",
257+
"ResourceProperties",
258+
"RequestId",
259+
"Fn::Join",
260+
0
261+
],
262+
"Start": {
263+
"ColumnNumber": 13,
264+
"LineNumber": 781
265+
}
266+
},
267+
"Message": "Prefer using Fn::Sub over Fn::Join with an empty delimiter",
268+
"ParentId": null,
269+
"Rule": {
270+
"Description": "Prefer a sub instead of Join when using a join delimiter that is empty",
271+
"Id": "I1022",
272+
"ShortDescription": "Use Sub instead of Join",
273+
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html"
274+
}
275+
},
276+
{
277+
"Filename": "test/fixtures/templates/quickstart/openshift.yaml",
278+
"Id": "f77be627-51a5-5c13-2173-95647f45d22a",
279+
"Level": "Informational",
280+
"Location": {
281+
"End": {
282+
"ColumnNumber": 13,
283+
"LineNumber": 787
284+
},
285+
"Path": [
286+
"Resources",
287+
"GetRSA",
288+
"Properties",
289+
"ResponseURL",
290+
"Fn::Join",
291+
0
292+
],
293+
"Start": {
294+
"ColumnNumber": 11,
295+
"LineNumber": 787
296+
}
297+
},
298+
"Message": "Prefer using Fn::Sub over Fn::Join with an empty delimiter",
299+
"ParentId": null,
300+
"Rule": {
301+
"Description": "Prefer a sub instead of Join when using a join delimiter that is empty",
302+
"Id": "I1022",
303+
"ShortDescription": "Use Sub instead of Join",
304+
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html"
305+
}
306+
},
244307
{
245308
"Filename": "test/fixtures/templates/quickstart/openshift.yaml",
246309
"Id": "93eee50b-4524-efef-9d81-b9918acca9d8",

test/fixtures/results/quickstart/openshift.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,69 @@
303303
"Source": "https://aws.amazon.com/blogs/devops/optimize-aws-cloudformation-templates/"
304304
}
305305
},
306+
{
307+
"Filename": "test/fixtures/templates/quickstart/openshift.yaml",
308+
"Id": "4d08be7f-87eb-7a95-c47e-db51a14f7c1e",
309+
"Level": "Informational",
310+
"Location": {
311+
"End": {
312+
"ColumnNumber": 15,
313+
"LineNumber": 781
314+
},
315+
"Path": [
316+
"Resources",
317+
"GetRSA",
318+
"Properties",
319+
"ResourceProperties",
320+
"RequestId",
321+
"Fn::Join",
322+
0
323+
],
324+
"Start": {
325+
"ColumnNumber": 13,
326+
"LineNumber": 781
327+
}
328+
},
329+
"Message": "Prefer using Fn::Sub over Fn::Join with an empty delimiter",
330+
"ParentId": null,
331+
"Rule": {
332+
"Description": "Prefer a sub instead of Join when using a join delimiter that is empty",
333+
"Id": "I1022",
334+
"ShortDescription": "Use Sub instead of Join",
335+
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html"
336+
}
337+
},
338+
{
339+
"Filename": "test/fixtures/templates/quickstart/openshift.yaml",
340+
"Id": "f77be627-51a5-5c13-2173-95647f45d22a",
341+
"Level": "Informational",
342+
"Location": {
343+
"End": {
344+
"ColumnNumber": 13,
345+
"LineNumber": 787
346+
},
347+
"Path": [
348+
"Resources",
349+
"GetRSA",
350+
"Properties",
351+
"ResponseURL",
352+
"Fn::Join",
353+
0
354+
],
355+
"Start": {
356+
"ColumnNumber": 11,
357+
"LineNumber": 787
358+
}
359+
},
360+
"Message": "Prefer using Fn::Sub over Fn::Join with an empty delimiter",
361+
"ParentId": null,
362+
"Rule": {
363+
"Description": "Prefer a sub instead of Join when using a join delimiter that is empty",
364+
"Id": "I1022",
365+
"ShortDescription": "Use Sub instead of Join",
366+
"Source": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html"
367+
}
368+
},
306369
{
307370
"Filename": "test/fixtures/templates/quickstart/openshift.yaml",
308371
"Id": "93eee50b-4524-efef-9d81-b9918acca9d8",

test/fixtures/schemas/providers/base.definition.schema.v1.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@
333333
"type": "boolean",
334334
"const": false
335335
},
336+
"patternProperties": {
337+
"type": "object",
338+
"patternProperties": {
339+
".*": {
340+
"$ref": "#/definitions/properties"
341+
}
342+
},
343+
"additionalProperties": false
344+
},
336345
"properties": {
337346
"type": "object",
338347
"patternProperties": {

test/fixtures/schemas/providers/provider.definition.schema.v1.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
"$comment": "All properties of a resource must be expressed in the schema - arbitrary inputs are not allowed",
175175
"$ref": "base.definition.schema.v1.json#/properties/additionalProperties"
176176
},
177+
"patternProperties": {
178+
"$ref": "base.definition.schema.v1.json#/properties/patternProperties"
179+
},
177180
"properties": {
178181
"$ref": "base.definition.schema.v1.json#/properties/properties"
179182
},
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Resources:
2+
KmsKey:
3+
DeletionPolicy: Delete
4+
UpdateReplacePolicy: Delete
5+
Type: AWS::KMS::Key
6+
Properties: {}
7+
8+
CustomResource:
9+
Type: AWS::CloudFormation::CustomResource
10+
Properties:
11+
ServiceToken: test
12+
KmsKeyId: !GetAtt KmsKey.ArnA

0 commit comments

Comments
 (0)