1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

aws python boto3 roleではなく、access-keyで権限を付与する

Posted at

ロールではなく、Access-keyで権限を付与することはできないかなと思い、試してみました。
os.environを利用することで環境変数を利用することができます。
Lambda関数でも環境変数を取得できるようになり、コード管理が容易になりました。

xx.py

import boto3
import os
from boto3.session import Session

access_key = os.environ['ACCESS_KEY']
secret_key = os.environ['SECRET_KEY']

session = Session(
    aws_access_key_id = access_key,
    aws_secret_access_key = secret_key,
    region_name = 'us-west-1'
    )
ddb= session.resource("dynamodb")

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?