When i add a s3 event in my serverless.yml it generates a function policy without a sourceAccount condition .When a event is attached through lambda console the function policy has the sourceAccount in it, but when creating a Lambda::Permission and adding and event to lambda through serverless, the sourceAccount is missing from function policy causing the AWS config to report this lambda as non compliant.
Any suggestions on how to solve this will be appreciated.
This is my serverless yml :
Resources:
LambdaPermissionInvoke:
Type: âAWS::Lambda::Permissionâ
Properties:
FunctionName:
âFn::GetAttâ:
- MyLambdaFunction
- Arn
Principal: âs3.amazonaws.comâ
Action: âlambda:InvokeFunctionâ
SourceAccount:
Ref: âAWS::AccountIdâ
SourceArn: âarn:aws:s3:::my-s3-sbucketâ
functions:
MyLambdaFunction:
handler: lambda_handler
events: # The Events that trigger this Function
- s3:
bucket: my-s3-bucket
event: s3:ObjectCreated:*