1 Answer
- Newest
- Most votes
- Most comments
1
Hello.
Access keys starting with "ASIA" are temporary access keys issued in STS events.
https://docs.aws.amazon.com/STS/latest/APIReference/API_GetAccessKeyInfo.html
If you are issuing a signed URL with Lambda, an IAM role will be used, so there is no need to set an access key in the code.
session = boto3.Session(
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
aws_session_token=os.environ["AWS_SESSION_TOKEN"]
)
By the way, is the request successful with a "curl" command using a URL created with Lambda instead of an HTML form?
In my environment, I have confirmed that I can create a URL using the Lambda below and upload it using the curl command.
import boto3
s3_client = boto3.client('s3',region_name="ap-northeast-1",endpoint_url="https://s3.ap-northeast-1.amazonaws.com")
def lambda_handler(event, context):
url = s3_client.generate_presigned_post(
Bucket="bucket-name",
Key="test.txt",
Conditions=[
{
"acl":"public-read"
}
],
ExpiresIn=3600
)
print(url)
return url
The response looks like this:
{
"url": "https://s3.ap-northeast-1.amazonaws.com/bucket-name",
"fields": {
"key": "test",
"AWSAccessKeyId": "ASIAxxxxxxxxx",
"x-amz-security-token": "xxxxxxxxxxxxxx",
"policy": "xxxxxxxxxxxxxxx",
"signature": "xxxxxxxxxxxx"
}
}
The curl command looks like this:
curl -X POST https://s3.ap-northeast-1.amazonaws.com/bucket-name \
-F 'key=test' \
-F 'acl=public-read' \
-F 'AWSAccessKeyId=ASIAxxxxxx' \
-F 'policy=xxxxxxxx' \
-F 'x-amz-security-token=xxxxxx' \
-F 'signature=xxxxxxxxx=' \
-F file=@kobayashi.txt
Relevant content
- asked 2 years ago
- asked 5 months ago
- asked 5 years ago
