0

I have a requirement to launch a number of lambda functions on the ObjectCreated event in a number of s3 buckets. But the architecture of my application requires modularity thus, I have to create two different templates, one for my bucket creation and another for the lambdas. According to me, one way to achieve this is by using the SNS service.

SNS

we create the SNS topic in the buckets creation template and provide the ObjectCreated event to it through NotificationConfiguration property of the s3. In the lambda template we can subscribe the lambda to the above mentioned SNS topic and the lambda function will be called on the s3 ObjectCreated event. But again the architecture does not allows using SNS.

Possible way

Is it all possible to do this without using SNS and compromising on the modularity like making two separate templates for buckets and lambdas and using their notification configuration in a third template to complete the chain.

Final Question

I can not use SNS and I want modularity, how can I call my lambda functions on the s3 event? is it even ossible with my restrictions? thank you

1
  • Can you import the Lambda function from their stack using Fn::ImportValue? Commented Dec 14, 2017 at 18:25

1 Answer 1

1

You could trigger your functions straight from S3 using events in the bucket properties. http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html

You could also use a CloudWatch Event Rule to trigger your functions. To do so:

  1. Go to your AWs Console and select Services > CloudWatch.
  2. Select Rules under Events on the left.
  3. Select Create Rule.
  4. Leave Event Pattern selected.
  5. Select Simple Storage Service (S3) from Service Name drop down.
  6. Select Object Level Operations from Event Type drop down.
  7. Select Specific operation(s).
  8. Select PutObject from drop down.
  9. Select Specific bucket(s) by name.
  10. Enter bucket names.
  11. Select + Add target* on the right.
  12. Select Lambda function to trigger.
  13. Select Configure details at the bottom of the page.
  14. Enter a rule name.
  15. Finish by selecting Create rule.
Sign up to request clarification or add additional context in comments.

2 Comments

I have already tried the first option you suggested. when using s3 and lambda in combination they need to be specified in the same template otherwise cloudformation throws an error. as for your second option, it looks like a viable option. i will give it a try
this does not work, as there is no trigger for lambda

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.