【対策方法】CloudFront Distributionに紐付けたLambda@Edge関数を削除できない

記事タイトルとURLをコピーする

こんにちは!技術4課のイーゴリです。

CloudFront Distributionに紐付けたLambda@Edge関数を削除しようとすると、下記のようなエラーが発生します。対策方法は下記となります。

f:id:swx-korotkov:20220401141951p:plain

Lambda was unable to delete arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:add-header-function:2 because it is a replicated function. Please see our documentation for Deleting Lambda@Edge Functions and Replicas. が発生しました。

下記の記事に回答が記載してあるので、その通り削除します。

You can delete a Lambda@Edge function only when the replicas of the function have been deleted by CloudFront. Replicas of a Lambda function are automatically deleted in the following situations:

  • After you remove the last association for the function from all of your CloudFront distributions. If more than one distribution uses a function, the replicas are deleted only after you remove the function association from the last distribution.
  • After you delete the last distribution that a function was associated with.

docs.aws.amazon.com

対象のCloudFront Distributionをクリックします。

f:id:swx-korotkov:20220401144153p:plain

[ビヘイビア]タブをクリックします。ビヘイビアを選択し、[編集]をクリックします。

f:id:swx-korotkov:20220401144442p:plain

[関数の関連付け]で[ビューワーリクエスト]の[関数タイプ]をクリックします。

f:id:swx-korotkov:20220401144749p:plain

[Lambda@Edge]から[関連付けなし]に変更します。

f:id:swx-korotkov:20220401144941p:plain

[変更を保存]をクリックします。

f:id:swx-korotkov:20220401145130p:plain

[サービス]>[Lambda]>[関数]>対象のLambda関数をクリックします。

[バージョン]タブをクリックし、バージョンを削除します。

f:id:swx-korotkov:20220401145503p:plain

[削除]をクリックします。

f:id:swx-korotkov:20220401145612p:plain

バージョンを削除できました。

f:id:swx-korotkov:20220401145627p:plain

もう一回Lambda関数を削除してみますと・・・

f:id:swx-korotkov:20220401145854p:plain

無事に削除できました!

f:id:swx-korotkov:20220401145941p:plain

以上、御一読ありがとうございました。

本田 イーゴリ (記事一覧)

カスタマーサクセス部

・AWS SAP, DOP, SCS, DBS, SAA, DVA, CLF
・Azure AZ-900
・EC-Council CCSE

趣味:日本国内旅行(47都道府県制覇)・ドライブ・音楽