diff --git a/cloudformation/intrinsics.go b/cloudformation/intrinsics.go index 0f7a6f6b42..c293326e01 100644 --- a/cloudformation/intrinsics.go +++ b/cloudformation/intrinsics.go @@ -226,6 +226,17 @@ func Or(conditions []string) string { return encode(fmt.Sprintf(`{ "Fn::Or": [ %v ] }`, printList(conditions))) } +// (str, map[str]str) -> str + +func TransformFn(name string, parameters map[string]string) string { + var params []string + for key, value := range parameters { + params = append(params, fmt.Sprintf(`"%v" : "%v"`, key, value)) + } + + return encode(fmt.Sprintf(`{ "Fn::Transform" : { "Name" : "%v", "Parameters" : { "%v" } } }`, name, strings.Trim(strings.Join(params, `, `), `, "`))) +} + // encode takes a string representation of an intrinsic function, and base64 encodes it. // This prevents the escaping issues when nesting multiple layers of intrinsic functions. func encode(value string) string { diff --git a/intrinsics/fntransform.go b/intrinsics/fntransform.go new file mode 100644 index 0000000000..e9e008d30b --- /dev/null +++ b/intrinsics/fntransform.go @@ -0,0 +1,8 @@ +package intrinsics + +func FnTransform(name string, input interface{}, template interface{}) interface{} { + + // { "Fn::Transform" : { "Name" : "macro name", "Parameters" : {"key" : "value", ... } } } + + return nil +} diff --git a/intrinsics/intrinsics.go b/intrinsics/intrinsics.go index 1ba1cb673a..5380749725 100644 --- a/intrinsics/intrinsics.go +++ b/intrinsics/intrinsics.go @@ -34,6 +34,7 @@ var defaultIntrinsicHandlers = map[string]IntrinsicHandler{ "Fn::Sub": FnSub, "Ref": Ref, "Fn::Cidr": nonResolvingHandler, + "Fn::Transform": FnTransform, } // ProcessorOptions allows customisation of the intrinsic function processor behaviour.