Skip to content

Commit

Permalink
Merge 2995525 into e65fe09
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersouthwick committed Feb 5, 2016
2 parents e65fe09 + 2995525 commit c5043a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ which will construct an ARN from the AWS account, region, and this default funct

Credit for the Lambda function script: http://www.spacevatican.org/2015/12/20/cloudformation-nat-gateway/

## Working with Cloudformation Concatenating
In the CloudFormation DSL, there is support for concatenating strings, parameters, and function calls together to build strings.
This can get really ugly as they are chained together.
There is a [string interpolator](http://monsantoco.github.io/cloudformation-template-generator/latest/api/#com.monsanto.arch.cloudformation.model.package$$AwsStringInterpolator) to make this easier.

## Releasing

This project uses the sbt release plugin. After the changes you want to
Expand Down
19 changes: 18 additions & 1 deletion src/main/scala/com/monsanto/arch/cloudformation/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,24 @@ package object model {

implicit def parameter2TokenString(parameter : StringParameter) : Token[String] = ParameterRef(parameter)

implicit class AwsToken(val sc: StringContext) extends AnyVal {
/**
* Provides a string interpolator to assist in the concatenation of
*
* The following:
* {{{
* import com.monsanto.arch.cloudformation.model._
*
* val param = ParameterRef(StringParameter("that"))
* val fun = aws"test\$param"
* }}}
*
* Will generate the following FunctionCall definition:
* {{{
* FunctionCallToken(`Fn::Join`("", Seq(StringToken("test"), param)))
* }}}
*
*/
implicit class AwsStringInterpolator(val sc: StringContext) extends AnyVal {

def aws(tokens: Token[String]*) = AwsStringInterpolation(sc, tokens)

Expand Down

0 comments on commit c5043a5

Please sign in to comment.