io.cloudshiftdev.awscdk.services.stepfunctions.tasks.LambdaInvoke.kt Maven / Gradle / Ivy
The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package io.cloudshiftdev.awscdk.services.stepfunctions.tasks
import io.cloudshiftdev.awscdk.Duration
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import io.cloudshiftdev.awscdk.services.lambda.IFunction
import io.cloudshiftdev.awscdk.services.stepfunctions.Credentials
import io.cloudshiftdev.awscdk.services.stepfunctions.IntegrationPattern
import io.cloudshiftdev.awscdk.services.stepfunctions.TaskInput
import io.cloudshiftdev.awscdk.services.stepfunctions.TaskStateBase
import io.cloudshiftdev.awscdk.services.stepfunctions.Timeout
import kotlin.Any
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.String
import kotlin.Unit
import kotlin.collections.Map
import kotlin.jvm.JvmName
import io.cloudshiftdev.constructs.Construct as CloudshiftdevConstructsConstruct
import software.constructs.Construct as SoftwareConstructsConstruct
/**
* Invoke a Lambda function as a Task.
*
* Example:
*
* ```
* Function fn;
* LambdaInvoke.Builder.create(this, "Invoke with empty object as payload")
* .lambdaFunction(fn)
* .payload(TaskInput.fromObject(Map.of()))
* .build();
* // use the output of fn as input
* // use the output of fn as input
* LambdaInvoke.Builder.create(this, "Invoke with payload field in the state input")
* .lambdaFunction(fn)
* .payload(TaskInput.fromJsonPathAt("$.Payload"))
* .build();
* ```
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html)
*/
public open class LambdaInvoke(
cdkObject: software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke,
) : TaskStateBase(cdkObject) {
public constructor(
scope: CloudshiftdevConstructsConstruct,
id: String,
props: LambdaInvokeProps,
) :
this(software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
id, props.let(LambdaInvokeProps.Companion::unwrap))
)
public constructor(
scope: CloudshiftdevConstructsConstruct,
id: String,
props: LambdaInvokeProps.Builder.() -> Unit,
) : this(scope, id, LambdaInvokeProps(props)
)
/**
* A fluent builder for [io.cloudshiftdev.awscdk.services.stepfunctions.tasks.LambdaInvoke].
*/
@CdkDslMarker
public interface Builder {
/**
* Up to 3583 bytes of base64-encoded data about the invoking client to pass to the function.
*
* Default: - No context
*
* @param clientContext Up to 3583 bytes of base64-encoded data about the invoking client to
* pass to the function.
*/
public fun clientContext(clientContext: String)
/**
* An optional description for this state.
*
* Default: - No comment
*
* @param comment An optional description for this state.
*/
public fun comment(comment: String)
/**
* Credentials for an IAM Role that the State Machine assumes for executing the task.
*
* This enables cross-account resource invocations.
*
* Default: - None (Task is executed using the State Machine's execution role)
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html)
* @param credentials Credentials for an IAM Role that the State Machine assumes for executing
* the task.
*/
public fun credentials(credentials: Credentials)
/**
* Credentials for an IAM Role that the State Machine assumes for executing the task.
*
* This enables cross-account resource invocations.
*
* Default: - None (Task is executed using the State Machine's execution role)
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html)
* @param credentials Credentials for an IAM Role that the State Machine assumes for executing
* the task.
*/
@kotlin.Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("7c3f8577729b26bd57d5849d617d74f5dbdf86aae2ea7563644895440ab7d606")
public fun credentials(credentials: Credentials.Builder.() -> Unit)
/**
* (deprecated) Timeout for the heartbeat.
*
* Default: - None
*
* @deprecated use `heartbeatTimeout`
* @param heartbeat Timeout for the heartbeat.
*/
@Deprecated(message = "deprecated in CDK")
public fun heartbeat(heartbeat: Duration)
/**
* Timeout for the heartbeat.
*
* [disable-awslint:duration-prop-type] is needed because all props interface in
* aws-stepfunctions-tasks extend this interface
*
* Default: - None
*
* @param heartbeatTimeout Timeout for the heartbeat.
*/
public fun heartbeatTimeout(heartbeatTimeout: Timeout)
/**
* JSONPath expression to select part of the state to be the input to this state.
*
* May also be the special value JsonPath.DISCARD, which will cause the effective
* input to be the empty object {}.
*
* Default: - The entire task input (JSON path '$')
*
* @param inputPath JSONPath expression to select part of the state to be the input to this
* state.
*/
public fun inputPath(inputPath: String)
/**
* AWS Step Functions integrates with services directly in the Amazon States Language.
*
* You can control these AWS services using service integration patterns.
*
* Depending on the AWS Service, the Service Integration Pattern availability will vary.
*
* Default: - `IntegrationPattern.REQUEST_RESPONSE` for most tasks.
* `IntegrationPattern.RUN_JOB` for the following exceptions:
* `BatchSubmitJob`, `EmrAddStep`, `EmrCreateCluster`, `EmrTerminationCluster`, and
* `EmrContainersStartJobRun`.
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/connect-supported-services.html)
* @param integrationPattern AWS Step Functions integrates with services directly in the Amazon
* States Language.
*/
public fun integrationPattern(integrationPattern: IntegrationPattern)
/**
* Invocation type of the Lambda function.
*
* Default: InvocationType.REQUEST_RESPONSE
*
* @param invocationType Invocation type of the Lambda function.
*/
public fun invocationType(invocationType: LambdaInvocationType)
/**
* Lambda function to invoke.
*
* @param lambdaFunction Lambda function to invoke.
*/
public fun lambdaFunction(lambdaFunction: IFunction)
/**
* JSONPath expression to select select a portion of the state output to pass to the next state.
*
* May also be the special value JsonPath.DISCARD, which will cause the effective
* output to be the empty object {}.
*
* Default: - The entire JSON node determined by the state input, the task result,
* and resultPath is passed to the next state (JSON path '$')
*
* @param outputPath JSONPath expression to select select a portion of the state output to pass
* to the next state.
*/
public fun outputPath(outputPath: String)
/**
* The JSON that will be supplied as input to the Lambda function.
*
* Default: - The state input (JSON path '$')
*
* @param payload The JSON that will be supplied as input to the Lambda function.
*/
public fun payload(payload: TaskInput)
/**
* Invoke the Lambda in a way that only returns the payload response without additional
* metadata.
*
* The `payloadResponseOnly` property cannot be used if `integrationPattern`, `invocationType`,
* `clientContext`, or `qualifier` are specified.
* It always uses the REQUEST_RESPONSE behavior.
*
* Default: false
*
* @param payloadResponseOnly Invoke the Lambda in a way that only returns the payload response
* without additional metadata.
*/
public fun payloadResponseOnly(payloadResponseOnly: Boolean)
/**
* (deprecated) Version or alias to invoke a published version of the function.
*
* You only need to supply this if you want the version of the Lambda Function to depend
* on data in the state machine state. If not, you can pass the appropriate Alias or Version
* object
* directly as the `lambdaFunction` argument.
*
* Default: - Version or alias inherent to the `lambdaFunction` object.
*
* @deprecated pass a Version or Alias object as lambdaFunction instead
* @param qualifier Version or alias to invoke a published version of the function.
*/
@Deprecated(message = "deprecated in CDK")
public fun qualifier(qualifier: String)
/**
* JSONPath expression to indicate where to inject the state's output.
*
* May also be the special value JsonPath.DISCARD, which will cause the state's
* input to become its output.
*
* Default: - Replaces the entire input with the result (JSON path '$')
*
* @param resultPath JSONPath expression to indicate where to inject the state's output.
*/
public fun resultPath(resultPath: String)
/**
* The JSON that will replace the state's raw result and become the effective result before
* ResultPath is applied.
*
* You can use ResultSelector to create a payload with values that are static
* or selected from the state's raw result.
*
* Default: - None
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector)
* @param resultSelector The JSON that will replace the state's raw result and become the
* effective result before ResultPath is applied.
*/
public fun resultSelector(resultSelector: Map)
/**
* Whether to retry on Lambda service exceptions.
*
* This handles `Lambda.ServiceException`, `Lambda.AWSLambdaException`,
* `Lambda.SdkClientException`, and `Lambda.ClientExecutionTimeoutException`
* with an interval of 2 seconds, a back-off rate
* of 2 and 6 maximum attempts.
*
* Default: true
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/bp-lambda-serviceexception.html)
* @param retryOnServiceExceptions Whether to retry on Lambda service exceptions.
*/
public fun retryOnServiceExceptions(retryOnServiceExceptions: Boolean)
/**
* Optional name for this state.
*
* Default: - The construct ID will be used as state name
*
* @param stateName Optional name for this state.
*/
public fun stateName(stateName: String)
/**
* Timeout for the task.
*
* [disable-awslint:duration-prop-type] is needed because all props interface in
* aws-stepfunctions-tasks extend this interface
*
* Default: - None
*
* @param taskTimeout Timeout for the task.
*/
public fun taskTimeout(taskTimeout: Timeout)
/**
* (deprecated) Timeout for the task.
*
* Default: - None
*
* @deprecated use `taskTimeout`
* @param timeout Timeout for the task.
*/
@Deprecated(message = "deprecated in CDK")
public fun timeout(timeout: Duration)
}
private class BuilderImpl(
scope: SoftwareConstructsConstruct,
id: String,
) : Builder {
private val cdkBuilder: software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke.Builder
= software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke.Builder.create(scope, id)
/**
* Up to 3583 bytes of base64-encoded data about the invoking client to pass to the function.
*
* Default: - No context
*
* @param clientContext Up to 3583 bytes of base64-encoded data about the invoking client to
* pass to the function.
*/
override fun clientContext(clientContext: String) {
cdkBuilder.clientContext(clientContext)
}
/**
* An optional description for this state.
*
* Default: - No comment
*
* @param comment An optional description for this state.
*/
override fun comment(comment: String) {
cdkBuilder.comment(comment)
}
/**
* Credentials for an IAM Role that the State Machine assumes for executing the task.
*
* This enables cross-account resource invocations.
*
* Default: - None (Task is executed using the State Machine's execution role)
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html)
* @param credentials Credentials for an IAM Role that the State Machine assumes for executing
* the task.
*/
override fun credentials(credentials: Credentials) {
cdkBuilder.credentials(credentials.let(Credentials.Companion::unwrap))
}
/**
* Credentials for an IAM Role that the State Machine assumes for executing the task.
*
* This enables cross-account resource invocations.
*
* Default: - None (Task is executed using the State Machine's execution role)
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html)
* @param credentials Credentials for an IAM Role that the State Machine assumes for executing
* the task.
*/
@kotlin.Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("7c3f8577729b26bd57d5849d617d74f5dbdf86aae2ea7563644895440ab7d606")
override fun credentials(credentials: Credentials.Builder.() -> Unit): Unit =
credentials(Credentials(credentials))
/**
* (deprecated) Timeout for the heartbeat.
*
* Default: - None
*
* @deprecated use `heartbeatTimeout`
* @param heartbeat Timeout for the heartbeat.
*/
@Deprecated(message = "deprecated in CDK")
override fun heartbeat(heartbeat: Duration) {
cdkBuilder.heartbeat(heartbeat.let(Duration.Companion::unwrap))
}
/**
* Timeout for the heartbeat.
*
* [disable-awslint:duration-prop-type] is needed because all props interface in
* aws-stepfunctions-tasks extend this interface
*
* Default: - None
*
* @param heartbeatTimeout Timeout for the heartbeat.
*/
override fun heartbeatTimeout(heartbeatTimeout: Timeout) {
cdkBuilder.heartbeatTimeout(heartbeatTimeout.let(Timeout.Companion::unwrap))
}
/**
* JSONPath expression to select part of the state to be the input to this state.
*
* May also be the special value JsonPath.DISCARD, which will cause the effective
* input to be the empty object {}.
*
* Default: - The entire task input (JSON path '$')
*
* @param inputPath JSONPath expression to select part of the state to be the input to this
* state.
*/
override fun inputPath(inputPath: String) {
cdkBuilder.inputPath(inputPath)
}
/**
* AWS Step Functions integrates with services directly in the Amazon States Language.
*
* You can control these AWS services using service integration patterns.
*
* Depending on the AWS Service, the Service Integration Pattern availability will vary.
*
* Default: - `IntegrationPattern.REQUEST_RESPONSE` for most tasks.
* `IntegrationPattern.RUN_JOB` for the following exceptions:
* `BatchSubmitJob`, `EmrAddStep`, `EmrCreateCluster`, `EmrTerminationCluster`, and
* `EmrContainersStartJobRun`.
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/connect-supported-services.html)
* @param integrationPattern AWS Step Functions integrates with services directly in the Amazon
* States Language.
*/
override fun integrationPattern(integrationPattern: IntegrationPattern) {
cdkBuilder.integrationPattern(integrationPattern.let(IntegrationPattern.Companion::unwrap))
}
/**
* Invocation type of the Lambda function.
*
* Default: InvocationType.REQUEST_RESPONSE
*
* @param invocationType Invocation type of the Lambda function.
*/
override fun invocationType(invocationType: LambdaInvocationType) {
cdkBuilder.invocationType(invocationType.let(LambdaInvocationType.Companion::unwrap))
}
/**
* Lambda function to invoke.
*
* @param lambdaFunction Lambda function to invoke.
*/
override fun lambdaFunction(lambdaFunction: IFunction) {
cdkBuilder.lambdaFunction(lambdaFunction.let(IFunction.Companion::unwrap))
}
/**
* JSONPath expression to select select a portion of the state output to pass to the next state.
*
* May also be the special value JsonPath.DISCARD, which will cause the effective
* output to be the empty object {}.
*
* Default: - The entire JSON node determined by the state input, the task result,
* and resultPath is passed to the next state (JSON path '$')
*
* @param outputPath JSONPath expression to select select a portion of the state output to pass
* to the next state.
*/
override fun outputPath(outputPath: String) {
cdkBuilder.outputPath(outputPath)
}
/**
* The JSON that will be supplied as input to the Lambda function.
*
* Default: - The state input (JSON path '$')
*
* @param payload The JSON that will be supplied as input to the Lambda function.
*/
override fun payload(payload: TaskInput) {
cdkBuilder.payload(payload.let(TaskInput.Companion::unwrap))
}
/**
* Invoke the Lambda in a way that only returns the payload response without additional
* metadata.
*
* The `payloadResponseOnly` property cannot be used if `integrationPattern`, `invocationType`,
* `clientContext`, or `qualifier` are specified.
* It always uses the REQUEST_RESPONSE behavior.
*
* Default: false
*
* @param payloadResponseOnly Invoke the Lambda in a way that only returns the payload response
* without additional metadata.
*/
override fun payloadResponseOnly(payloadResponseOnly: Boolean) {
cdkBuilder.payloadResponseOnly(payloadResponseOnly)
}
/**
* (deprecated) Version or alias to invoke a published version of the function.
*
* You only need to supply this if you want the version of the Lambda Function to depend
* on data in the state machine state. If not, you can pass the appropriate Alias or Version
* object
* directly as the `lambdaFunction` argument.
*
* Default: - Version or alias inherent to the `lambdaFunction` object.
*
* @deprecated pass a Version or Alias object as lambdaFunction instead
* @param qualifier Version or alias to invoke a published version of the function.
*/
@Deprecated(message = "deprecated in CDK")
override fun qualifier(qualifier: String) {
cdkBuilder.qualifier(qualifier)
}
/**
* JSONPath expression to indicate where to inject the state's output.
*
* May also be the special value JsonPath.DISCARD, which will cause the state's
* input to become its output.
*
* Default: - Replaces the entire input with the result (JSON path '$')
*
* @param resultPath JSONPath expression to indicate where to inject the state's output.
*/
override fun resultPath(resultPath: String) {
cdkBuilder.resultPath(resultPath)
}
/**
* The JSON that will replace the state's raw result and become the effective result before
* ResultPath is applied.
*
* You can use ResultSelector to create a payload with values that are static
* or selected from the state's raw result.
*
* Default: - None
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector)
* @param resultSelector The JSON that will replace the state's raw result and become the
* effective result before ResultPath is applied.
*/
override fun resultSelector(resultSelector: Map) {
cdkBuilder.resultSelector(resultSelector.mapValues{CdkObjectWrappers.unwrap(it.value)})
}
/**
* Whether to retry on Lambda service exceptions.
*
* This handles `Lambda.ServiceException`, `Lambda.AWSLambdaException`,
* `Lambda.SdkClientException`, and `Lambda.ClientExecutionTimeoutException`
* with an interval of 2 seconds, a back-off rate
* of 2 and 6 maximum attempts.
*
* Default: true
*
* [Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/bp-lambda-serviceexception.html)
* @param retryOnServiceExceptions Whether to retry on Lambda service exceptions.
*/
override fun retryOnServiceExceptions(retryOnServiceExceptions: Boolean) {
cdkBuilder.retryOnServiceExceptions(retryOnServiceExceptions)
}
/**
* Optional name for this state.
*
* Default: - The construct ID will be used as state name
*
* @param stateName Optional name for this state.
*/
override fun stateName(stateName: String) {
cdkBuilder.stateName(stateName)
}
/**
* Timeout for the task.
*
* [disable-awslint:duration-prop-type] is needed because all props interface in
* aws-stepfunctions-tasks extend this interface
*
* Default: - None
*
* @param taskTimeout Timeout for the task.
*/
override fun taskTimeout(taskTimeout: Timeout) {
cdkBuilder.taskTimeout(taskTimeout.let(Timeout.Companion::unwrap))
}
/**
* (deprecated) Timeout for the task.
*
* Default: - None
*
* @deprecated use `taskTimeout`
* @param timeout Timeout for the task.
*/
@Deprecated(message = "deprecated in CDK")
override fun timeout(timeout: Duration) {
cdkBuilder.timeout(timeout.let(Duration.Companion::unwrap))
}
public fun build(): software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke =
cdkBuilder.build()
}
public companion object {
public operator fun invoke(
scope: CloudshiftdevConstructsConstruct,
id: String,
block: Builder.() -> Unit = {},
): LambdaInvoke {
val builderImpl = BuilderImpl(CloudshiftdevConstructsConstruct.unwrap(scope), id)
return LambdaInvoke(builderImpl.apply(block).build())
}
internal fun wrap(cdkObject: software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke):
LambdaInvoke = LambdaInvoke(cdkObject)
internal fun unwrap(wrapped: LambdaInvoke):
software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke = wrapped.cdkObject as
software.amazon.awscdk.services.stepfunctions.tasks.LambdaInvoke
}
}