diff --git a/samcli/commands/_utils/resources.py b/samcli/commands/_utils/resources.py index dd10880eed..d3b2a18be3 100644 --- a/samcli/commands/_utils/resources.py +++ b/samcli/commands/_utils/resources.py @@ -14,6 +14,8 @@ AWS_LAMBDA_FUNCTION = "AWS::Lambda::Function" AWS_APIGATEWAY_RESTAPI = "AWS::ApiGateway::RestApi" AWS_ELASTICBEANSTALK_APPLICATIONVERSION = "AWS::ElasticBeanstalk::ApplicationVersion" +AWS_CLOUDFORMATION_MODULEVERSION = "AWS::CloudFormation::ModuleVersion" +AWS_CLOUDFORMATION_RESOURCEVERSION = "AWS::CloudFormation::ResourceVersion" AWS_CLOUDFORMATION_STACK = "AWS::CloudFormation::Stack" AWS_SERVERLESS_APPLICATION = "AWS::Serverless::Application" AWS_LAMBDA_LAYERVERSION = "AWS::Lambda::LayerVersion" @@ -35,6 +37,8 @@ AWS_LAMBDA_FUNCTION: ["Code"], AWS_APIGATEWAY_RESTAPI: ["BodyS3Location"], AWS_ELASTICBEANSTALK_APPLICATIONVERSION: ["SourceBundle"], + AWS_CLOUDFORMATION_MODULEVERSION: ["ModulePackage"], + AWS_CLOUDFORMATION_RESOURCEVERSION: ["SchemaHandlerPackage"], AWS_CLOUDFORMATION_STACK: ["TemplateURL"], AWS_SERVERLESS_APPLICATION: ["Location"], AWS_LAMBDA_LAYERVERSION: ["Content"], diff --git a/samcli/lib/package/packageable_resources.py b/samcli/lib/package/packageable_resources.py index d4d20327e4..edb99074d8 100644 --- a/samcli/lib/package/packageable_resources.py +++ b/samcli/lib/package/packageable_resources.py @@ -40,6 +40,8 @@ AWS_SERVERLESS_LAYERVERSION, AWS_GLUE_JOB, AWS_STEPFUNCTIONS_STATEMACHINE, + AWS_CLOUDFORMATION_MODULEVERSION, + AWS_CLOUDFORMATION_RESOURCEVERSION, METADATA_WITH_LOCAL_PATHS, RESOURCES_WITH_LOCAL_PATHS, RESOURCES_WITH_IMAGE_COMPONENT, @@ -423,6 +425,16 @@ class GlueJobCommandScriptLocationResource(ResourceZip): PROPERTY_NAME = RESOURCES_WITH_LOCAL_PATHS[AWS_GLUE_JOB][0] +class CloudFormationModuleVersionModulePackage(ResourceZip): + RESOURCE_TYPE = AWS_CLOUDFORMATION_MODULEVERSION + PROPERTY_NAME = RESOURCES_WITH_LOCAL_PATHS[AWS_CLOUDFORMATION_MODULEVERSION][0] + + +class CloudFormationResourceVersionSchemaHandlerPackage(ResourceZip): + RESOURCE_TYPE = AWS_CLOUDFORMATION_RESOURCEVERSION + PROPERTY_NAME = RESOURCES_WITH_LOCAL_PATHS[AWS_CLOUDFORMATION_RESOURCEVERSION][0] + + RESOURCES_EXPORT_LIST = [ ServerlessFunctionResource, ServerlessFunctionImageResource, @@ -442,6 +454,8 @@ class GlueJobCommandScriptLocationResource(ResourceZip): ServerlessLayerVersionResource, LambdaLayerVersionResource, GlueJobCommandScriptLocationResource, + CloudFormationModuleVersionModulePackage, + CloudFormationResourceVersionSchemaHandlerPackage, ] METADATA_EXPORT_LIST = [ServerlessRepoApplicationReadme, ServerlessRepoApplicationLicense] diff --git a/tests/integration/package/test_package_command_zip.py b/tests/integration/package/test_package_command_zip.py index 4a266023c8..e60157a5bf 100644 --- a/tests/integration/package/test_package_command_zip.py +++ b/tests/integration/package/test_package_command_zip.py @@ -52,6 +52,8 @@ def test_package_template_flag(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -99,6 +101,8 @@ def test_package_without_required_args(self): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -139,6 +143,8 @@ def test_package_with_prefix(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -191,6 +197,8 @@ def test_package_with_output_template_file(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -244,6 +252,8 @@ def test_package_with_json(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -299,6 +309,8 @@ def test_package_with_force_upload(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -352,6 +364,8 @@ def test_package_with_kms_key(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", @@ -404,6 +418,8 @@ def test_package_with_metadata(self, template_file): "aws-lambda-function.yaml", "aws-apigateway-restapi.yaml", "aws-elasticbeanstalk-applicationversion.yaml", + "aws-cloudformation-moduleversion.yaml", + "aws-cloudformation-resourceversion.yaml", "aws-cloudformation-stack.yaml", "aws-serverless-application.yaml", "aws-lambda-layerversion.yaml", diff --git a/tests/integration/testdata/package/aws-cloudformation-moduleversion.yaml b/tests/integration/testdata/package/aws-cloudformation-moduleversion.yaml new file mode 100644 index 0000000000..2fd082ef33 --- /dev/null +++ b/tests/integration/testdata/package/aws-cloudformation-moduleversion.yaml @@ -0,0 +1,10 @@ +AWSTemplateFormatVersion : '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: Simple Stack + +Resources: + MyResourceVersion: + Type: AWS::CloudFormation::ModuleVersion + Properties: + ModulePackage: ./sourcebundle.zip + ModuleName: Company::Service::Module diff --git a/tests/integration/testdata/package/aws-cloudformation-resourceversion.yaml b/tests/integration/testdata/package/aws-cloudformation-resourceversion.yaml new file mode 100644 index 0000000000..003ca684ae --- /dev/null +++ b/tests/integration/testdata/package/aws-cloudformation-resourceversion.yaml @@ -0,0 +1,10 @@ +AWSTemplateFormatVersion : '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: Simple Stack + +Resources: + MyResourceVersion: + Type: AWS::CloudFormation::ResourceVersion + Properties: + SchemaHandlerPackage: ./sourcebundle.zip + TypeName: Company::Service::Resource diff --git a/tests/unit/lib/package/test_artifact_exporter.py b/tests/unit/lib/package/test_artifact_exporter.py index 64b3538ecd..f1a793ecf3 100644 --- a/tests/unit/lib/package/test_artifact_exporter.py +++ b/tests/unit/lib/package/test_artifact_exporter.py @@ -47,6 +47,8 @@ AppSyncFunctionConfigurationRequestTemplateResource, AppSyncFunctionConfigurationResponseTemplateResource, GlueJobCommandScriptLocationResource, + CloudFormationModuleVersionModulePackage, + CloudFormationResourceVersionSchemaHandlerPackage, ResourceZip, ResourceImage, ) @@ -93,6 +95,8 @@ def test_all_resources_export(self): {"class": ServerlessRepoApplicationLicense, "expected_result": uploaded_s3_url}, {"class": ServerlessRepoApplicationLicense, "expected_result": uploaded_s3_url}, {"class": GlueJobCommandScriptLocationResource, "expected_result": {"ScriptLocation": uploaded_s3_url}}, + {"class": CloudFormationModuleVersionModulePackage, "expected_result": uploaded_s3_url}, + {"class": CloudFormationResourceVersionSchemaHandlerPackage, "expected_result": uploaded_s3_url}, ] with patch("samcli.lib.package.packageable_resources.upload_local_artifacts") as upload_local_artifacts_mock: