Open1

google-auth(Custom AWS Lambda Layer)

marchanmarchan

-- 2025.05.12

Cloud9 Amazon Linux2 で作業する

python のバージョンを確認する

$ python --version

Python 3.12.0

ディレクトリを新規作成する

mkdir python
ls -ls

0 drwxrwxr-x 2 ec2-user ec2-user 6 May 13 05:46 python

インストールする

$ pip install google-auth -t ./python

Collecting google-auth
Using cached google_auth-2.40.1-py2.py3-none-any.whl.metadata (6.2 kB)
Collecting cachetools<6.0,>=2.0.0 (from google-auth)
Using cached cachetools-5.5.2-py3-none-any.whl.metadata (5.4 kB)
Collecting pyasn1-modules>=0.2.1 (from google-auth)
Using cached pyasn1_modules-0.4.2-py3-none-any.whl.metadata (3.5 kB)
Collecting rsa<5,>=3.1.4 (from google-auth)
Using cached rsa-4.9.1-py3-none-any.whl.metadata (5.6 kB)
Collecting pyasn1<0.7.0,>=0.6.1 (from pyasn1-modules>=0.2.1->google-auth)
Using cached pyasn1-0.6.1-py3-none-any.whl.metadata (8.4 kB)
Using cached google_auth-2.40.1-py2.py3-none-any.whl (216 kB)
Using cached cachetools-5.5.2-py3-none-any.whl (10 kB)
Using cached pyasn1_modules-0.4.2-py3-none-any.whl (181 kB)
Using cached rsa-4.9.1-py3-none-any.whl (34 kB)
Using cached pyasn1-0.6.1-py3-none-any.whl (83 kB)
Installing collected packages: pyasn1, cachetools, rsa, pyasn1-modules, google-auth
Successfully installed cachetools-5.5.2 google-auth-2.40.1 pyasn1-0.6.1 pyasn1-modules-0.4.2 rsa-4.9.1

確認する

$ cd python 
$ ls -ls 

total 8
0 drwxrwxr-x 2 ec2-user ec2-user 128 May 13 05:49 bin
0 drwxrwxr-x 3 ec2-user ec2-user 96 May 13 05:49 cachetools
0 drwxrwxr-x 2 ec2-user ec2-user 102 May 13 05:49 cachetools-5.5.2.dist-info
0 drwxrwxr-x 4 ec2-user ec2-user 32 May 13 05:49 google
0 drwxrwxr-x 2 ec2-user ec2-user 119 May 13 05:49 google_auth-2.40.1.dist-info
0 drwxrwxr-x 6 ec2-user ec2-user 115 May 13 05:49 pyasn1
0 drwxrwxr-x 2 ec2-user ec2-user 122 May 13 05:49 pyasn1-0.6.1.dist-info
8 drwxrwxr-x 3 ec2-user ec2-user 4096 May 13 05:49 pyasn1_modules
0 drwxrwxr-x 3 ec2-user ec2-user 119 May 13 05:49 pyasn1_modules-0.4.2.dist-info
0 drwxrwxr-x 3 ec2-user ec2-user 272 May 13 05:49 rsa
0 drwxrwxr-x 2 ec2-user ec2-user 105 May 13 05:49 rsa-4.9.1.dist-info

移動する

$ cd ../
$ ls -ls

ZIP圧縮する

$ zip -r google-auth-layer.zip python

【省略】
adding: python/google/oauth2/pycache/webauthn_types.cpython-312.pyc (deflated 55%)
adding: python/google_auth-2.40.1.dist-info/ (stored 0%)
adding: python/google_auth-2.40.1.dist-info/LICENSE (deflated 65%)
adding: python/google_auth-2.40.1.dist-info/METADATA (deflated 69%)
adding: python/google_auth-2.40.1.dist-info/WHEEL (deflated 12%)
adding: python/google_auth-2.40.1.dist-info/top_level.txt (stored 0%)
adding: python/google_auth-2.40.1.dist-info/RECORD (deflated 63%)
adding: python/google_auth-2.40.1.dist-info/INSTALLER (stored 0%)
adding: python/google_auth-2.40.1.dist-info/REQUESTED (stored 0%)
adding: python/bin/ (stored 0%)
adding: python/bin/pyrsa-decrypt (deflated 25%)
adding: python/bin/pyrsa-encrypt (deflated 25%)
adding: python/bin/pyrsa-keygen (deflated 24%)
adding: python/bin/pyrsa-priv2pub (deflated 27%)
adding: python/bin/pyrsa-sign (deflated 24%)
adding: python/bin/pyrsa-verify (deflated 24%)

確認する

ls -ls

1452 -rw-rw-r-- 1 ec2-user ec2-user 1483533 May 13 05:52 google-auth-layer.zip

作業ディレクトリ名を変更してバックアップする

mv python python-google-auth
ls -ls

0 drwxrwxr-x 13 ec2-user ec2-user 261 May 13 05:49 python-google-auth