Amazon Web Services CloudFormation Stack SBT Plugin
An sbt plugin to deploy a CloudFormation stack generated by the project. Create a main class in the project that accepts a file path as its first argument, and write the stack's CloudFormation template to the given file.
Installation and Enabling
Add the following to project/plugins.sbt
addSbtPlugin("com.dwolla.sbt" % "sbt-cloudformation-stack" % "{version-number}")
Then, enable the plugin by adding something like the following to build.sbt
:
val app = (project in file(".")).enablePlugins(CloudFormationStack)
Settings
templateJsonFilename
Filename of the generated JSON CloudFormation template.
stackName
Name of the stack. Defaults the normalized name of the project.
stackParameters
List of key-value pairs that will be provided to the stack as parameters. These can accept task or setting values; e.g., S3 bucket and keys from the S3 Publisher plugin.
stackParameters ++= List(
"S3Bucket" → s3Bucket.value,
"S3Key" → s3Key.value
)
changeSetName
If supplied, CloudFormation will create a change set to allow stack creates or update to be evaluated before being completed.
Tasks
generate
Runs the main class of the project, passing templateJson
as the first argument.
deploy
Creates or updates a CloudFormation stack using the generated JSON template.
Commands
withDeployParameters
Allows certain deploy parameters to be set on the command line, with some input validation. The parameters that will be overridden are as follows:
-
awsAccountId
must be a 12-digit AWS Account ID -
awsRoleName
must match the patternrole/{name}
, and the value will be set to{name}
-
stackRoleArn
will be set to a full ARN ifawsAccountId
andawsRoleName
are set, or toNone
if either are missing -
deployEnvironment
must be one of the values indeployEnvironmentOptions
, and will add a stack parameter named usingdeployEnvironmentParameterName
.The default
deployEnvironmentParameterName
isEnvironment
, so settingdeployEnvironment
toAdmin
would add a stack parameter namedEnvironment
with the valueAdmin
.
Note that all these will be set if the command is invoked. Missing values will be set to None
. The parameters can be passed in any order.
For example,
sbt "withDeployParameters 123456789012 role/myRole Admin" deploy
will add a stack parameter Environment → Admin
and create or update the stack using the AWS role arn:aws:iam::123456789012:role/myRole
.