Skip to content

Commit

Permalink
Patch dynamodb tables to check schemas (#3133)
Browse files Browse the repository at this point in the history
* Patch dynamodb tables to check schemas
* Switch to keywords and add prefixItems
* Remove requiredOr for anyOf
  • Loading branch information
kddejong committed Apr 26, 2024
1 parent aac3d71 commit 2ad95ea
Show file tree
Hide file tree
Showing 604 changed files with 69,716 additions and 40,357 deletions.
41 changes: 3 additions & 38 deletions docs/cfn-schema-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,6 @@ is equivalent to the JSON schema
}
```

#### requiredOr
*requiredOr* is used to define when at least one property from a set properties is required.

On the following defined object
```json
{
"properties": {
"a": true,
"b": true,
"c": true
},
"additionalProperties": false
}
```

The cfn-lint schema
```json
{
"requiredOr": ["a", "b", "c"]
}
```
is equivalent to the JSON schema
```json
{
"anyOf": [
{
"required": ["a"]
},
{
"required": ["b"]
},
{
"required": ["c"]
}
]
}
```

#### propertiesNand
*propertiesNand* is used to define when none or only one property from a set properties can be defined.

Expand Down Expand Up @@ -189,3 +151,6 @@ is equivalent to the JSON schema
}
}
```

