Search code examples
amazon-s3spinnaker

Trigger Spinnaker pipeline on AWS S3 bucket change


I need my Spinnaker pipeline to trigger on changes to an AWS s3 bucket, specifically when a file is added or edited.

I cannot find a builtin mechanism to do that: there is nothing remotely related to S3 buckets in the drop-down list of triggers.

I thought I might be able to use a webhook from an AWS lambda that subscribes to S3 events on the bucket, and have the lambda webhook to https://my_spinnnaker.mybiz.com/webhooks/webhook/s3_new. However it does not seem possible to pass parameters to the hook, e.g. the key of new S3 object.

Any other ways of doing this?


Solution

  • The S3 Object Key can be read from the event that triggers the Lambda function. The event records have the S3 object key. 1

    For a pipeline with parameters, the request sent from the Lambda function can contain parameter values in the request body. The format for the payload is given below. 2

    {
      "parameters": {
        "<parameter-key>": "<parameter-value>"
      }
    }