AWS::CloudFormation::ModuleDefaultVersion - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::CloudFormation::ModuleDefaultVersion

Specifies the default version of a module. The default version of the module will be used in CloudFormation operations for this account and Region.

To register a module version, use the AWS::CloudFormation::ModuleVersion resource.

For more information using modules, see Using modules to encapsulate and reuse resource configurations and Registering extensions in the Amazon CloudFormation User Guide. For information on developing modules, see Developing modules in the Amazon CloudFormation CLI User Guide.

Syntax

To declare this entity in your Amazon CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::CloudFormation::ModuleDefaultVersion", "Properties" : { "Arn" : String, "ModuleName" : String, "VersionId" : String } }

YAML

Type: AWS::CloudFormation::ModuleDefaultVersion Properties: Arn: String ModuleName: String VersionId: String

Properties

Arn

The Amazon Resource Name (ARN) of the module version to set as the default version.

Conditional: You must specify either Arn, or ModuleName and VersionId.

Required: Conditional

Type: String

Pattern: ^arn:aws[A-Za-z0-9-]{0,64}:cloudformation:[A-Za-z0-9-]{1,64}:([0-9]{12})?:type/module/.+/[0-9]{8}$

Update requires: Replacement

ModuleName

The name of the module.

Conditional: You must specify either Arn, or ModuleName and VersionId.

Required: Conditional

Type: String

Pattern: ^[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::MODULE

Update requires: Replacement

VersionId

The ID for the specific version of the module.

Conditional: You must specify either Arn, or ModuleName and VersionId.

Required: Conditional

Type: String

Pattern: ^[0-9]{8}$

Update requires: Replacement

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the Amazon Resource Name (ARN) of the module version.

For more information about using the Ref function, see Ref.

Remarks

Considerations when managing the default module version:

  • The first module version to be registered in an account and Region remains the default version CloudFormation uses, unless and until you explicitly sets another version as the default.

  • For ease of determining which module version is the default version, we recommend that you only include a single AWS::CloudFormation::ModuleDefaultVersion resource for a given module in a template.

  • If you delete an AWS::CloudFormation::ModuleVersion resource, either by deleting it from a stack or deleting the entire stack, CloudFormation marks the corresponding module version as DEPRECATED.

    If you attempt to delete an AWS::CloudFormation::ModuleVersion resource that represent the default version, the operation will fail if there are other active versions.

    For more information on deprecating module versions, see DeregisterType in the Amazon CloudFormation API Reference.

Examples

Specifying the default module version

The following example registers two versions of a module, and then sets the second version as the default version for CloudFormation to use. Note that the example uses the DependsOn attribute to ensure that CloudFormation provisions version one before version two.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "ModuleVersion1": { "Type": "AWS::CloudFormation::ModuleVersion", "Properties": { "ModuleName": "My::Sample::Test::MODULE", "ModulePackage": "s3://my-sample-moduleversion-bucket/sample-module-package-v1.zip" } }, "ModuleVersion2": { "Type": "AWS::CloudFormation::ModuleVersion", "Properties": { "ModuleName": "My::Sample::Test::MODULE", "ModulePackage": "s3://my-sample-moduleversion-bucket/sample-module-package-v2.zip" }, "DependsOn": "ModuleVersion1" }, "ModuleDefaultVersion": { "Type": "AWS::CloudFormation::ModuleDefaultVersion", "Properties": { "Arn": { "Ref": "ModuleVersion2" } } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Resources: ModuleVersion1: Type: 'AWS::CloudFormation::ModuleVersion' Properties: ModuleName: 'My::Sample::Test::MODULE' ModulePackage: 's3://my-sample-moduleversion-bucket/sample-module-package-v1.zip' ModuleVersion2: Type: 'AWS::CloudFormation::ModuleVersion' Properties: ModuleName: 'My::Sample::Test::MODULE' ModulePackage: 's3://my-sample-moduleversion-bucket/sample-module-package-v2.zip' DependsOn: ModuleVersion1 ModuleDefaultVersion: Type: 'AWS::CloudFormation::ModuleDefaultVersion' Properties: Arn: !Ref ModuleVersion2