@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
198 lines (197 loc) • 8.04 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
/**
* Invokes an AWS Lambda Function and returns its results. Use this data source to execute Lambda functions during Pulumi operations and use their results in other resources or outputs.
*
* The Lambda function is invoked with [RequestResponse](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestSyntax) invocation type.
*
* > **Note:** The `aws.lambda.Invocation` data source invokes the function during the first `apply` and every subsequent `plan` when the function is known.
*
* > **Note:** If you get a `KMSAccessDeniedException: Lambda was unable to decrypt the environment variables because KMS access was denied` error when invoking a 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. (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
*
* ### Basic Invocation
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const example = aws.lambda.getInvocation({
* functionName: exampleAwsLambdaFunction.functionName,
* input: JSON.stringify({
* operation: "getStatus",
* id: "123456",
* }),
* });
* export const result = example.then(example => std.jsondecode({
* input: example.result,
* })).then(invoke => invoke.result);
* ```
*
* ### Dynamic Resource Configuration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* // Get resource configuration from Lambda
* const resourceConfig = aws.lambda.getInvocation({
* functionName: "resource-config-generator",
* qualifier: "production",
* input: JSON.stringify({
* environment: environment,
* region: current.region,
* service: "api",
* }),
* });
* const config = resourceConfig.then(resourceConfig => std.jsondecode({
* input: resourceConfig.result,
* })).then(invoke => invoke.result);
* // Use dynamic configuration
* const example = new aws.elasticache.Cluster("example", {
* clusterId: config?.cache?.clusterId,
* engine: config?.cache?.engine,
* nodeType: config?.cache?.nodeType,
* numCacheNodes: config?.cache?.nodes,
* parameterGroupName: config?.cache?.parameterGroup,
* tags: config?.tags,
* });
* ```
*/
export declare function getInvocation(args: GetInvocationArgs, opts?: pulumi.InvokeOptions): Promise<GetInvocationResult>;
/**
* A collection of arguments for invoking getInvocation.
*/
export interface GetInvocationArgs {
/**
* Name of the Lambda function.
*/
functionName: string;
/**
* String in JSON format that is passed as payload to the Lambda function.
*
* The following arguments are optional:
*/
input: string;
/**
* Qualifier (a.k.a version) of the Lambda function. Defaults to `$LATEST`.
*/
qualifier?: string;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: string;
/**
* Tenant Id to serve invocations from specified tenant.
*/
tenantId?: string;
}
/**
* A collection of values returned by getInvocation.
*/
export interface GetInvocationResult {
readonly functionName: string;
/**
* The provider-assigned unique ID for this managed resource.
*/
readonly id: string;
readonly input: string;
readonly qualifier?: string;
readonly region: string;
/**
* String result of the Lambda function invocation.
*/
readonly result: string;
readonly tenantId?: string;
}
/**
* Invokes an AWS Lambda Function and returns its results. Use this data source to execute Lambda functions during Pulumi operations and use their results in other resources or outputs.
*
* The Lambda function is invoked with [RequestResponse](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestSyntax) invocation type.
*
* > **Note:** The `aws.lambda.Invocation` data source invokes the function during the first `apply` and every subsequent `plan` when the function is known.
*
* > **Note:** If you get a `KMSAccessDeniedException: Lambda was unable to decrypt the environment variables because KMS access was denied` error when invoking a 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. (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
*
* ### Basic Invocation
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const example = aws.lambda.getInvocation({
* functionName: exampleAwsLambdaFunction.functionName,
* input: JSON.stringify({
* operation: "getStatus",
* id: "123456",
* }),
* });
* export const result = example.then(example => std.jsondecode({
* input: example.result,
* })).then(invoke => invoke.result);
* ```
*
* ### Dynamic Resource Configuration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* // Get resource configuration from Lambda
* const resourceConfig = aws.lambda.getInvocation({
* functionName: "resource-config-generator",
* qualifier: "production",
* input: JSON.stringify({
* environment: environment,
* region: current.region,
* service: "api",
* }),
* });
* const config = resourceConfig.then(resourceConfig => std.jsondecode({
* input: resourceConfig.result,
* })).then(invoke => invoke.result);
* // Use dynamic configuration
* const example = new aws.elasticache.Cluster("example", {
* clusterId: config?.cache?.clusterId,
* engine: config?.cache?.engine,
* nodeType: config?.cache?.nodeType,
* numCacheNodes: config?.cache?.nodes,
* parameterGroupName: config?.cache?.parameterGroup,
* tags: config?.tags,
* });
* ```
*/
export declare function getInvocationOutput(args: GetInvocationOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output<GetInvocationResult>;
/**
* A collection of arguments for invoking getInvocation.
*/
export interface GetInvocationOutputArgs {
/**
* Name of the Lambda function.
*/
functionName: pulumi.Input<string>;
/**
* String in JSON format that is passed as payload to the Lambda function.
*
* The following arguments are optional:
*/
input: pulumi.Input<string>;
/**
* Qualifier (a.k.a version) of the Lambda function. Defaults to `$LATEST`.
*/
qualifier?: pulumi.Input<string>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* Tenant Id to serve invocations from specified tenant.
*/
tenantId?: pulumi.Input<string>;
}