Table of contents
Join
In CloudFormation you can concatenate Strings and intrinsic functions using Fn::Join
Info of
Fn::Join
from AWS can be found here
We have simplified how this works in KloudFormation by providing the plus operator.
You can concatenate any Reference, Value<String>
or Attribute as follows:
val sgName = parameter<String>("Name") securityGroup(groupDescription = +"Description-" + sgName.ref() + "-XYZ")
Tip: If the first element is a
String
then you need the unary plus to make itValue<String>
Produces
SecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription:
Fn::Join:
- ""
- - "Description-"
- Ref: "Name"
- "-XYZ"
By default the plus operator will create an instance of Join
and will apply no splitter between elements.
If you want to supply a splitter you will need to create an instance of Join
:
securityGroup(groupDescription = Join("-", listOf(+"Description", sgName.ref(), +"XYZ")))