
LambdaSharp Module Syntax
A LambdaSharp module is divided into three main components: details about the module, required dependencies, and item definitions, such as parameters, variables, resources, and functions.
Parameter values are provided at module deployment time. Optionally, parameters can act as conditional resources that are created when a parameter value is omitted.
Variables hold intermediate results that can be shared with other item definitions in the module. Variables are inlined during compilation and don't appear in the final output unless shared publicly.
Parameters, variables, and resources can be shared with other modules by making them public. These can then be imported using cross-module references. Alternatively, they can be scoped as stack, which makes them only available in a nested stack.
Functions can be wired up to respond to various event sources, such as SQS, SNS, API Gateway, or even Slack Commands. Functions can be implemented using C# or Javascript.
The LambdaSharp CLI build command compiles the module into a CloudFormation template. The publish command uploads the artifacts to the deployment bucket. Finally, the deploy command creates/updates a CloudFormation stack.
Syntax
Module: String
Version: String
Origin: String
Description: String
Pragmas:
- PragmaDefinition
Secrets:
- String
Using:
- UsingDefinition
Items:
- ItemDefinition
Properties
Description-
The
Descriptionattribute specifies the description for the CloudFormation stack.Required: No
Type: String
Items-
The
Itemssection specifies the items defined in the module, such as parameters, variables, resources, conditions, mappings, functions, nested stacks, resource type definitions, macro definitions, and module imports.Required: No
Type: List of Item Definition
Module-
The
Moduleattribute specifies the full name of the module. It must be formatted asNamespace.Name.The module namespace and name can be retrieved using the
!Refoperations withModule::NamespaceandModule::Name, respectively. Alternatively, the full name can be retrieved usingModule::FullName.Required: Yes
Type: String
Origin-
The
Originattribute specifies the origin S3 bucket of the module. When omitted, the origin information is filled in when the module is published to an S3 bucket.Required: No
Type: String
Pragmas-
The
Pragmassection specifies directives that change the default compiler behavior.Required: No
Type: List of Pragma Definition
Using-
The
Usingsection specifies LambdaSharp modules that are used by this module. During the build phase, the manifests of the used modules are imported to validate their parameters and attributes. During the deploy phase, the used modules are automatically deployed when missing.Required: No
Type: List of Using Definition
Secrets-
The
Secretssection specifies which KMS keys can be used to decrypt parameter values. The module IAM role will get permission to use these keys (mks:Decryptetc.).Required: No
Type: List of String (see Secrets Section)
Version-
The
Versionattribute specifies the version of the LambdaSharp module. The format of the version must beMajor.Minor[.Build[.Revision]][-Suffix]. Components in square brackets ([]) are optional and can be omitted. The presence of the-Suffixelement indicates a pre-release version.The module version can be accessed as a variable in
!Suboperations using the${Module::Version}.Required: No
Type: String
Intrinsic Functions
CloudFormation intrinsic functions are supported in item definitions where values can be specified.
!Include
LambdaSharp modules can use the !Include pre-processor directive to include plain text files as strings or YAML files as nested objects. The !Include directive can be used anywhere in a YAML file.
Example
Module: My.Module
Items:
- !Include MyFirstItem