Invocation

class Invocation : KotlinCustomResource

Use this resource to invoke a lambda function. The lambda function is invoked with the RequestResponse invocation type.

NOTE: This resource only invokes the function when the arguments call for a create or update. In other words, after an initial invocation on apply, if the arguments do not change, a subsequent apply does not invoke the function again. To dynamically invoke the function, see the triggers example below. To always invoke a function on each apply, see the aws.lambda.Invocation data source. NOTE: If you get a KMSAccessDeniedException: Lambda was unable to decrypt the environment variables because KMS access was denied error when invoking an aws.lambda.Function with environment variables, the IAM role associated with the function may have been deleted and recreated after the function was created. You can fix the problem two ways: 1) updating the function's role to another role and then updating it back again to the recreated role, or 2) by using Pulumi to taint the function and apply your configuration again to recreate the function. (When you create a function, Lambda grants permissions on the KMS key to the function's IAM role. If the IAM role is recreated, the grant is no longer valid. Changing the function's role or recreating the function causes Lambda to update the grant.)

Example Usage

Dynamic Invocation Example Using Triggers

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.Invocation;
import com.pulumi.aws.lambda.InvocationArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Invocation("example", InvocationArgs.builder()
.functionName(aws_lambda_function.lambda_function_test().function_name())
.triggers(Map.of("redeployment", computeSHA1(serializeJson(
jsonArray(aws_lambda_function.example().environment())))))
.input(serializeJson(
jsonObject(
jsonProperty("key1", "value1"),
jsonProperty("key2", "value2")
)))
.build());
}
}

Properties

Link copied to clipboard
val functionName: Output<String>

Name of the lambda function.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val input: Output<String>

JSON payload to the lambda function. The following arguments are optional:

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val qualifier: Output<String>?

Qualifier (i.e., version) of the lambda function. Defaults to $LATEST.

Link copied to clipboard
val result: Output<String>

String result of the lambda function invocation.

Link copied to clipboard
val triggers: Output<Map<String, String>>?

Map of arbitrary keys and values that, when changed, will trigger a re-invocation.

Link copied to clipboard
val urn: Output<String>