java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggableV2, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.109.0 (build c221850)", date="2025-03-13T18:54:58.561Z") @Stability(Stable) public class CfnFlow extends CfnResource implements IInspectable, ITaggableV2
Creates a prompt flow that you can use to send an input through various steps to yield an output.

You define a flow by configuring nodes, each of which corresponds to a step of the flow, and creating connections between the nodes to create paths to different outputs. You can define the flow in one of the following ways:

  • Define a FlowDefinition in the Definition property.
  • Provide the definition in the DefinitionString property as a JSON-formatted string matching the FlowDefinition property.
  • Provide an Amazon S3 location in the DefinitionS3Location property that matches the FlowDefinition .

If you use the DefinitionString or DefinitionS3Location property, you can use the DefinitionSubstitutions property to define key-value pairs to replace at runtime.

For more information, see How it works and Create a prompt flow in Amazon Bedrock in the Amazon Bedrock User Guide.

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.bedrock.*;
 Object collector;
 Object input;
 Object iterator;
 Object output;
 CfnFlow cfnFlow = CfnFlow.Builder.create(this, "MyCfnFlow")
         .executionRoleArn("executionRoleArn")
         .name("name")
         // the properties below are optional
         .customerEncryptionKeyArn("customerEncryptionKeyArn")
         .definition(FlowDefinitionProperty.builder()
                 .connections(List.of(FlowConnectionProperty.builder()
                         .name("name")
                         .source("source")
                         .target("target")
                         .type("type")
                         // the properties below are optional
                         .configuration(FlowConnectionConfigurationProperty.builder()
                                 .conditional(FlowConditionalConnectionConfigurationProperty.builder()
                                         .condition("condition")
                                         .build())
                                 .data(FlowDataConnectionConfigurationProperty.builder()
                                         .sourceOutput("sourceOutput")
                                         .targetInput("targetInput")
                                         .build())
                                 .build())
                         .build()))
                 .nodes(List.of(FlowNodeProperty.builder()
                         .name("name")
                         .type("type")
                         // the properties below are optional
                         .configuration(FlowNodeConfigurationProperty.builder()
                                 .agent(AgentFlowNodeConfigurationProperty.builder()
                                         .agentAliasArn("agentAliasArn")
                                         .build())
                                 .collector(collector)
                                 .condition(ConditionFlowNodeConfigurationProperty.builder()
                                         .conditions(List.of(FlowConditionProperty.builder()
                                                 .name("name")
                                                 // the properties below are optional
                                                 .expression("expression")
                                                 .build()))
                                         .build())
                                 .input(input)
                                 .iterator(iterator)
                                 .knowledgeBase(KnowledgeBaseFlowNodeConfigurationProperty.builder()
                                         .knowledgeBaseId("knowledgeBaseId")
                                         // the properties below are optional
                                         .guardrailConfiguration(GuardrailConfigurationProperty.builder()
                                                 .guardrailIdentifier("guardrailIdentifier")
                                                 .guardrailVersion("guardrailVersion")
                                                 .build())
                                         .modelId("modelId")
                                         .build())
                                 .lambdaFunction(LambdaFunctionFlowNodeConfigurationProperty.builder()
                                         .lambdaArn("lambdaArn")
                                         .build())
                                 .lex(LexFlowNodeConfigurationProperty.builder()
                                         .botAliasArn("botAliasArn")
                                         .localeId("localeId")
                                         .build())
                                 .output(output)
                                 .prompt(PromptFlowNodeConfigurationProperty.builder()
                                         .sourceConfiguration(PromptFlowNodeSourceConfigurationProperty.builder()
                                                 .inline(PromptFlowNodeInlineConfigurationProperty.builder()
                                                         .modelId("modelId")
                                                         .templateConfiguration(PromptTemplateConfigurationProperty.builder()
                                                                 .text(TextPromptTemplateConfigurationProperty.builder()
                                                                         .text("text")
                                                                         // the properties below are optional
                                                                         .inputVariables(List.of(PromptInputVariableProperty.builder()
                                                                                 .name("name")
                                                                                 .build()))
                                                                         .build())
                                                                 .build())
                                                         .templateType("templateType")
                                                         // the properties below are optional
                                                         .inferenceConfiguration(PromptInferenceConfigurationProperty.builder()
                                                                 .text(PromptModelInferenceConfigurationProperty.builder()
                                                                         .maxTokens(123)
                                                                         .stopSequences(List.of("stopSequences"))
                                                                         .temperature(123)
                                                                         .topP(123)
                                                                         .build())
                                                                 .build())
                                                         .build())
                                                 .resource(PromptFlowNodeResourceConfigurationProperty.builder()
                                                         .promptArn("promptArn")
                                                         .build())
                                                 .build())
                                         // the properties below are optional
                                         .guardrailConfiguration(GuardrailConfigurationProperty.builder()
                                                 .guardrailIdentifier("guardrailIdentifier")
                                                 .guardrailVersion("guardrailVersion")
                                                 .build())
                                         .build())
                                 .retrieval(RetrievalFlowNodeConfigurationProperty.builder()
                                         .serviceConfiguration(RetrievalFlowNodeServiceConfigurationProperty.builder()
                                                 .s3(RetrievalFlowNodeS3ConfigurationProperty.builder()
                                                         .bucketName("bucketName")
                                                         .build())
                                                 .build())
                                         .build())
                                 .storage(StorageFlowNodeConfigurationProperty.builder()
                                         .serviceConfiguration(StorageFlowNodeServiceConfigurationProperty.builder()
                                                 .s3(StorageFlowNodeS3ConfigurationProperty.builder()
                                                         .bucketName("bucketName")
                                                         .build())
                                                 .build())
                                         .build())
                                 .build())
                         .inputs(List.of(FlowNodeInputProperty.builder()
                                 .expression("expression")
                                 .name("name")
                                 .type("type")
                                 .build()))
                         .outputs(List.of(FlowNodeOutputProperty.builder()
                                 .name("name")
                                 .type("type")
                                 .build()))
                         .build()))
                 .build())
         .definitionS3Location(S3LocationProperty.builder()
                 .bucket("bucket")
                 .key("key")
                 // the properties below are optional
                 .version("version")
                 .build())
         .definitionString("definitionString")
         .definitionSubstitutions(Map.of(
                 "definitionSubstitutionsKey", "definitionSubstitutions"))
         .description("description")
         .tags(Map.of(
                 "tagsKey", "tags"))
         .testAliasTags(Map.of(
                 "testAliasTagsKey", "testAliasTags"))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnFlow

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

      protected CfnFlow(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnFlow

      @Stability(Stable) public CfnFlow(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnFlowProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrArn

      @Stability(Stable) @NotNull public String getAttrArn()
      The Amazon Resource Name (ARN) of the flow.
    • getAttrCreatedAt

      @Stability(Stable) @NotNull public String getAttrCreatedAt()
      The time at which the flow was created.
    • getAttrId

      @Stability(Stable) @NotNull public String getAttrId()
      The unique identifier of the flow.
    • getAttrStatus

      @Stability(Stable) @NotNull public String getAttrStatus()
      The status of the flow. The following statuses are possible:.

      • NotPrepared – The flow has been created or updated, but hasn't been prepared. If you just created the flow, you can't test it. If you updated the flow, the DRAFT version won't contain the latest changes for testing. Send a PrepareFlow request to package the latest changes into the DRAFT version.
      • Preparing – The flow is being prepared so that the DRAFT version contains the latest changes for testing.
      • Prepared – The flow is prepared and the DRAFT version contains the latest changes for testing.
      • Failed – The last API operation that you invoked on the flow failed. Send a GetFlow request and check the error message in the validations field.
    • getAttrUpdatedAt

      @Stability(Stable) @NotNull public String getAttrUpdatedAt()
      The time at which the flow was last updated.
    • getAttrValidations

      @Stability(Stable) @NotNull public IResolvable getAttrValidations()
      List of flow validations.
    • getAttrVersion

      @Stability(Stable) @NotNull public String getAttrVersion()
      The latest version of the flow.
    • getCdkTagManager

      @Stability(Stable) @NotNull public TagManager getCdkTagManager()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getCdkTagManager in interface ITaggableV2
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getExecutionRoleArn

      @Stability(Stable) @NotNull public String getExecutionRoleArn()
      The Amazon Resource Name (ARN) of the service role with permissions to create a flow.
    • setExecutionRoleArn

      @Stability(Stable) public void setExecutionRoleArn(@NotNull String value)
      The Amazon Resource Name (ARN) of the service role with permissions to create a flow.
    • getName

      @Stability(Stable) @NotNull public String getName()
      The name of the flow.
    • setName

      @Stability(Stable) public void setName(@NotNull String value)
      The name of the flow.
    • getCustomerEncryptionKeyArn

      @Stability(Stable) @Nullable public String getCustomerEncryptionKeyArn()
      The Amazon Resource Name (ARN) of the KMS key that the flow is encrypted with.
    • setCustomerEncryptionKeyArn

      @Stability(Stable) public void setCustomerEncryptionKeyArn(@Nullable String value)
      The Amazon Resource Name (ARN) of the KMS key that the flow is encrypted with.
    • getDefinition

      @Stability(Stable) @Nullable public Object getDefinition()
      The definition of the nodes and connections between the nodes in the flow.
    • setDefinition

      @Stability(Stable) public void setDefinition(@Nullable IResolvable value)
      The definition of the nodes and connections between the nodes in the flow.
    • setDefinition

      @Stability(Stable) public void setDefinition(@Nullable CfnFlow.FlowDefinitionProperty value)
      The definition of the nodes and connections between the nodes in the flow.
    • getDefinitionS3Location

      @Stability(Stable) @Nullable public Object getDefinitionS3Location()
      The Amazon S3 location of the flow definition.
    • setDefinitionS3Location

      @Stability(Stable) public void setDefinitionS3Location(@Nullable IResolvable value)
      The Amazon S3 location of the flow definition.
    • setDefinitionS3Location

      @Stability(Stable) public void setDefinitionS3Location(@Nullable CfnFlow.S3LocationProperty value)
      The Amazon S3 location of the flow definition.
    • getDefinitionString

      @Stability(Stable) @Nullable public String getDefinitionString()
      The definition of the flow as a JSON-formatted string.
    • setDefinitionString

      @Stability(Stable) public void setDefinitionString(@Nullable String value)
      The definition of the flow as a JSON-formatted string.
    • getDefinitionSubstitutions

      @Stability(Stable) @Nullable public Object getDefinitionSubstitutions()
      A map that specifies the mappings for placeholder variables in the prompt flow definition.
    • setDefinitionSubstitutions

      @Stability(Stable) public void setDefinitionSubstitutions(@Nullable IResolvable value)
      A map that specifies the mappings for placeholder variables in the prompt flow definition.
    • setDefinitionSubstitutions

      @Stability(Stable) public void setDefinitionSubstitutions(@Nullable Map<String,Object> value)
      A map that specifies the mappings for placeholder variables in the prompt flow definition.
    • getDescription

      @Stability(Stable) @Nullable public String getDescription()
      A description of the flow.
    • setDescription

      @Stability(Stable) public void setDescription(@Nullable String value)
      A description of the flow.
    • getTags

      @Stability(Stable) @Nullable public Map<String,String> getTags()
      Metadata that you can assign to a resource as key-value pairs.

      For more information, see the following resources:.

    • setTags

      @Stability(Stable) public void setTags(@Nullable Map<String,String> value)
      Metadata that you can assign to a resource as key-value pairs.

      For more information, see the following resources:.

    • getTestAliasTags

      @Stability(Stable) @Nullable public Object getTestAliasTags()
      A map of tag keys and values.
    • setTestAliasTags

      @Stability(Stable) public void setTestAliasTags(@Nullable Map<String,String> value)
      A map of tag keys and values.
    • setTestAliasTags

      @Stability(Stable) public void setTestAliasTags(@Nullable IResolvable value)
      A map of tag keys and values.