diff --git a/README.md b/README.md index 3fa00a32..a1a30f28 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/scala/com/monsanto/arch/cloudformation/model.scala b/src/main/scala/com/monsanto/arch/cloudformation/model.scala index 5d519728..b7e1daed 100644 --- a/src/main/scala/com/monsanto/arch/cloudformation/model.scala +++ b/src/main/scala/com/monsanto/arch/cloudformation/model.scala @@ -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)