I've been looking everywhere and can't seem to find an example that comes close. This is as close as I've gotten:
import {APIGatewayProxyEvent} from 'aws-lambda';
import AWS from 'aws-sdk';
const creds = new AWS.SharedIniFileCredentials({profile: 'dev'});
const S3 = new AWS.S3(creds);
import {Readable} from "stream";
export const handler = async (_event: APIGatewayProxyEvent): Promise<Readable> => {
const s3Params = {
Bucket: "some-aws-s3-buckeet",
Key: "some-folder/some-document.pdf"
}
return S3.getObject(s3Params).createReadStream();
}
After this, I'm getting the error:
InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.
I've logged into AWS using the following:
aws sso login --profile dev