-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Sumiya Eguchi edited this page Sep 8, 2024
·
16 revisions
Warning
cdk deployを実行しようとすると、以下のように弾かれてしまう。
4:45:13 PM | UPDATE_FAILED | AWS::Lambda::Alias | CdkLambdaVersionAl...ampleAlias6E7DC8B0
Resource handler returned message: "$LATEST is not supported for an alias pointing to more than 1 version (Service: Lambda, Status Code: 400, Request ID: 4f539cce-ff5c-46d7-ab8c-7e54967245cf)" (RequestToken: a1174c44-58cf-ff1a-3e45-85ca3c460251, HandlerErrorCode: InvalidRequest)Warning
以下のように、二つ同時にversionを発行しようとした場合、cdk deployに失敗します。
// lambdaの現在のバージョンを発行
const lambdaOldVersion = new Version(this, 'CdkLambdaVersionAliasExampleVersionOld', {
lambda: lambda
})
// lambdaの新しいバージョンを発行
const lambdaNewVersion = new Version(this, 'CdkLambdaVersionAliasExampleVersionNew', {
lambda: lambda
})また、めんどくさいのが、とりあえずcommitをすれば良いわけではなく、「lambdaのコードに更新を加えないといけない」。 と思っていたが本当だろうか?lambdaの設定を変更しても良い?であれば「lambdaになんらかの変更を加えなければいけない」が正しい表現になるのかな? →yes lambdaのnode versionを変更しただけでも新規versionは発行可能だった。つまり、「lambdaになんらかの変更を加えなければversionは発行できない」が正しい表現になる。 また、それを裏付ける根拠としてこちらのブログ記事でも、lambdaのdescriptionを変更する手段をとっている。
[current version]がなかなか使えそう。lambdaに更新があった時のみ、バージョンを再発行してくれるような挙動になっている。
/**
* Returns a `lambda.Version` which represents the current version of this
* Lambda function. A new version will be created every time the function's
* configuration changes.
*
* You can specify options for this version using the `currentVersionOptions`
* prop when initializing the `lambda.Function`.
*/
get currentVersion(): Version;