LoginSignup
0
0

More than 5 years have passed since last update.

MacでLambdaのコードのSHA256を計算する

Last updated at Posted at 2016-11-07

注意点

Macのzipコマンドで圧縮する場合は毎回ハッシュが変わるので-Xオプションを付ける。

zip -X archive.zip index.js

時刻の情報などが拡張属性として入ってしまうっぽい。
man zipより↓。

Do not save extra file attributes (Extended Attributes on OS/2, uid/gid and file times on Unix)

参考 http://qiita.com/knaka/items/c8673dfb4ed1b83d3585

SHA256の計算

zipファイルに対して行う。

shasum -a 256 archive.zip | awk '{print $1}' | xxd -r -p | base64

opensslコマンドでも同じことが出来る。

openssl dgst -binary -sha256 < a.zip | base64

LambdaファンクションのCodeSha256の取得

既存のLambdaファンクションのCodeSha256を取得する。
awsコマンドで取得する方法。

aws lambda get-function-configuration --function-name ...

{
  "CodeSha256": "...",
  "FunctionName": "...",
  "CodeSize": 200,
  "MemorySize": 128,
  "FunctionArn": "arn:aws:lambda:...",
  "Version": "$LATEST",
  "Role": "arn:aws:iam::...",
  "Timeout": 5,
  "LastModified": "...",
  "Handler": "index.handler",
  "Runtime": "nodejs4.3",
  "Description": "..."
}
0
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
0
0