Im trying to upload an image into my S3 bucket from a live site using AWM Amplify
but i keep getting this error in my cloudfront:
ERROR Error in headObject: Forbidden: null.
I know its a permission issue but ive looked online and applied what everyones been saying but i still keep getting that issue.
In my lambda function i click on configuration, and the rolename. Inside my role i created a inline policy named S3Access:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::aws-bucket",
"arn:aws:s3:::aws-bucket/*"
]
}
]
}
Trust relationship:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Then i go in my S3 Bucket and i make this my policy:
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipal",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::aws-bucket/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::32132131241:distribution/EKTT2sAWYDZ"
}
}
},
{
"Sid": "AllowLambdaFunctionAccess",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::12345678910:role/awsLambdaRole312d22e0a-auth"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::aws-bucket",
"arn:aws:s3:::aws-bucket/*"
]
}
]
}
Am i missing something here?