Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions samcli/commands/_utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"],
Expand Down
14 changes: 14 additions & 0 deletions samcli/lib/package/packageable_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -442,6 +454,8 @@ class GlueJobCommandScriptLocationResource(ResourceZip):
ServerlessLayerVersionResource,
LambdaLayerVersionResource,
GlueJobCommandScriptLocationResource,
CloudFormationModuleVersionModulePackage,
CloudFormationResourceVersionSchemaHandlerPackage,
]

METADATA_EXPORT_LIST = [ServerlessRepoApplicationReadme, ServerlessRepoApplicationLicense]
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/package/test_package_command_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/unit/lib/package/test_artifact_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
AppSyncFunctionConfigurationRequestTemplateResource,
AppSyncFunctionConfigurationResponseTemplateResource,
GlueJobCommandScriptLocationResource,
CloudFormationModuleVersionModulePackage,
CloudFormationResourceVersionSchemaHandlerPackage,
ResourceZip,
ResourceImage,
)
Expand Down Expand Up @@ -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:
Expand Down