Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions on ca-central-1 lambda bucket #564

Closed
lucasteligioridis opened this issue Apr 11, 2019 · 7 comments · Fixed by #566
Closed

Permissions on ca-central-1 lambda bucket #564

lucasteligioridis opened this issue Apr 11, 2019 · 7 comments · Fixed by #566

Comments

@lucasteligioridis
Copy link

lucasteligioridis commented Apr 11, 2019

:(

aws_lambda_function.lambda: Error modifying Lambda Function Code: AccessDeniedException: Your access has been denied by S3, please make sure your request credentials have permission to GetObject for buildkite-lambdas-ca-central-1/buildkite-agent-scaler/v0.4.0/handler.zip. S3 Error Code: AccessDenied. S3 Error Message: Access Denied
@lucasteligioridis lucasteligioridis changed the title Permissions on ca-central-1 Permissions on ca-central-1 lambda bucket Apr 11, 2019
@lox
Copy link
Contributor

lox commented Apr 12, 2019

It looks like this might be related to the user you are using to create the CloudFormation stack. AWS provided this insight:

  1. While accessing a public S3 object present in a bucket within the same account, we don't need to specify any explicit permission (GetObject) in the CloudFormation service role / the role which is trying to create/update the stack.
  2. However, even if an S3 object is publicly accessible, but if it's present in a different account (Say a third party account), we still need to give permission (GetObject) for that particular S3 object in the CloudFormation service role's policy / the role's policy which is trying to create/update the stack.

@lucasteligioridis
Copy link
Author

Hmmm, I'm using a different set of users in my stack, but its the same IAM permissions as the other regions and they worked all fine.

I thought those buckets/paths were fully publicly accessible?

@lox
Copy link
Contributor

lox commented Apr 12, 2019

The key element here is the user that is creating the stack. Yes those bucket/paths are fully accessible, but check out point 2 in the above from AWS.

@lucasteligioridis
Copy link
Author

I'm misunderstanding, I don't see what the Cloudformation stack or role is relevant with the bucket policy? 2 examples below:

For example, here is a random account I'm authenticating against in ap-southeast-2:

$ export AWS_DEFAULT_REGION=ap-southeast-2
$ aws s3 cp s3://buildkite-lambdas-ap-southeast-2/buildkite-agent-scaler/v0.4.0/handler.zip .
download: s3://buildkite-lambdas-ap-southeast-2/buildkite-agent-scaler/v0.4.0/handler.zip to ./handler.zip

Now here is another random account with ca-central-1:

$ export AWS_DEFAULT_REGION=ca-central-1
$ aws s3 cp s3://buildkite-lambdas-ca-central-1/buildkite-agent-scaler/v0.4.0/handler.zip .
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden

@lox
Copy link
Contributor

lox commented Apr 12, 2019

So many face palms. You are right, we are getting this same error for some that do exist, but in this case you are correct and we haven't published the scaler there! Sorry! Seeing zebras when I should be seeing horses 🦓

@lucasteligioridis
Copy link
Author

Haha, great. I thought I was going crazy for a second. IAM will do that to you.
Glad we got it though :)

I just put a workaround in place by moving the lambda in my stack code and push it up as a file rather than fetching from S3.

@lox
Copy link
Contributor

lox commented Apr 12, 2019

I'll get buildkite/buildkite-agent-scaler#11 into 4.3.2 on Monday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants