Fn

class aws_cdk.core.Fn

Bases: object

CloudFormation intrinsic functions. http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html.

Static Methods

classmethod base64(data)

The intrinsic function Fn::Base64 returns the Base64 representation of the input string.

This function is typically used to pass encoded data to Amazon EC2 instances by way of the UserData property.

Parameters

data (str) – The string value you want to convert to Base64.

return :rtype: str :return: a token represented as a string

classmethod cidr(ip_block, count, size_mask=None)

The intrinsic function Fn::Cidr returns the specified Cidr address block.

Parameters
  • ip_block (str) – The user-specified default Cidr address block.

  • count (Union[int, float]) – The number of subnets’ Cidr block wanted. Count can be 1 to 256.

  • size_mask (Optional[str]) – The digit covered in the subnet.

return :rtype: List[str] :return: a token represented as a string

classmethod condition_and(*conditions)

Returns true if all the specified conditions evaluate to true, or returns false if any one of the conditions evaluates to false.

Fn::And acts as an AND operator. The minimum number of conditions that you can include is 2, and the maximum is 10.

Parameters

conditions (ICfnConditionExpression) – conditions to AND.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_contains(list_of_strings, value)

Returns true if a specified string matches at least one value in a list of strings.

Parameters
  • list_of_strings (List[str]) – A list of strings, such as “A”, “B”, “C”.

  • value (str) – A string, such as “A”, that you want to compare against a list of strings.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_each_member_equals(list_of_strings, value)

Returns true if a specified string matches all values in a list.

Parameters
  • list_of_strings (List[str]) – A list of strings, such as “A”, “B”, “C”.

  • value (str) – A string, such as “A”, that you want to compare against a list of strings.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_each_member_in(strings_to_check, strings_to_match)

Returns true if each member in a list of strings matches at least one value in a second list of strings.

Parameters
  • strings_to_check (List[str]) – A list of strings, such as “A”, “B”, “C”. AWS CloudFormation checks whether each member in the strings_to_check parameter is in the strings_to_match parameter.

  • strings_to_match (List[str]) – A list of strings, such as “A”, “B”, “C”. Each member in the strings_to_match parameter is compared against the members of the strings_to_check parameter.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_equals(lhs, rhs)

Compares if two values are equal.

Returns true if the two values are equal or false if they aren’t.

Parameters
  • lhs (Any) – A value of any type that you want to compare.

  • rhs (Any) – A value of any type that you want to compare.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_if(condition_id, value_if_true, value_if_false)

Returns one value if the specified condition evaluates to true and another value if the specified condition evaluates to false.

Currently, AWS CloudFormation supports the Fn::If intrinsic function in the metadata attribute, update policy attribute, and property values in the Resources section and Outputs sections of a template. You can use the AWS::NoValue pseudo parameter as a return value to remove the corresponding property.

Parameters
  • condition_id (str) – A reference to a condition in the Conditions section. Use the condition’s name to reference it.

  • value_if_true (Any) – A value to be returned if the specified condition evaluates to true.

  • value_if_false (Any) – A value to be returned if the specified condition evaluates to false.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_not(condition)

Returns true for a condition that evaluates to false or returns false for a condition that evaluates to true.

Fn::Not acts as a NOT operator.

Parameters

condition (ICfnConditionExpression) – A condition such as Fn::Equals that evaluates to true or false.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod condition_or(*conditions)

Returns true if any one of the specified conditions evaluate to true, or returns false if all of the conditions evaluates to false.

Fn::Or acts as an OR operator. The minimum number of conditions that you can include is 2, and the maximum is 10.

Parameters

conditions (ICfnConditionExpression) – conditions that evaluates to true or false.

return :rtype: ICfnConditionExpression :return: an FnCondition token

classmethod find_in_map(map_name, top_level_key, second_level_key)

The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.

Parameters
  • map_name (str) –

  • top_level_key (str) –

  • second_level_key (str) –

return :rtype: str :return: a token represented as a string

classmethod get_att(logical_name_of_resource, attribute_name)

The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.

Parameters
  • logical_name_of_resource (str) – The logical name (also called logical ID) of the resource that contains the attribute that you want.

  • attribute_name (str) – The name of the resource-specific attribute whose value you want. See the resource’s reference page for details about the attributes available for that resource type.

