6
7

More than 3 years have passed since last update.

LambdaでPostgreSQLを使う(Python + psycopg2)

Last updated at Posted at 2020-09-03

はじめに

LambdaでPythonを使うときに、psycopg2でPostgreSQLを簡単に使う方法です。
これまでは、psycopg2をimportするのは手間でしたね。

方法

Mischa SpiegelmockさんのLambdaレイヤーを使わせてもらいます。

Python 3.8 東京リージョン ap-northeast-1 の場合

arn:aws:lambda:ap-northeast-1:898466741470:layer:psycopg2-py38:1

スクリーンショット 2020-09-04 0.06.19.png

レイヤーを追加、arnを指定すればOK。これだけでimportできます!

終わりに

Mischa SpiegelmockさんのGithubのCodeからbuildして、レイヤーにするのも簡単に出来ました。

参考

Qiita: AWS LambdaでPython外部ライブラリのLayerを作る前に
https://qiita.com/polarbear08/items/202752d5ffcb65595bd9

6
7
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
6
7