小编zar*_*aru的帖子

AWS CDK:如何将指定版本的 Lambda 与别名关联?

我使用 AWS CDK 来管理 Lambda。

我为 Lambda 函数创建了两个别名,development并且production.

但我不知道如何将版本与每个别名关联起来。

export class CdkLambdaStack extends cdk.Stack {
    constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
        super(scope, id, props);

        const fnDemo = new NodejsFunction(this, 'demo', {
            entry: 'lib/lambda-handler/index.ts',
            currentVersionOptions: {
                removalPolicy: RemovalPolicy.RETAIN,
                retryAttempts: 1
            }
        });

        // In this case, production would be the most recent version
        // I want to specify the previous stable version
        fnDemo.currentVersion.addAlias('production');


        new lambda.Alias(this, 'demo-development-alias', {
            aliasName: 'development',
            version: fnDemo.latestVersion
        });

    }
}
Run Code Online (Sandbox Code Playgroud)

我查看了 AWS …

aws-cdk

5
推荐指数
1
解决办法
7631
查看次数

标签 统计

aws-cdk ×1