UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

280 lines (279 loc) • 9.48 kB
import * as pulumi from "@pulumi/pulumi"; /** * Provides details about an AWS Lambda Alias. Use this data source to retrieve information about an existing Lambda function alias for traffic management, deployment strategies, or API integrations. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.lambda.getAlias({ * functionName: "my-lambda-function", * name: "production", * }); * export const aliasArn = example.then(example => example.arn); * ``` * * ### API Gateway Integration * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const apiHandler = aws.lambda.getAlias({ * functionName: "api-handler", * name: "live", * }); * const example = new aws.apigateway.Integration("example", { * restApi: exampleAwsApiGatewayRestApi.id, * resourceId: exampleAwsApiGatewayResource.id, * httpMethod: exampleAwsApiGatewayMethod.httpMethod, * integrationHttpMethod: "POST", * type: "AWS_PROXY", * uri: apiHandler.then(apiHandler => apiHandler.invokeArn), * }); * // Grant API Gateway permission to invoke the alias * const apiGateway = new aws.lambda.Permission("api_gateway", { * statementId: "AllowExecutionFromAPIGateway", * action: "lambda:InvokeFunction", * "function": apiHandler.then(apiHandler => apiHandler.functionName), * principal: "apigateway.amazonaws.com", * qualifier: apiHandler.then(apiHandler => apiHandler.name), * sourceArn: `${exampleAwsApiGatewayRestApi.executionArn}/*&#47;*`, * }); * ``` * * ### Deployment Version Tracking * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Get production alias details * const production = aws.lambda.getAlias({ * functionName: "payment-processor", * name: "production", * }); * // Get staging alias details * const staging = aws.lambda.getAlias({ * functionName: "payment-processor", * name: "staging", * }); * const versionDrift = Promise.all([production, staging]).then(([production, staging]) => production.functionVersion != staging.functionVersion); * export const deploymentStatus = { * productionVersion: production.then(production => production.functionVersion), * stagingVersion: staging.then(staging => staging.functionVersion), * versionDrift: versionDrift, * readyForPromotion: !versionDrift, * }; * ``` * * ### EventBridge Rule Target * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const eventProcessor = aws.lambda.getAlias({ * functionName: "event-processor", * name: "stable", * }); * const example = new aws.cloudwatch.EventRule("example", { * name: "capture-events", * description: "Capture events for processing", * eventPattern: JSON.stringify({ * source: ["myapp.orders"], * "detail-type": ["Order Placed"], * }), * }); * const lambda = new aws.cloudwatch.EventTarget("lambda", { * rule: example.name, * targetId: "SendToLambda", * arn: eventProcessor.then(eventProcessor => eventProcessor.arn), * }); * const allowEventbridge = new aws.lambda.Permission("allow_eventbridge", { * statementId: "AllowExecutionFromEventBridge", * action: "lambda:InvokeFunction", * "function": eventProcessor.then(eventProcessor => eventProcessor.functionName), * principal: "events.amazonaws.com", * qualifier: eventProcessor.then(eventProcessor => eventProcessor.name), * sourceArn: example.arn, * }); * ``` */ export declare function getAlias(args: GetAliasArgs, opts?: pulumi.InvokeOptions): Promise<GetAliasResult>; /** * A collection of arguments for invoking getAlias. */ export interface GetAliasArgs { /** * Name of the aliased Lambda function. */ functionName: string; /** * Name of the Lambda alias. * * The following arguments are optional: */ name: 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; } /** * A collection of values returned by getAlias. */ export interface GetAliasResult { /** * ARN identifying the Lambda function alias. */ readonly arn: string; /** * Description of the alias. */ readonly description: string; readonly functionName: string; /** * Lambda function version which the alias uses. */ readonly functionVersion: string; /** * The provider-assigned unique ID for this managed resource. */ readonly id: string; /** * ARN to be used for invoking Lambda Function from API Gateway - to be used in `aws.apigateway.Integration`'s `uri`. */ readonly invokeArn: string; readonly name: string; readonly region: string; } /** * Provides details about an AWS Lambda Alias. Use this data source to retrieve information about an existing Lambda function alias for traffic management, deployment strategies, or API integrations. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.lambda.getAlias({ * functionName: "my-lambda-function", * name: "production", * }); * export const aliasArn = example.then(example => example.arn); * ``` * * ### API Gateway Integration * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const apiHandler = aws.lambda.getAlias({ * functionName: "api-handler", * name: "live", * }); * const example = new aws.apigateway.Integration("example", { * restApi: exampleAwsApiGatewayRestApi.id, * resourceId: exampleAwsApiGatewayResource.id, * httpMethod: exampleAwsApiGatewayMethod.httpMethod, * integrationHttpMethod: "POST", * type: "AWS_PROXY", * uri: apiHandler.then(apiHandler => apiHandler.invokeArn), * }); * // Grant API Gateway permission to invoke the alias * const apiGateway = new aws.lambda.Permission("api_gateway", { * statementId: "AllowExecutionFromAPIGateway", * action: "lambda:InvokeFunction", * "function": apiHandler.then(apiHandler => apiHandler.functionName), * principal: "apigateway.amazonaws.com", * qualifier: apiHandler.then(apiHandler => apiHandler.name), * sourceArn: `${exampleAwsApiGatewayRestApi.executionArn}/*&#47;*`, * }); * ``` * * ### Deployment Version Tracking * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Get production alias details * const production = aws.lambda.getAlias({ * functionName: "payment-processor", * name: "production", * }); * // Get staging alias details * const staging = aws.lambda.getAlias({ * functionName: "payment-processor", * name: "staging", * }); * const versionDrift = Promise.all([production, staging]).then(([production, staging]) => production.functionVersion != staging.functionVersion); * export const deploymentStatus = { * productionVersion: production.then(production => production.functionVersion), * stagingVersion: staging.then(staging => staging.functionVersion), * versionDrift: versionDrift, * readyForPromotion: !versionDrift, * }; * ``` * * ### EventBridge Rule Target * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const eventProcessor = aws.lambda.getAlias({ * functionName: "event-processor", * name: "stable", * }); * const example = new aws.cloudwatch.EventRule("example", { * name: "capture-events", * description: "Capture events for processing", * eventPattern: JSON.stringify({ * source: ["myapp.orders"], * "detail-type": ["Order Placed"], * }), * }); * const lambda = new aws.cloudwatch.EventTarget("lambda", { * rule: example.name, * targetId: "SendToLambda", * arn: eventProcessor.then(eventProcessor => eventProcessor.arn), * }); * const allowEventbridge = new aws.lambda.Permission("allow_eventbridge", { * statementId: "AllowExecutionFromEventBridge", * action: "lambda:InvokeFunction", * "function": eventProcessor.then(eventProcessor => eventProcessor.functionName), * principal: "events.amazonaws.com", * qualifier: eventProcessor.then(eventProcessor => eventProcessor.name), * sourceArn: example.arn, * }); * ``` */ export declare function getAliasOutput(args: GetAliasOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output<GetAliasResult>; /** * A collection of arguments for invoking getAlias. */ export interface GetAliasOutputArgs { /** * Name of the aliased Lambda function. */ functionName: pulumi.Input<string>; /** * Name of the Lambda alias. * * The following arguments are optional: */ name: 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>; }