diff --git a/samtranslator/validator/sam_schema/definitions/parameter.json b/samtranslator/validator/sam_schema/definitions/parameter.json index 26cdcc3f4..79f951f11 100644 --- a/samtranslator/validator/sam_schema/definitions/parameter.json +++ b/samtranslator/validator/sam_schema/definitions/parameter.json @@ -59,7 +59,8 @@ "List", "List", "List", - "List" + "List", + "AWS::SSM::Parameter::Value" ], "type": "string" } diff --git a/tests/validator/input/root/error_minimal_template_with_parameters.yaml b/tests/validator/input/root/error_minimal_template_with_parameters.yaml new file mode 100644 index 000000000..747888b6f --- /dev/null +++ b/tests/validator/input/root/error_minimal_template_with_parameters.yaml @@ -0,0 +1,108 @@ +# Smallest possible API template +Transform: AWS::Serverless-2016-10-31 +Parameters: + StringParameter: + Type: String + Default: 'String' + NumberParameter: + Type: Number + Default: 2 + CommaDelimitedListParameter: + Type: CommaDelimitedList + Default: 'String,1,6' + AWSZoneParameter: + Type: "AWS::EC2::AvailabilityZone::Name" + Default: 'us-east-1' + AWSImageId: + Type: AWS::EC2::Image::Id + Default: 'Image_ID_1' + AWSInstanceID: + Type: AWS::EC2::Instance::Id + Default: 'Instance_ID_1' + AWSKeyPairName: + Type: AWS::EC2::KeyPair::KeyName + Default: 'Key_Name_1' + AWSSecurityGroupName: + Type: AWS::EC2::SecurityGroup::GroupName + Default: 'Group_Name_1' + AWSSecurityGroupID: + Type: AWS::EC2::SecurityGroup::Id + Default: 'Sec_Group_ID_1' + AWSSubnetID: + Type: AWS::EC2::Subnet::Id + Default: 'Sub_net_ID_1' + AWSVolumeID: + Type: AWS::EC2::Volume::Id + Default: 'Vol_ID_1' + AWSVPCID: + Type: AWS::EC2::VPC::Id + Default: 'VPC_ID_1' + AWSHostedZoneID: + Type: AWS::Route53::HostedZone::Id + Default: 'Hosted_Zone_ID_1' + AWSParameterValue: + Type: AWS::SSM::Parameter::Value + Default: 'Parameter_SSM_1' + StringParameterList: + Type: List + Default: + - 'String' + - 'Other srtring' + NumberParameterList: + Type: List + Default: + - 1 + - 2 + AWSZoneParameterList: + Type: List + Default: + - 'us-east-1' + - 'us-east-2' + AWSImageIDList: + Type: List + Default: + - 'Image_ID_1' + - 'Image_ID_2' + AWSInstanceIDList: + Type: List + Default: + - 'Instance_ID_1' + - 'Instance_ID_2' + AWSSecurityGroupNameList: + Type: AWS::EC2::SecurityGroup::GroupName + Default: + - 'Group_Name_1' + - 'Group_Name_2' + AWSSecurityGroupIDList: + Type: List + Default: + - 'Sec_Group_ID_1' + - 'Sec_Group_ID_2' + AWSSubnetIDList: + Type: List + Default: + - 'Sub_net_ID_1' + - 'Sub_net_ID_2' + AWSVolumeIDList: + Type: List + Default: + - 'Vol_ID_1' + - 'Vol_ID_2' + AWSVPCIDList: + Type: List + Default: + - 'VPC_ID_1' + - 'VPC_ID_2' + AWSHostedZoneIDList: + Type: List + Default: + - 'Hosted_Zone_ID_1' + - 'Hosted_Zone_ID_2' + BadTypeParameter: + Type: OtherThatIsNotOnTheEnumLikeTheOnesAbove + Default: 'This will trigger an error' +Resources: + MyApi: + Type: AWS::Serverless::Api + Properties: + StageName: Stage Name diff --git a/tests/validator/input/root/success_minimal_template_with_parameters.yaml b/tests/validator/input/root/success_minimal_template_with_parameters.yaml new file mode 100644 index 000000000..a153ec8f2 --- /dev/null +++ b/tests/validator/input/root/success_minimal_template_with_parameters.yaml @@ -0,0 +1,105 @@ +# Smallest possible API template +Transform: AWS::Serverless-2016-10-31 +Parameters: + StringParameter: + Type: String + Default: 'String' + NumberParameter: + Type: Number + Default: 2 + CommaDelimitedListParameter: + Type: CommaDelimitedList + Default: 'String,1,6' + AWSZoneParameter: + Type: "AWS::EC2::AvailabilityZone::Name" + Default: 'us-east-1' + AWSImageId: + Type: AWS::EC2::Image::Id + Default: 'Image_ID_1' + AWSInstanceID: + Type: AWS::EC2::Instance::Id + Default: 'Instance_ID_1' + AWSKeyPairName: + Type: AWS::EC2::KeyPair::KeyName + Default: 'Key_Name_1' + AWSSecurityGroupName: + Type: AWS::EC2::SecurityGroup::GroupName + Default: 'Group_Name_1' + AWSSecurityGroupID: + Type: AWS::EC2::SecurityGroup::Id + Default: 'Sec_Group_ID_1' + AWSSubnetID: + Type: AWS::EC2::Subnet::Id + Default: 'Sub_net_ID_1' + AWSVolumeID: + Type: AWS::EC2::Volume::Id + Default: 'Vol_ID_1' + AWSVPCID: + Type: AWS::EC2::VPC::Id + Default: 'VPC_ID_1' + AWSHostedZoneID: + Type: AWS::Route53::HostedZone::Id + Default: 'Hosted_Zone_ID_1' + AWSParameterValue: + Type: AWS::SSM::Parameter::Value + Default: 'Parameter_SSM_1' + StringParameterList: + Type: List + Default: + - 'String' + - 'Other srtring' + NumberParameterList: + Type: List + Default: + - 1 + - 2 + AWSZoneParameterList: + Type: List + Default: + - 'us-east-1' + - 'us-east-2' + AWSImageIDList: + Type: List + Default: + - 'Image_ID_1' + - 'Image_ID_2' + AWSInstanceIDList: + Type: List + Default: + - 'Instance_ID_1' + - 'Instance_ID_2' + AWSSecurityGroupNameList: + Type: AWS::EC2::SecurityGroup::GroupName + Default: + - 'Group_Name_1' + - 'Group_Name_2' + AWSSecurityGroupIDList: + Type: List + Default: + - 'Sec_Group_ID_1' + - 'Sec_Group_ID_2' + AWSSubnetIDList: + Type: List + Default: + - 'Sub_net_ID_1' + - 'Sub_net_ID_2' + AWSVolumeIDList: + Type: List + Default: + - 'Vol_ID_1' + - 'Vol_ID_2' + AWSVPCIDList: + Type: List + Default: + - 'VPC_ID_1' + - 'VPC_ID_2' + AWSHostedZoneID: + Type: List + Default: + - 'Hosted_Zone_ID_1' + - 'Hosted_Zone_ID_2' +Resources: + MyApi: + Type: AWS::Serverless::Api + Properties: + StageName: Stage Name \ No newline at end of file diff --git a/tests/validator/output/root/error_minimal_template_with_parameters.json b/tests/validator/output/root/error_minimal_template_with_parameters.json new file mode 100644 index 000000000..8b85bc35d --- /dev/null +++ b/tests/validator/output/root/error_minimal_template_with_parameters.json @@ -0,0 +1,3 @@ +[ +"[Parameters.BadTypeParameter.Type] 'OtherThatIsNotOnTheEnumLikeTheOnesAbove' is not one of ['String', 'Number', 'List', 'CommaDelimitedList', 'AWS::EC2::AvailabilityZone::Name', 'AWS::EC2::Image::Id', 'AWS::EC2::Instance::Id', 'AWS::EC2::KeyPair::KeyName', 'AWS::EC2::SecurityGroup::GroupName', 'AWS::EC2::SecurityGroup::Id', 'AWS::EC2::Subnet::Id', 'AWS::EC2::Volume::Id', 'AWS::EC2::VPC::Id', 'AWS::Route53::HostedZone::Id', 'List', 'List', 'List', 'List', 'List', 'List', 'List', 'List', 'List', 'List', 'AWS::SSM::Parameter::Value']" +] \ No newline at end of file diff --git a/tests/validator/test_validator_root.py b/tests/validator/test_validator_root.py index b404f0464..f343834be 100644 --- a/tests/validator/test_validator_root.py +++ b/tests/validator/test_validator_root.py @@ -16,6 +16,7 @@ class TestValidatorRoot(TestValidatorBase): [ "error_awstemplateformatversion_unknown", "error_empty_template", + "error_minimal_template_with_parameters", "error_resources_empty", "error_resources_missing", "error_resources_not_object", @@ -28,6 +29,7 @@ def test_errors(self, template): @parameterized.expand( [ + "success_minimal_template_with_parameters", "success_minimal_template", ], )