I'm using boto3 in order to create a presigned post url for s3.
s3 = boto3.client('s3')
post = s3.generate_presigned_post(
Bucket=bucket_name,
Key=f"{userid}.{suffix}"
)
The aws_access_key_id
that is being used is incorrect, one of the ways of using the right one is by adding an environment variable through environment variables.
Any idea how can I enforce using the aws access key as defined by the user I've created in IAM ?
Update 1
Policy attached to the IAM role that executes the lambda
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:*"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"xray:PutTraceSegments",
"xray:PutTelemetryRecords"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:AttachNetworkInterface",
"ec2:CreateNetworkInterface",
"ec2:DeleteNetworkInterface",
"ec2:DescribeInstances",
"ec2:DescribeNetworkInterfaces",
"ec2:DetachNetworkInterface",
"ec2:ModifyNetworkInterfaceAttribute",
"ec2:ResetNetworkInterfaceAttribute"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"kinesis:*"
],
"Resource": "arn:aws:kinesis:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"sns:*"
],
"Resource": "arn:aws:sns:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"sqs:*"
],
"Resource": "arn:aws:sqs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": "arn:aws:dynamodb:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"route53:*"
],
"Resource": "*"
}
]
}
ASIA
(notAKIA
), and it rotates. "The access key does not exist in our records" is the error thrown if the request lacks the accompanyingx-amz-security-token
that gives meaning to the temporary access-key-id. – Michael - sqlbotx-amz-security-token
? am I suppose to get it back as part of the response ? – Efi MKaws_session_token
. – Michael - sqlbot