Skip to content

Commit ab45182

Browse files
authored
Add more exceptions E1040 (#3636)
* Add more exceptions E1040
1 parent dd78dbf commit ab45182

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/cfnlint/rules/functions/GetAttFormat.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def __init__(self):
3333
"AWS::ServiceCatalog::CloudFormationProvisionedProduct",
3434
]
3535

36+
self._resource_type_attribute_exceptions = [("AWS::SSM::Parameter", "Value")]
37+
3638
def validate(
3739
self, validator: Validator, _, instance: Any, schema: Any
3840
) -> ValidationResult:
@@ -50,11 +52,15 @@ def validate(
5052
t, validator.context.regions
5153
):
5254
region = regions[0]
53-
getatt_ptr = validator.context.resources[resource].get_atts(region)[attr]
5455

5556
if t in self._resource_type_exceptions:
5657
return
5758

59+
if (t, attr) in self._resource_type_attribute_exceptions:
60+
return
61+
62+
getatt_ptr = validator.context.resources[resource].get_atts(region)[attr]
63+
5864
getatt_schema = resource_schema.resolver.resolve_cfn_pointer(getatt_ptr)
5965
getatt_fmt = getatt_schema.get("format")
6066
if getatt_fmt != fmt:

test/unit/rules/functions/test_getatt_format.py

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def template():
2727
"MyProvisionedProduct": {
2828
"Type": "AWS::ServiceCatalog::CloudFormationProvisionedProduct"
2929
},
30+
"MySSMParameter": {"Type": "AWS::SSM::Parameter"},
3031
},
3132
}
3233

@@ -64,6 +65,12 @@ def template():
6465
{"format": "AWS::EC2::SecurityGroup.GroupId"},
6566
[],
6667
),
68+
(
69+
"Valid GetAtt because of exception with attribute",
70+
["MySSMParameter", "Value"],
71+
{"format": "AWS::EC2::Image.Id"},
72+
[],
73+
),
6774
(
6875
"Invalid GetAtt with a bad format",
6976
["MyBucket", "Arn"],

0 commit comments

Comments
 (0)