return :rtype: IResolvable :return: an IResolvable object

classmethod get_azs(region=None)

The intrinsic function Fn::GetAZs returns an array that lists Availability Zones for a specified region.

Because customers have access to different Availability Zones, the intrinsic function Fn::GetAZs enables template authors to write templates that adapt to the calling user’s access. That way you don’t have to hard-code a full list of Availability Zones for a specified region.

Parameters

region (Optional[str]) – The name of the region for which you want to get the Availability Zones. You can use the AWS::Region pseudo parameter to specify the region in which the stack is created. Specifying an empty string is equivalent to specifying AWS::Region.

return :rtype: List[str] :return: a token represented as a string array

classmethod import_value(shared_value_to_import)

The intrinsic function Fn::ImportValue returns the value of an output exported by another stack.

You typically use this function to create cross-stack references. In the following example template snippets, Stack A exports VPC security group values and Stack B imports them.

Parameters

shared_value_to_import (str) – The stack output value that you want to import.

return :rtype: str :return: a token represented as a string

classmethod join(delimiter, list_of_values)

The intrinsic function Fn::Join appends a set of values into a single value, separated by the specified delimiter.

If a delimiter is the empty string, the set of values are concatenated with no delimiter.

Parameters
  • delimiter (str) – The value you want to occur between fragments. The delimiter will occur between fragments only. It will not terminate the final value.

  • list_of_values (List[str]) – The list of values you want combined.

return :rtype: str :return: a token represented as a string

classmethod ref_all(parameter_type)

Returns all values for a specified parameter type.

Parameters

parameter_type (str) – An AWS-specific parameter type, such as AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. For more information, see Parameters in the AWS CloudFormation User Guide.

return :rtype: List[str] :return: a token represented as a string array

classmethod select(index, array)

The intrinsic function Fn::Select returns a single object from a list of objects by index.

Parameters
  • index (Union[int, float]) – The index of the object to retrieve. This must be a value from zero to N-1, where N represents the number of elements in the array.

  • array (List[str]) – The list of objects to select from. This list must not be null, nor can it have null entries.

return :rtype: str :return: a token represented as a string

classmethod split(delimiter, source)

To split a string into a list of string values so that you can select an element from the resulting string list, use the Fn::Split intrinsic function.

Specify the location of splits with a delimiter, such as , (a comma). After you split a string, use the Fn::Select function to pick a specific element.

Parameters
  • delimiter (str) – A string value that determines where the source string is divided.

  • source (str) – The string value that you want to split.

return :rtype: List[str] :return: a token represented as a string array

classmethod sub(body, variables=None)

The intrinsic function Fn::Sub substitutes variables in an input string with values that you specify.

In your templates, you can use this function to construct commands or outputs that include values that aren’t available until you create or update a stack.

Parameters
  • body (str) – A string with variables that AWS CloudFormation substitutes with their associated values at runtime. Write variables as ${MyVarName}. Variables can be template parameter names, resource logical IDs, resource attributes, or a variable in a key-value map. If you specify only template parameter names, resource logical IDs, and resource attributes, don’t specify a key-value map.

  • variables (Optional[Mapping[str, str]]) – The name of a variable that you included in the String parameter. The value that AWS CloudFormation substitutes for the associated variable name at runtime.

return :rtype: str :return: a token represented as a string

classmethod value_of(parameter_or_logical_id, attribute)

Returns an attribute value or list of values for a specific parameter and attribute.

Parameters
  • parameter_or_logical_id (str) – The name of a parameter for which you want to retrieve attribute values. The parameter must be declared in the Parameters section of the template.

  • attribute (str) – The name of an attribute from which you want to retrieve a value.

return :rtype: str :return: a token represented as a string

classmethod value_of_all(parameter_type, attribute)

Returns a list of all attribute values for a given parameter type and attribute.

Parameters
  • parameter_type (str) – An AWS-specific parameter type, such as AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. For more information, see Parameters in the AWS CloudFormation User Guide.

  • attribute (str) – The name of an attribute from which you want to retrieve a value. For more information about attributes, see Supported Attributes.

return :rtype: List[str] :return: a token represented as a string array