diff --git a/samtranslator/schema/any_cfn_resource.py b/samtranslator/schema/any_cfn_resource.py index 713fc2badb..30aa55dc12 100644 --- a/samtranslator/schema/any_cfn_resource.py +++ b/samtranslator/schema/any_cfn_resource.py @@ -4,6 +4,6 @@ constr = pydantic.constr -# Match anything not containing Serverless +# Anything goes if has string Type but is not AWS::Serverless::* class Resource(LenientBaseModel): - Type: constr(regex=r"^((?!::Serverless::).)*$") # type: ignore + Type: constr(regex=r"^(?!AWS::Serverless::).+$") # type: ignore diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index 74dd27f260..819614d101 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -5577,7 +5577,7 @@ "properties": { "Type": { "title": "Type", - "pattern": "^((?!::Serverless::).)*$", + "pattern": "^(?!AWS::Serverless::).+$", "type": "string" } }, diff --git a/tests/translator/input/schema_validation_3.yaml b/tests/translator/input/schema_validation_3.yaml new file mode 100644 index 0000000000..6a4cd0a5e6 --- /dev/null +++ b/tests/translator/input/schema_validation_3.yaml @@ -0,0 +1,19 @@ +Resources: + UnknownType1: + Type: AWS::Foo::Bar + + UnknownType2: + Type: AWS::Foo::Bar + Properties: + Turtle: Train + + UnknownType3: + Type: Foo::Bar::Egg + Properties: + Turtle: Train + + UnknownType4: + Type: Foo::Bar::Egg + + UnknownType5: + Type: Foo::Serverless::Egg diff --git a/tests/translator/output/aws-cn/schema_validation_3.json b/tests/translator/output/aws-cn/schema_validation_3.json new file mode 100644 index 0000000000..7703e1b3b7 --- /dev/null +++ b/tests/translator/output/aws-cn/schema_validation_3.json @@ -0,0 +1,25 @@ +{ + "Resources": { + "UnknownType1": { + "Type": "AWS::Foo::Bar" + }, + "UnknownType2": { + "Properties": { + "Turtle": "Train" + }, + "Type": "AWS::Foo::Bar" + }, + "UnknownType3": { + "Properties": { + "Turtle": "Train" + }, + "Type": "Foo::Bar::Egg" + }, + "UnknownType4": { + "Type": "Foo::Bar::Egg" + }, + "UnknownType5": { + "Type": "Foo::Serverless::Egg" + } + } +} diff --git a/tests/translator/output/aws-us-gov/schema_validation_3.json b/tests/translator/output/aws-us-gov/schema_validation_3.json new file mode 100644 index 0000000000..7703e1b3b7 --- /dev/null +++ b/tests/translator/output/aws-us-gov/schema_validation_3.json @@ -0,0 +1,25 @@ +{ + "Resources": { + "UnknownType1": { + "Type": "AWS::Foo::Bar" + }, + "UnknownType2": { + "Properties": { + "Turtle": "Train" + }, + "Type": "AWS::Foo::Bar" + }, + "UnknownType3": { + "Properties": { + "Turtle": "Train" + }, + "Type": "Foo::Bar::Egg" + }, + "UnknownType4": { + "Type": "Foo::Bar::Egg" + }, + "UnknownType5": { + "Type": "Foo::Serverless::Egg" + } + } +} diff --git a/tests/translator/output/schema_validation_3.json b/tests/translator/output/schema_validation_3.json new file mode 100644 index 0000000000..7703e1b3b7 --- /dev/null +++ b/tests/translator/output/schema_validation_3.json @@ -0,0 +1,25 @@ +{ + "Resources": { + "UnknownType1": { + "Type": "AWS::Foo::Bar" + }, + "UnknownType2": { + "Properties": { + "Turtle": "Train" + }, + "Type": "AWS::Foo::Bar" + }, + "UnknownType3": { + "Properties": { + "Turtle": "Train" + }, + "Type": "Foo::Bar::Egg" + }, + "UnknownType4": { + "Type": "Foo::Bar::Egg" + }, + "UnknownType5": { + "Type": "Foo::Serverless::Egg" + } + } +}