1
0

More than 3 years have passed since last update.

GitLFS用のLambdaの.NETCoreをアップデートする

Posted at

S3 の GitLFS サーバ の Lambda関数 の .NETcore をアップデートする

経緯

AWS の Lambda にて .NETcore2.1 のサポートが 2021/09/20 で終了するとの通知が来たので、
以前構築したGitLFSサーバのLambda関数をアップデートすることに

  • CloudFormationの変更セットを使って、Lambda関数だけアップデートできるか検証する

手順

ファイル準備

新しいyamlファイルと鍵Zipファイルをアップする

SigningLambda:
    Type: AWS::Lambda::Function
    Properties:
        Code:
            S3Bucket: !Sub 'gitlfs-test'
            S3Key: Estranged.Lfs.Hosting.Lambda.zip
        Description: Generates S3 signed URLs for Git LFS
        FunctionName: !Ref AWS::StackName
        Handler: Estranged.Lfs.Hosting.Lambda::Estranged.Lfs.Hosting.Lambda.LambdaEntryPoint::FunctionHandlerAsync
        MemorySize: 512
        Role: !GetAtt SigningLambdaRole.Arn
        Runtime: dotnetcore3.1

S3key の部分と Runtime の部分を変える

S3 にアップロードして、オブジェクトURLをコピペしておく

CloudFormation 変更スタックとして実行

  • 変更セット作成
$ aws cloudformation create-change-set --stack-name gitlfs-server --change-set-name gitlfs-change-set --template-url 'https://gitlfs-test.s3.ap-northeast-1.amazonaws.com/git-lfs_new.yaml' --change-set-name gitlfs-change-set --parameters file://[path/to/params.json] --capabilities CAPABILITY_IAM

arn:aws:cloudformation:ap-northeast-1:571357558873:changeSet/gitlfs-change-set/79bed005-8343-42e0-924e-558f398812d1
arn:aws:cloudformation:ap-northeast-1:571357558873:stack/gitlfs-server/23a6e0c0-f467-11eb-82c8-0a9dd4300739
  • 変更セットの実行
$ aws cloudformation execute-change-set --change-set-name gitlfs-changeset --stack-name gitlfs-server

確認

コンソールで確認

  • CloudFormation Stack

スタックのステータスでUPDATE_COMPLETEになってたらOK

  • Lambda

ランタイム設定が .NET Core 3.1 になってたらOK

  • S3

バケットが変わらずそのままならOK

大丈夫そう!

Git LFS動作確認

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        binaries/photos/Z6_02_01.jpg

nothing added to commit but untracked files present (use "git add" to track)

$ git add .
$ git commit -m "バイナリファイル追加"
[master de08335] バイナリファイル追加
 1 file changed, 3 insertions(+)
 create mode 100644 binaries/photos/Z6_02_01.jpg

$ git push
Enumerating objects: 8, done.1/1), 15 MB | 0 B/s                                                                                               
Counting objects: 100% (8/8), done.
Delta compression using up to 2 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 549 bytes | 549.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0), pack-reused 0
To https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/lfs-test
   f59078c..de08335  master -> master
  • S3, CodeCommit 確認

→ちゃんとS3に実体だけUPされてる!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0