AWS CloudFormation Concepts Intrinsic Functions: Difference between revisions
(→Ref) |
|||
Line 11: | Line 11: | ||
{{External|[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html Ref]}} | {{External|[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html Ref]}} | ||
The intrinsic function Ref returns the value of the | The intrinsic function Ref returns the value of the object it refers to, such as a [[AWS_CloudFormation_Concepts#Input_Parameters|parameter]] or [[AWS_CloudFormation_Concepts#Resources|resource]]. When a parameter logical name is specified, it returns the value of the parameter. When a resource logical name is specified, it returns a value that can be typically used to refer to that resource, such as a physical ID. | ||
!Ref AWS::StackName | !Ref AWS::StackName |
Revision as of 16:00, 21 March 2019
External
Internal
Ref
The intrinsic function Ref returns the value of the object it refers to, such as a parameter or resource. When a parameter logical name is specified, it returns the value of the parameter. When a resource logical name is specified, it returns a value that can be typically used to refer to that resource, such as a physical ID.
!Ref AWS::StackName !Ref MyParameter !Ref MyResourceName
Join
!Join [ delimiter, [ comma-delimited list of values ] ]
!Join ['-', [ a, b, c ]]
returns "a:b:c"
Split
!Split ['.', "www.example.com"]
returns ["www", "example", "com"].
Select
Sub
Sub substitutes variables in an input string with specified values.
If only template parameters, resource logical IDs and resource attributes are substituted in the String parameter, no variable map is required:
!Sub '${TemplateParameterA} is a ${TemplateParameterB}' !Sub '${AWS::Region}-something'
ImportValue
The Fn::ImportValue returns the value of an output exported by another stack. The function is used to create cross-stack references.
Can be used as a key in a YAML structure:
... ServiceRole: Fn::ImportValue: ...
or a value:
... EnvironmentVariables: - Name: TARGET_BUCKET Value: Fn::ImportValue: !Sub '${AWS::Region}-BuildBucket'
FindInMap
!FindInMap [ MapName, TopLevelKey, SecondLevelKey ]