Hello, I’m working on automating file uploads to an AWS S3 bucket using Postman’s pre-request scripts feature. I am using Postman’s scripting capabilities to set environment variables dynamically and execute AWS S3 uploads through AWS SDK calls made via Boto3 in a Python backend. However, I consistently receive an “Access Denied” error. I’ve included the relevant part of the script that initializes AWS credentials and performs the upload. Could someone review this and suggest what might be causing the error?
import boto3
def upload_file_to_s3(file_name, bucket_name):
aws_access_key_id = 'AKIAYD6247QVUW53NV6G'
aws_secret_access_key = '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'
github_pat = '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'
session = boto3.Session(
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key
)
s3 = session.resource('s3')
s3.meta.client.upload_file(file_name, bucket_name, file_name)
if __name__ == "__main__":
upload_file_to_s3('myfile.txt', 'my-test-bucket')