Class Fn

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.Fn
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-22T02:23:55.794Z") @Stability(Stable) public class Fn extends software.amazon.jsii.JsiiObject
CloudFormation intrinsic functions.

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

Example:

 import software.amazon.awscdk.*;
 Bucket destinationBucket;
 BucketDeployment myBucketDeployment = BucketDeployment.Builder.create(this, "DeployMeWithoutExtractingFilesOnDestination")
         .sources(List.of(Source.asset(join(__dirname, "my-website"))))
         .destinationBucket(destinationBucket)
         .extract(false)
         .build();
 CfnOutput.Builder.create(this, "ObjectKey")
         .value(Fn.select(0, myBucketDeployment.getObjectKeys()))
         .build();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Fn(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Fn(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    base64(String data)
    The intrinsic function Fn::Base64 returns the Base64 representation of the input string.
    static List<String>
    cidr(String ipBlock, Number count)
    The intrinsic function Fn::Cidr returns the specified Cidr address block.
    static List<String>
    cidr(String ipBlock, Number count, String sizeMask)
    The intrinsic function Fn::Cidr returns the specified Cidr address block.
    conditionAnd(@NotNull ICfnConditionExpression... conditions)
    Returns true if all the specified conditions evaluate to true, or returns false if any one of the conditions evaluates to false.
    conditionContains(List<String> listOfStrings, String value)
    Returns true if a specified string matches at least one value in a list of strings.
    conditionEachMemberEquals(List<String> listOfStrings, String value)
    Returns true if a specified string matches all values in a list.
    conditionEachMemberIn(List<String> stringsToCheck, List<String> stringsToMatch)
    Returns true if each member in a list of strings matches at least one value in a second list of strings.
    Compares if two values are equal.
    conditionIf(String conditionId, Object valueIfTrue, Object valueIfFalse)
    Returns one value if the specified condition evaluates to true and another value if the specified condition evaluates to false.
    Returns true for a condition that evaluates to false or returns false for a condition that evaluates to true.
    conditionOr(@NotNull ICfnConditionExpression... conditions)
    Returns true if any one of the specified conditions evaluate to true, or returns false if all of the conditions evaluates to false.
    static String
    findInMap(String mapName, String topLevelKey, String secondLevelKey)
    The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.
    static String
    findInMap(String mapName, String topLevelKey, String secondLevelKey, String defaultValue)
    The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.
    getAtt(String logicalNameOfResource, String attributeName)
    The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.
    static List<String>
    The intrinsic function Fn::GetAZs returns an array that lists Availability Zones for a specified region.
    static List<String>
    getAzs(String region)
    The intrinsic function Fn::GetAZs returns an array that lists Availability Zones for a specified region.
    static List<String>
    importListValue(String sharedValueToImport, Number assumedLength)
    Like Fn.importValue, but import a list with a known length.
    static List<String>
    importListValue(String sharedValueToImport, Number assumedLength, String delimiter)
    Like Fn.importValue, but import a list with a known length.
    static String
    importValue(String sharedValueToImport)
    The intrinsic function Fn::ImportValue returns the value of an output exported by another stack.
    static String
    join(String delimiter, List<String> listOfValues)
    The intrinsic function Fn::Join appends a set of values into a single value, separated by the specified delimiter.
    static Number
    len(Object array)
    The intrinsic function Fn::Length returns the number of elements within an array or an intrinsic function that returns an array.
    static String
    Given an url, parse the domain name.
    static String
    ref(String logicalName)
    The Ref intrinsic function returns the value of the specified parameter or resource.
    static List<String>
    refAll(String parameterType)
    Returns all values for a specified parameter type.
    static String
    select(Number index, List<String> array)
    The intrinsic function Fn::Select returns a single object from a list of objects by index.
    static List<String>
    split(String delimiter, String source)
    Split a string token into a token list of string values.
    static List<String>
    split(String delimiter, String source, Number assumedLength)
    Split a string token into a token list of string values.
    static String
    sub(String body)
    The intrinsic function Fn::Sub substitutes variables in an input string with values that you specify.
    static String
    sub(String body, Map<String,String> variables)
    The intrinsic function Fn::Sub substitutes variables in an input string with values that you specify.
    static String
    The Fn::ToJsonString intrinsic function converts an object or array to its corresponding JSON string.
    transform(String macroName, Map<String,? extends Object> parameters)
    Creates a token representing the Fn::Transform expression.
    static String
    valueOf(String parameterOrLogicalId, String attribute)
    Returns an attribute value or list of values for a specific parameter and attribute.
    static List<String>
    valueOfAll(String parameterType, String attribute)
    Returns a list of all attribute values for a given parameter type and attribute.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • Fn

      protected Fn(software.amazon.jsii.JsiiObjectRef objRef)
    • Fn

      protected Fn(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
  • Method Details

    • base64

      @Stability(Stable) @NotNull public static String base64(@NotNull String 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 - The string value you want to convert to Base64. This parameter is required.
      Returns:
      a token represented as a string
    • cidr

      @Stability(Stable) @NotNull public static List<String> cidr(@NotNull String ipBlock, @NotNull Number count, @Nullable String sizeMask)
      The intrinsic function Fn::Cidr returns the specified Cidr address block.

      Parameters:
      ipBlock - The user-specified default Cidr address block. This parameter is required.
      count - The number of subnets' Cidr block wanted. This parameter is required.
      sizeMask - The digit covered in the subnet.
      Returns:
      a token represented as a string
    • cidr

      @Stability(Stable) @NotNull public static List<String> cidr(@NotNull String ipBlock, @NotNull Number count)
      The intrinsic function Fn::Cidr returns the specified Cidr address block.

      Parameters:
      ipBlock - The user-specified default Cidr address block. This parameter is required.
      count - The number of subnets' Cidr block wanted. This parameter is required.
      Returns:
      a token represented as a string
    • conditionAnd

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionAnd(@NotNull @NotNull ICfnConditionExpression... 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 1.

      Parameters:
      conditions - conditions to AND. This parameter is required.
      Returns:
      an FnCondition token
    • conditionContains

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionContains(@NotNull List<String> listOfStrings, @NotNull String value)
      Returns true if a specified string matches at least one value in a list of strings.

      Parameters:
      listOfStrings - A list of strings, such as "A", "B", "C". This parameter is required.
      value - A string, such as "A", that you want to compare against a list of strings. This parameter is required.
      Returns:
      an FnCondition token
    • conditionEachMemberEquals

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionEachMemberEquals(@NotNull List<String> listOfStrings, @NotNull String value)
      Returns true if a specified string matches all values in a list.

      Parameters:
      listOfStrings - A list of strings, such as "A", "B", "C". This parameter is required.
      value - A string, such as "A", that you want to compare against a list of strings. This parameter is required.
      Returns:
      an FnCondition token
    • conditionEachMemberIn

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionEachMemberIn(@NotNull List<String> stringsToCheck, @NotNull List<String> stringsToMatch)
      Returns true if each member in a list of strings matches at least one value in a second list of strings.

      Parameters:
      stringsToCheck - A list of strings, such as "A", "B", "C". This parameter is required.
      stringsToMatch - A list of strings, such as "A", "B", "C". This parameter is required.
      Returns:
      an FnCondition token
    • conditionEquals

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionEquals(@NotNull Object lhs, @NotNull Object rhs)
      Compares if two values are equal.

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

      Parameters:
      lhs - A value of any type that you want to compare. This parameter is required.
      rhs - A value of any type that you want to compare. This parameter is required.
      Returns:
      an FnCondition token
    • conditionIf

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionIf(@NotNull String conditionId, @NotNull Object valueIfTrue, @NotNull Object valueIfFalse)
      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:
      conditionId - A reference to a condition in the Conditions section. This parameter is required.
      valueIfTrue - A value to be returned if the specified condition evaluates to true. This parameter is required.
      valueIfFalse - A value to be returned if the specified condition evaluates to false. This parameter is required.
      Returns:
      an FnCondition token
    • conditionNot

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionNot(@NotNull ICfnConditionExpression 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 - A condition such as Fn::Equals that evaluates to true or false. This parameter is required.
      Returns:
      an FnCondition token
    • conditionOr

      @Stability(Stable) @NotNull public static ICfnRuleConditionExpression conditionOr(@NotNull @NotNull ICfnConditionExpression... 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 1.

      Parameters:
      conditions - conditions that evaluates to true or false. This parameter is required.
      Returns:
      an FnCondition token
    • findInMap

      @Stability(Stable) @NotNull public static String findInMap(@NotNull String mapName, @NotNull String topLevelKey, @NotNull String secondLevelKey, @Nullable String defaultValue)
      The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.

      Warning: do not use with lazy mappings as this function will not guarentee a lazy mapping to render in the template. Prefer to use CfnMapping.findInMap in general.

      Parameters:
      mapName - This parameter is required.
      topLevelKey - This parameter is required.
      secondLevelKey - This parameter is required.
      defaultValue -
      Returns:
      a token represented as a string
    • findInMap

      @Stability(Stable) @NotNull public static String findInMap(@NotNull String mapName, @NotNull String topLevelKey, @NotNull String secondLevelKey)
      The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.

      Warning: do not use with lazy mappings as this function will not guarentee a lazy mapping to render in the template. Prefer to use CfnMapping.findInMap in general.

      Parameters:
      mapName - This parameter is required.
      topLevelKey - This parameter is required.
      secondLevelKey - This parameter is required.
      Returns:
      a token represented as a string
    • getAtt

      @Stability(Stable) @NotNull public static IResolvable getAtt(@NotNull String logicalNameOfResource, @NotNull String attributeName)
      The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.

      Parameters:
      logicalNameOfResource - The logical name (also called logical ID) of the resource that contains the attribute that you want. This parameter is required.
      attributeName - The name of the resource-specific attribute whose value you want. This parameter is required.
      Returns:
      an IResolvable object
    • getAzs

      @Stability(Stable) @NotNull public static List<String> getAzs(@Nullable String region)
      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 - The name of the region for which you want to get the Availability Zones.
      Returns:
      a token represented as a string array
    • getAzs

      @Stability(Stable) @NotNull public static List<String> getAzs()
      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.

      Returns:
      a token represented as a string array
    • importListValue

      @Stability(Stable) @NotNull public static List<String> importListValue(@NotNull String sharedValueToImport, @NotNull Number assumedLength, @Nullable String delimiter)
      Like Fn.importValue, but import a list with a known length.

      If you explicitly want a list with an unknown length, call Fn.split(',', Fn.importValue(exportName)). See the documentation of Fn.split to read more about the limitations of using lists of unknown length.

      Fn.importListValue(exportName, assumedLength) is the same as Fn.split(',', Fn.importValue(exportName), assumedLength), but easier to read and impossible to forget to pass assumedLength.

      Parameters:
      sharedValueToImport - This parameter is required.
      assumedLength - This parameter is required.
      delimiter -
    • importListValue

      @Stability(Stable) @NotNull public static List<String> importListValue(@NotNull String sharedValueToImport, @NotNull Number assumedLength)
      Like Fn.importValue, but import a list with a known length.

      If you explicitly want a list with an unknown length, call Fn.split(',', Fn.importValue(exportName)). See the documentation of Fn.split to read more about the limitations of using lists of unknown length.

      Fn.importListValue(exportName, assumedLength) is the same as Fn.split(',', Fn.importValue(exportName), assumedLength), but easier to read and impossible to forget to pass assumedLength.

      Parameters:
      sharedValueToImport - This parameter is required.
      assumedLength - This parameter is required.
    • importValue

      @Stability(Stable) @NotNull public static String importValue(@NotNull String sharedValueToImport)
      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:
      sharedValueToImport - The stack output value that you want to import. This parameter is required.
      Returns:
      a token represented as a string
    • join

      @Stability(Stable) @NotNull public static String join(@NotNull String delimiter, @NotNull List<String> listOfValues)
      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 - The value you want to occur between fragments. This parameter is required.
      listOfValues - The list of values you want combined. This parameter is required.
      Returns:
      a token represented as a string
    • len

      @Stability(Stable) @NotNull public static Number len(@NotNull Object array)
      The intrinsic function Fn::Length returns the number of elements within an array or an intrinsic function that returns an array.

      Parameters:
      array - The array you want to return the number of elements from. This parameter is required.
    • parseDomainName

      @Stability(Stable) @NotNull public static String parseDomainName(@NotNull String url)
      Given an url, parse the domain name.

      Parameters:
      url - the url to parse. This parameter is required.
    • ref

      @Stability(Stable) @NotNull public static String ref(@NotNull String logicalName)
      The Ref intrinsic function returns the value of the specified parameter or resource.

      Note that it doesn't validate the logicalName, it mainly serves parameter/resource reference defined in a CfnInclude template.

      Parameters:
      logicalName - The logical name of a parameter/resource for which you want to retrieve its value. This parameter is required.
    • refAll

      @Stability(Stable) @NotNull public static List<String> refAll(@NotNull String parameterType)
      Returns all values for a specified parameter type.

      Parameters:
      parameterType - An AWS-specific parameter type, such as AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. This parameter is required.
      Returns:
      a token represented as a string array
    • select

      @Stability(Stable) @NotNull public static String select(@NotNull Number index, @NotNull List<String> array)
      The intrinsic function Fn::Select returns a single object from a list of objects by index.

      Parameters:
      index - The index of the object to retrieve. This parameter is required.
      array - The list of objects to select from. This parameter is required.
      Returns:
      a token represented as a string
    • split

      @Stability(Stable) @NotNull public static List<String> split(@NotNull String delimiter, @NotNull String source, @Nullable Number assumedLength)
      Split a string token into a token list of string values.

      Specify the location of splits with a delimiter such as ',' (a comma). Renders to the Fn::Split intrinsic function.

      Lists with unknown lengths (default)

      Since this function is used to work with deploy-time values, if assumedLength is not given the CDK cannot know the length of the resulting list at synthesis time. This brings the following restrictions:

      • You must use Fn.select(i, list) to pick elements out of the list (you must not use list[i]).
      • You cannot add elements to the list, remove elements from the list, combine two such lists together, or take a slice of the list.
      • You cannot pass the list to constructs that do any of the above.

      The only valid operation with such a tokenized list is to pass it unmodified to a CloudFormation Resource construct.

      Lists with assumed lengths

      Pass assumedLength if you know the length of the list that will be produced by splitting. The actual list length at deploy time may be longer than the number you pass, but not shorter.

      The returned list will look like:

       [Fn.select(0, split), Fn.select(1, split), Fn.select(2, split), ...]
       

      The restrictions from the section "Lists with unknown lengths" will now be lifted, at the expense of having to know and fix the length of the list.

      Parameters:
      delimiter - A string value that determines where the source string is divided. This parameter is required.
      source - The string value that you want to split. This parameter is required.
      assumedLength - The length of the list that will be produced by splitting.
      Returns:
      a token represented as a string array
    • split

      @Stability(Stable) @NotNull public static List<String> split(@NotNull String delimiter, @NotNull String source)
      Split a string token into a token list of string values.

      Specify the location of splits with a delimiter such as ',' (a comma). Renders to the Fn::Split intrinsic function.

      Lists with unknown lengths (default)

      Since this function is used to work with deploy-time values, if assumedLength is not given the CDK cannot know the length of the resulting list at synthesis time. This brings the following restrictions:

      • You must use Fn.select(i, list) to pick elements out of the list (you must not use list[i]).
      • You cannot add elements to the list, remove elements from the list, combine two such lists together, or take a slice of the list.
      • You cannot pass the list to constructs that do any of the above.

      The only valid operation with such a tokenized list is to pass it unmodified to a CloudFormation Resource construct.

      Lists with assumed lengths

      Pass assumedLength if you know the length of the list that will be produced by splitting. The actual list length at deploy time may be longer than the number you pass, but not shorter.

      The returned list will look like:

       [Fn.select(0, split), Fn.select(1, split), Fn.select(2, split), ...]
       

      The restrictions from the section "Lists with unknown lengths" will now be lifted, at the expense of having to know and fix the length of the list.

      Parameters:
      delimiter - A string value that determines where the source string is divided. This parameter is required.
      source - The string value that you want to split. This parameter is required.
      Returns:
      a token represented as a string array
    • sub

      @Stability(Stable) @NotNull public static String sub(@NotNull String body, @Nullable Map<String,String> variables)
      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 - A string with variables that AWS CloudFormation substitutes with their associated values at runtime. This parameter is required.
      variables - The name of a variable that you included in the String parameter.
      Returns:
      a token represented as a string
    • sub

      @Stability(Stable) @NotNull public static String sub(@NotNull String body)
      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 - A string with variables that AWS CloudFormation substitutes with their associated values at runtime. This parameter is required.
      Returns:
      a token represented as a string
    • toJsonString

      @Stability(Stable) @NotNull public static String toJsonString(@NotNull Object object)
      The Fn::ToJsonString intrinsic function converts an object or array to its corresponding JSON string.

      Parameters:
      object - The object or array to stringify. This parameter is required.
    • transform

      @Stability(Stable) @NotNull public static IResolvable transform(@NotNull String macroName, @NotNull Map<String,? extends Object> parameters)
      Creates a token representing the Fn::Transform expression.

      Parameters:
      macroName - The name of the macro to perform the processing. This parameter is required.
      parameters - The parameters to be passed to the macro. This parameter is required.
      Returns:
      a token representing the transform expression
      See Also:
    • valueOf

      @Stability(Stable) @NotNull public static String valueOf(@NotNull String parameterOrLogicalId, @NotNull String attribute)
      Returns an attribute value or list of values for a specific parameter and attribute.

      Parameters:
      parameterOrLogicalId - The name of a parameter for which you want to retrieve attribute values. This parameter is required.
      attribute - The name of an attribute from which you want to retrieve a value. This parameter is required.
      Returns:
      a token represented as a string
    • valueOfAll

      @Stability(Stable) @NotNull public static List<String> valueOfAll(@NotNull String parameterType, @NotNull String attribute)
      Returns a list of all attribute values for a given parameter type and attribute.

      Parameters:
      parameterType - An AWS-specific parameter type, such as AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. This parameter is required.
      attribute - The name of an attribute from which you want to retrieve a value. This parameter is required.
      Returns:
      a token represented as a string array