jorgebastida / gordon

λ Gordon is a tool to create, wire and deploy AWS Lambdas using CloudFormation
Other
2.04k stars 137 forks source link

How to create new S3 event source for diff --stage? #88

Closed kpx-dev closed 8 years ago

kpx-dev commented 8 years ago

Hi guys,

I have my simple s3 event source setting like this at the main settings.yml file, to call my lambda when a file is uploaded to a bucket.

s3:
  my_s3_integration:
    bucket: my-s3-bucket
    notifications:
      my_s3_file_uploaded:
        lambda: my_lambda_to_handle_file
        events:
          - s3:ObjectCreated:*

Now I want to do 2 diff stage, dev and prod. When I deploy with: gordon build --stage prod, it overwrites my S3 bucket event source setting for dev.

How can I have 2 S3 triggers triggering diff lambda based on --stage?

Thanks!

jorgebastida commented 8 years ago

The only way to do that is to have one bucket per stage. This is because both lambdas are consuming the same overlapping events s3:ObjectCreated:* and AWS doesn't enable you to do so.

Give a look to http://gordon.readthedocs.io/en/latest/parameters.html where you'll learn how to create parameters which vary from stage to stage.