Joshua G. Edwards
Joshua G. Edwards

Reputation: 693

CloudFormation, Lambda, S3 - Access denied by s3

So I am trying to run this cloudformation script but I get this error:

  • Your access has been denied by S3, please make sure your request credentials have permission to GetObject for s3.XXXX.amazonaws.com/s3-bucket/folder-1/folder-2/code.zip. S3 Error Code: AccessDenied. S3 Error Message: Access Denied

I've even tried making my code.zip public! which is not what I want to do ideally...

Here is my code:

"lambdafunction": {
     "Type": "AWS::Lambda::Function",
     "DependsOn": [
         "other1",
         "other2",
         "other3"
     ],
     "Properties": {
         "Code": {
             "S3Bucket": "s3.XXXX.amazonaws.com",
             "S3Key": "s3-bucket/folder-1/folder-2/code.zip"
         },
         "Role": {
             "Fn::GetAtt": [
                 "accessrole",
                 "Arn"
             ]
         },
         "Timeout": 60,
         "Handler": "lambda_function.lambda_handler",
         "Runtime": "python2.7",
         "MemorySize": 1024
     },
     "Metadata": {
         "AWS::CloudFormation::Designer": {
             "id": "XXXX"
         }
     }
 },

Thanks in advance!

Upvotes: 6

Views: 7984

Answers (1)

Joshua G. Edwards
Joshua G. Edwards

Reputation: 693

So it turns out the code section was wrong and needed to name the bucket url

 "Code": {
     "S3Bucket": "s3-bucket",
     "S3Key": "folder-1/folder-2/code.zip"
 },

Upvotes: 3

Related Questions