Skip to content

Commit 0b7c42b

Browse files
authored
Ignore custom resource Ref (#3965)
1 parent b4d790d commit 0b7c42b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/cfnlint/rules/functions/RefFormat.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from copy import deepcopy
99
from typing import Any
1010

11+
from cfnlint.helpers import is_custom_resource
1112
from cfnlint.jsonschema import ValidationResult, Validator
1213
from cfnlint.jsonschema._utils import Unset
1314
from cfnlint.rules.formats._schema_comparer import compare_schemas
@@ -62,16 +63,20 @@ def validate(
6263
if instance not in validator.context.resources:
6364
return
6465
t = validator.context.resources[instance].type
66+
67+
# When using a custom resource you can set the physical ID
68+
# which results in a usable Ref
69+
if is_custom_resource(t):
70+
return
71+
6572
for (
6673
regions,
6774
resource_schema,
6875
) in PROVIDER_SCHEMA_MANAGER.get_resource_schemas_by_regions(
6976
t, validator.context.regions
7077
):
7178
region = regions[0]
72-
7379
ref_schema = validator.context.resources[instance].ref(region)
74-
7580
ref_schema = self._filter_schema(validator, t, instance, ref_schema)
7681

7782
err = compare_schemas(schema, ref_schema)

test/unit/rules/functions/test_ref_format.py

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def template():
2121
"Resources": {
2222
"MyBucket": {"Type": "AWS::S3::Bucket"},
2323
"MyVpc": {"Type": "AWS::EC2::VPC"},
24+
"MyCustomResource": {"Type": "Custom::MyResource"},
2425
},
2526
}
2627

@@ -34,6 +35,12 @@ def template():
3435
{"format": "AWS::EC2::VPC.Id"},
3536
[],
3637
),
38+
(
39+
"Valid Ref with a good format",
40+
"MyCustomResource",
41+
{"format": "AWS::EC2::VPC.Id"},
42+
[],
43+
),
3744
(
3845
"Invalid Ref with a bad format",
3946
"MyVpc",

0 commit comments

Comments
 (0)