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

Fix #7103 Add source account to lambda permissions for s3 events #7417

Conversation

callumsmits
Copy link
Contributor

What did you implement

This PR adds the SourceAccount condition with the current account to the lambda permission for s3 events.

Closes #7103

How can we verify it

Deploy a function with an s3 event trigger:

photoupload:
    handler: photoupload.handler
    description: Process images dropped into S3
    events:
    - s3:
        bucket: mybucket
        event: s3:ObjectCreated:*

The lambda policy will now include the AWS:SourceAccount condition:

{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "autogensid",
      "Effect": "Allow",
      "Principal": {
        "Service": "s3.amazonaws.com"
      },
      "Action": "lambda:InvokeFunction",
      "Resource": "arn:aws:lambda:us-east-1:999999999999:function:photoupload",
      "Condition": {
        "StringEquals": {
          "AWS:SourceAccount": "999999999999"
        },
        "ArnLike": {
          "AWS:SourceArn": "arn:aws:s3:::mybucket"
        }
      }
    }
  ]
}

Todos

  • Write and run all tests
  • Write documentation
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: Only if users unintentionally rely on this behavior (which is unlikely and they really shouldn't).

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @callumsmits looks great!

@medikoo medikoo merged commit 7d67f33 into serverless:master Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance security of S3 event triggered Lambdas
2 participants