Skip to content

Commit

Permalink
Array of strings is an output value type (#3312)
Browse files Browse the repository at this point in the history
* Array of strings is an output value type
* Add one more element as possible in dynreference
  • Loading branch information
kddejong authored Jun 18, 2024
1 parent 8dae604 commit 21be43c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/cfnlint/rules/functions/DynamicReference.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
{"type": "string", "enum": ["SecretString", ""]}, # secret-string
{"type": "string"}, # json-key
{"type": "string"}, # version-stage or version-id
{"type": "string"}, # version-stage or version-id
],
"maxItems": 6,
"minItems": 3,
"maxItems": 7,
"type": "array",
}

Expand All @@ -56,8 +58,10 @@
{"type": "string", "enum": ["SecretString", ""]}, # secret-string
{"type": "string"}, # json-key
{"type": "string"}, # version-stage or version-id
{"type": "string"}, # version-stage or version-id
],
"maxItems": 12,
"minItems": 9,
"maxItems": 13,
"type": "array",
}

Expand Down
7 changes: 6 additions & 1 deletion src/cfnlint/rules/outputs/Value.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def validate(self, validator: Validator, _: Any, instance: Any, schema: Any):
context=validator.context.evolve(
functions=list(FUNCTIONS),
),
schema={"type": "string"},
schema={
"type": ["array", "string"],
"items": {
"type": "string",
},
},
)

yield from self._iter_errors(validator, instance)
19 changes: 19 additions & 0 deletions test/unit/rules/functions/test_dynamic_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ def context(cfn):
},
[],
),
(
"Invalid SSM Parameter with string version",
"{{resolve:secretsmanager:arn:aws:secretsmanager:us-east-1:012345678901:secret:my-secret:SecretString::::}}",
{"type": "test"},
{
"E1051": _TestRule(),
"E1027": _TestRule(),
},
[
ValidationError(
"['resolve', 'secretsmanager', 'arn', 'aws', "
"'secretsmanager', 'us-east-1', '012345678901', "
"'secret', 'my-secret', 'SecretString', "
"'', '', '', ''] is too long (13)",
validator="maxItems",
rule=DynamicReference(),
)
],
),
],
)
def test_validate(name, instance, schema, child_rules, expected, rule, context, cfn):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/rules/outputs/test_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(1.0, 1),
(1, 1),
(True, 1),
(["foo"], 1),
([{}], 1),
({"foo": "bar"}, 1),
],
)
Expand Down

0 comments on commit 21be43c

Please sign in to comment.