Skip to content

Commit 21be43c

Browse files
authored
Array of strings is an output value type (#3312)
* Array of strings is an output value type * Add one more element as possible in dynreference
1 parent 8dae604 commit 21be43c

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

src/cfnlint/rules/functions/DynamicReference.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
{"type": "string", "enum": ["SecretString", ""]}, # secret-string
3838
{"type": "string"}, # json-key
3939
{"type": "string"}, # version-stage or version-id
40+
{"type": "string"}, # version-stage or version-id
4041
],
41-
"maxItems": 6,
42+
"minItems": 3,
43+
"maxItems": 7,
4244
"type": "array",
4345
}
4446

@@ -56,8 +58,10 @@
5658
{"type": "string", "enum": ["SecretString", ""]}, # secret-string
5759
{"type": "string"}, # json-key
5860
{"type": "string"}, # version-stage or version-id
61+
{"type": "string"}, # version-stage or version-id
5962
],
60-
"maxItems": 12,
63+
"minItems": 9,
64+
"maxItems": 13,
6165
"type": "array",
6266
}
6367

src/cfnlint/rules/outputs/Value.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ def validate(self, validator: Validator, _: Any, instance: Any, schema: Any):
3232
context=validator.context.evolve(
3333
functions=list(FUNCTIONS),
3434
),
35-
schema={"type": "string"},
35+
schema={
36+
"type": ["array", "string"],
37+
"items": {
38+
"type": "string",
39+
},
40+
},
3641
)
3742

3843
yield from self._iter_errors(validator, instance)

test/unit/rules/functions/test_dynamic_reference.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ def context(cfn):
172172
},
173173
[],
174174
),
175+
(
176+
"Invalid SSM Parameter with string version",
177+
"{{resolve:secretsmanager:arn:aws:secretsmanager:us-east-1:012345678901:secret:my-secret:SecretString::::}}",
178+
{"type": "test"},
179+
{
180+
"E1051": _TestRule(),
181+
"E1027": _TestRule(),
182+
},
183+
[
184+
ValidationError(
185+
"['resolve', 'secretsmanager', 'arn', 'aws', "
186+
"'secretsmanager', 'us-east-1', '012345678901', "
187+
"'secret', 'my-secret', 'SecretString', "
188+
"'', '', '', ''] is too long (13)",
189+
validator="maxItems",
190+
rule=DynamicReference(),
191+
)
192+
],
193+
),
175194
],
176195
)
177196
def test_validate(name, instance, schema, child_rules, expected, rule, context, cfn):

test/unit/rules/outputs/test_value.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(1.0, 1),
1717
(1, 1),
1818
(True, 1),
19-
(["foo"], 1),
19+
([{}], 1),
2020
({"foo": "bar"}, 1),
2121
],
2222
)

0 commit comments

Comments
 (0)