Skip to content

Commit 44b7aa1

Browse files
authored
GetAtts to array returns a string (#3639)
1 parent eeb1208 commit 44b7aa1

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/cfnlint/rules/functions/GetAtt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from cfnlint.helpers import ensure_list, is_types_compatible
1414
from cfnlint.jsonschema import ValidationError, ValidationResult, Validator
15-
from cfnlint.rules.functions._BaseFn import BaseFn, all_types
15+
from cfnlint.rules.functions._BaseFn import BaseFn
1616
from cfnlint.schema import PROVIDER_SCHEMA_MANAGER
1717

1818

@@ -29,7 +29,7 @@ class GetAtt(BaseFn):
2929
tags = ["functions", "getatt"]
3030

3131
def __init__(self) -> None:
32-
super().__init__("Fn::GetAtt", all_types)
32+
super().__init__("Fn::GetAtt", ("string", "boolean", "integer", "number"))
3333

3434
def schema(self, validator, instance) -> dict[str, Any]:
3535
resource_functions = []
@@ -127,6 +127,9 @@ def _resolve_getatt(
127127
continue
128128

129129
schema_types = ensure_list(getatt_schema.get("type"))
130+
if "array" in schema_types:
131+
schema_types.remove("array")
132+
schema_types.append("string")
130133

131134
types = ensure_list(s.get("type"))
132135

test/unit/rules/functions/test_getatt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def validate(self, validator, s, instance, schema):
134134
[
135135
ValidationError(
136136
"{'Fn::GetAtt': 'MyBucket.Arn'} is not of type 'array'",
137-
path=deque(["Fn::GetAtt"]),
138-
schema_path=deque(["type"]),
137+
path=deque([]),
138+
schema_path=deque([]),
139139
validator="fn_getatt",
140140
),
141141
],
@@ -149,8 +149,8 @@ def validate(self, validator, s, instance, schema):
149149
[
150150
ValidationError(
151151
"{'Fn::GetAtt': 'MyBucket.Arn'} is not of type 'array', 'object'",
152-
path=deque(["Fn::GetAtt"]),
153-
schema_path=deque(["type"]),
152+
path=deque([]),
153+
schema_path=deque([]),
154154
validator="fn_getatt",
155155
),
156156
],

test/unit/rules/functions/test_sub.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,7 @@ def context(cfn):
274274
"Invalid Fn::Sub with a GetAtt to an array of attributes",
275275
{"Fn::Sub": "${MySimpleAd.DnsIpAddresses}"},
276276
{"type": "string"},
277-
[
278-
ValidationError(
279-
("'MySimpleAd.DnsIpAddresses' is not of type 'string'"),
280-
instance="MySimpleAd.DnsIpAddresses",
281-
path=deque(["Fn::Sub"]),
282-
schema_path=deque([]),
283-
validator="fn_sub",
284-
),
285-
],
277+
[],
286278
),
287279
(
288280
"Invalid Fn::Sub with a GetAtt to an integer",

0 commit comments

Comments
 (0)