user2168
user2168

Reputation: 309

Deploy flask application without AWS access key

I have Python Flask application (due to ORM and psycopg2 stuff) using Zappa to deploy to lambda. I am using boto library to perform some S3 related, and I use this to initialize it:

import boto3
client = boto3.client(
    's3',
    aws_access_key_id=ACCESS_KEY,
    aws_secret_access_key=SECRET_KEY
)

But I want to avoid using aws_access_key and aws_secret_access_key in code.
I created a separate empty lambda function and set proper role and permission, then in function code, I skipped putting access and secret key

client = boto3.client('s3')

and this works fine. But when I use zappa to deploy my Flask application, even though I set the same role and permission as above (and also give access to S3), it does not work.

Is there a way I can bypass putting aws_access_key and aws_secret_access_key in Flask app and get to deploy to lambda?

Upvotes: 0

Views: 315

Answers (1)

JD D
JD D

Reputation: 8097

Zappa recommends setting up an AWS credentials file. This should allow you to keep the credentials out of your code but allow the SDK to find and use your credentials.

Upvotes: 1

Related Questions