SBT plugin for validation of CloudFormation templates and operating AWS CloudFormations.
The plugin by default uses the default credential provider supplied by AWS SDK.
If you have already setup AWS CLI, you don't have to do any additional configurations.
Note that AWS_DEFAULT_REGION environment variable must also be set. For setting up AWS CLI, see the setup instructions.
In your plugins.sbt add:
resolvers += "SBT release" at "https://dl.bintray.com/sbt/sbt-plugin-releases/"
addSbtPlugin("com.github.tptodorov" % "sbt-cloudformation" % "0.7.1")
In your build.sbt add:
// or any parameters required by your template
stackParams in Staging := Map("NumberWithRange" -> "2", "StringWithLength" -> "longstring")
// tag your stack
stackTags in Staging := Map("env" -> "staging", "app" -> "sample")
By default, there are two configurations: staging and production. For each configuration, the following settings are defined and used for task execution:
stackTemplate- source of a CloudFormation template. By default, the first.templatefound insrc/main/awsfolder.stackParams- map of template parametersstackTags- map of tags assigned to new stacksstackRegion- region where the stack is created. By default,AWS_DEFAULT_REGIONenvironment is used.stackName- name of the stack. By default, is in the form<artifactId>-<configuration>
For full list of settings, see Keys
stackValidatevalidates CloudFormation *.template files. Supports~ stackValidatecommand as well.stackCreatecreates a stack. Does not block until create is completestackUpdateupdates a stack.stackDeletedeletes a stack.stackDescribedescribes a stack.stackStatusreturns the current stack statusstackWaitblocks while the stack is in any of thePROGRESSstates (see Usage below)
All tasks, except stackWait, return immediately.
-
Template Validation - all
*.templatefiles insrc/main/awsare validated during compilation. Continuous validation while you are developing your templates can be done by:sbt ~stackValidateYou can also specify where your templates are:
templatesSourceFolder <<= baseDirectory { _ / "src/main/resources" }Most of the time, it is useful to add the template validation as part of the compilation process:
compile in Compile <<= (compile in Compile) dependsOn stackValidate -
Create/Update/Delete a stack and wait for it to complete.
sbt " ; staging:stackCreate ; export staging:stackWait "sbt " ; staging:stackUpdate ; export staging:stackWait "sbt " ; staging:stackDelete ; export staging:stackWait "
Sample has a simple working setup.