#### prefixItems
*prefixItems* is similar to the definition of [prefixItems](https://json-schema.org/understanding-json-schema/reference/array#tupleValidation) but doesn't actually do the prefix. The current resource schema doesn't support [items](https://json-schema.org/understanding-json-schema/reference/array#items) being an array. We use `prefixItems` to validate array items where ordering matters.
72 changes: 68 additions & 4 deletions scripts/update_schemas_manually.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,64 @@
),
],
),
ResourcePatch(
resource_type="AWS::DynamoDB::Table",
patches=[
Patch(
values={
"allOf": [
{
"if": {
"type": "object",
"required": ["LocalSecondaryIndexes"],
},
"then": {
"type": "object",
"properties": {
"KeySchema": {
"minItems": 2,
},
"AttributeDefinitions": {
"minItems": 2,
},
},
},
}
]
},
path="/",
),
],
),
ResourcePatch(
resource_type="AWS::DynamoDB::GlobalTable",
patches=[
Patch(
values={
"allOf": [
{
"if": {
"required": ["LocalSecondaryIndexes"],
"type": "object",
},
"then": {
"properties": {
"KeySchema": {
"minItems": 2,
},
"AttributeDefinitions": {
"minItems": 2,
},
},
"type": "object",
},
}
]
},
path="/",
),
],
),
ResourcePatch(
resource_type="AWS::EC2::DHCPOptions",
patches=[
Expand Down Expand Up @@ -1011,7 +1069,13 @@
resource_type="AWS::IAM::Policy",
patches=[
Patch(
values={"requiredOr": ["Users", "Groups", "Roles"]},
values={
"anyOf": [
{"required": ["Users"]},
{"required": ["Groups"]},
{"required": ["Roles"]},
]
},
path="/",
),
Patch(
Expand Down Expand Up @@ -1355,9 +1419,9 @@
),
Patch(
values={
"requiredOr": [
"HttpErrorCodeReturnedEquals",
"KeyPrefixEquals",
"anyOf": [
{"required": ["HttpErrorCodeReturnedEquals"]},
{"required": ["KeyPrefixEquals"]},
],
},
path="/definitions/RoutingRuleCondition",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"e73b6822e0de7b75f9f34ea748ea2565\"", "url": "https://schema.cloudformation.eu-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"2ebe5d5fa13d16181b7d09a9935f4fda\"", "url": "https://schema.cloudformation.eu-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"30035f1418fbb20bf499a3fcd6002c07\"", "url": "https://schema.cloudformation.cn-north-1.amazonaws.com.cn/CloudformationSchema.zip"}
{"etag": "\"e7e148497e625af6d2b2009898098db5\"", "url": "https://schema.cloudformation.cn-north-1.amazonaws.com.cn/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"208e5ea3fb318a2a2fa351e2fba32063\"", "url": "https://schema.cloudformation.us-gov-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"386e71d9efa53fa88ff3cea36ea83a8c\"", "url": "https://schema.cloudformation.us-gov-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"b255ebac2df2657f7b3853cdda4672c8\"", "url": "https://schema.cloudformation.me-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"30c62c1375c87666435fb0e3c0bbc883\"", "url": "https://schema.cloudformation.me-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"f0daba625b77368f810a2ec78b51620b\"", "url": "https://schema.cloudformation.us-gov-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"27266e32ed432c4a9dfb8cf654d20cc5\"", "url": "https://schema.cloudformation.us-gov-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"ba9de912dec295b215e37f3abd89acd1\"", "url": "https://schema.cloudformation.me-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"4683bbce4d3af1e717610bc383d8f700\"", "url": "https://schema.cloudformation.me-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"88be1fa534b8a396909134313ec12038\"", "url": "https://schema.cloudformation.eu-west-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"50286e663a50f9dc8ab75d445b2392ac\"", "url": "https://schema.cloudformation.eu-west-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"a77483ff0cf7093429e5aa4b1b75db81\"", "url": "https://schema.cloudformation.cn-northwest-1.amazonaws.com.cn/CloudformationSchema.zip"}
{"etag": "\"3b3729d44f0d9f57ccd2fe307e20401e\"", "url": "https://schema.cloudformation.cn-northwest-1.amazonaws.com.cn/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"3c2d1d8188e041ecaa9893f34faf31a3\"", "url": "https://schema.cloudformation.af-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"9004b04be022bd377cad611a057512f0\"", "url": "https://schema.cloudformation.af-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"23521059871e438fe48cc99ee88be57a\"", "url": "https://schema.cloudformation.us-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"7732e27012782c733f6865ad0dba34b7\"", "url": "https://schema.cloudformation.us-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"1224999cf325dae249742c5870a983fc\"", "url": "https://schema.cloudformation.eu-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"64bfad570c83ada336c53fcba5bd113f\"", "url": "https://schema.cloudformation.eu-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"180743f536912d18f24c8de42811f9bf\"", "url": "https://schema.cloudformation.ap-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"4106b258ed514d54f8e715d0f190fb75\"", "url": "https://schema.cloudformation.ap-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"8bb759456e9b3f4c6e418aab0fdbb69d\"", "url": "https://schema.cloudformation.ap-southeast-4.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"8dd6c1f3b7329e57e4e29838e00c1666\"", "url": "https://schema.cloudformation.ap-southeast-4.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"2354e3507f6c305a5b2cda1e0a7588ae\"", "url": "https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"2bb20fe6918d551316c72306f5b31791\"", "url": "https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"cd0871def8a08f7ea64c4ff3a1059aaf\"", "url": "https://schema.cloudformation.ap-southeast-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"7a1a68b4fdcd113b4c4216dcc208a1e0\"", "url": "https://schema.cloudformation.ap-southeast-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"38021be45ce7cd3b4893468b231a7a94\"", "url": "https://schema.cloudformation.ap-northeast-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"f6f75465d5679f3f467e67318825c4b7\"", "url": "https://schema.cloudformation.ap-northeast-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"8249cfee6234994a4026dc176aab480e\"", "url": "https://schema.cloudformation.ap-southeast-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"42e6403ecb202793d20a5e2ef99e6dbe\"", "url": "https://schema.cloudformation.ap-southeast-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"99281665906d90b0378f063d753b4979\"", "url": "https://schema.cloudformation.ap-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"cc8649b6f2d092ab26b469ca6b3aa1ab\"", "url": "https://schema.cloudformation.ap-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"4f1616bbc9831f36c11596763ab4a5af\"", "url": "https://schema.cloudformation.sa-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"41274ec24a0ae4abade30ee039232e48\"", "url": "https://schema.cloudformation.sa-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"6660486ee0fb2bd0200c2760409425bb\"", "url": "https://schema.cloudformation.ap-southeast-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"fca8c0efb51dbdd2307040ff79fa561b\"", "url": "https://schema.cloudformation.ap-southeast-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"b5d70c06c84568cbed74890c1d033548\"", "url": "https://schema.cloudformation.ca-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"c75197f406b5d8927f0747a7a04d93bc\"", "url": "https://schema.cloudformation.ca-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"99d3a231ec6eede3617dd16d2c25e508\"", "url": "https://schema.cloudformation.eu-central-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"cbf9ffb996863524d8668a54da7dff9d\"", "url": "https://schema.cloudformation.eu-central-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"0bf600ed39651d8beda9a78ba24088fd\"", "url": "https://schema.cloudformation.eu-north-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"2462c38c8b0fe97afddd86bcc4c27405\"", "url": "https://schema.cloudformation.eu-north-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"6c11b29e10a25425a8443ad8ee8bd360\"", "url": "https://schema.cloudformation.eu-south-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"eed9277f55608503f4a9b51c5c1be9fb\"", "url": "https://schema.cloudformation.eu-south-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"fee502948b8818ca03753aa2856602e1\"", "url": "https://schema.cloudformation.ca-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"c665fb1332437114b6116f46e2a3f2e0\"", "url": "https://schema.cloudformation.ca-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"a70bcd8b7a25f0ef70831f88d983b108\"", "url": "https://schema.cloudformation.eu-west-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"806815fd98a18f5606711ac6b1e1828f\"", "url": "https://schema.cloudformation.eu-west-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"1f355118f8d8136a650a219497ad6434\"", "url": "https://schema.cloudformation.ap-northeast-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"7d3b8bb8ac8ebbf0b831a9c023061e78\"", "url": "https://schema.cloudformation.ap-northeast-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"bac346adbd45b8c353f21ce4e153ddc9\"", "url": "https://schema.cloudformation.us-west-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"2cbd6ee138716bec454cd73632d62cdb\"", "url": "https://schema.cloudformation.us-west-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"776c8f9849791c49098d33e416889a3a\"", "url": "https://schema.cloudformation.ap-south-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"32a0b3f0f2b39a482059ba56981b5c54\"", "url": "https://schema.cloudformation.ap-south-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"5edef4c68021cde237160ea95052d749\"", "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"a404313c67027ffa74514704a92f8e7e\"", "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"ad7d904d02ec3fd49b6ec5eaa85721ac\"", "url": "https://schema.cloudformation.eu-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"c6b9dba7d55caeeafb9f464dd7f1ea7e\"", "url": "https://schema.cloudformation.eu-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"c090009ef7ef43e95643f2c5c8d22d3f\"", "url": "https://schema.cloudformation.ap-northeast-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"d62f024f051a2876c6f2578eaf759f81\"", "url": "https://schema.cloudformation.ap-northeast-1.amazonaws.com/CloudformationSchema.zip"}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"op": "add",
"path": "/allOf",
"value": [
{
"if": {
"required": [
"LocalSecondaryIndexes"
],
"type": "object"
},
"then": {
"properties": {
"AttributeDefinitions": {
"minItems": 2
},
"KeySchema": {
"minItems": 2
}
},
"type": "object"
}
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"op": "add",
"path": "/allOf",
"value": [
{
"if": {
"required": [
"LocalSecondaryIndexes"
],
"type": "object"
},
"then": {
"properties": {
"AttributeDefinitions": {
"minItems": 2
},
"KeySchema": {
"minItems": 2
}
},
"type": "object"
}
}
]
}
]
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
[
{
"op": "add",
"path": "/requiredOr",
"path": "/anyOf",
"value": [
"Users",
"Groups",
"Roles"
{
"required": [
"Users"
]
},
{
"required": [
"Groups"
]
},
{
"required": [
"Roles"
]
}
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"path": "/properties/PromotionTier/maximum",
"value": 15
},
{
"op": "add",
"path": "/properties/PromotionTier/minimum",
"value": 0
},
{
"op": "add",
"path": "/properties/BackupRetentionPeriod/maximum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
},
{
"op": "add",
"path": "/definitions/RoutingRuleCondition/requiredOr",
"path": "/definitions/RoutingRuleCondition/anyOf",
"value": [
"HttpErrorCodeReturnedEquals",
"KeyPrefixEquals"
{
"required": [
"HttpErrorCodeReturnedEquals"
]
},
{
"required": [
"KeyPrefixEquals"
]
}
]
},
{
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"op": "add",
"path": "/properties/AttributeDefinitions/uniqueKeys",
"value": [
"AttributeName"
]
}
]
Loading

0 comments on commit 2ad95ea

Please sign in to comment.