-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5004a26
commit b281606
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
id: s3-trigger-python | ||
namespace: company.team | ||
|
||
variables: | ||
bucket: s3-bucket | ||
region: eu-west-2 | ||
|
||
tasks: | ||
- id: process_data | ||
type: io.kestra.plugin.scripts.python.Commands | ||
taskRunner: | ||
type: io.kestra.plugin.scripts.runner.docker.Docker | ||
containerImage: ghcr.io/kestra-io/kestrapy:latest | ||
namespaceFiles: | ||
enabled: true | ||
inputFiles: | ||
input.csv: "{{ read(trigger.objects[0].uri) }}" | ||
outputFiles: | ||
- data.csv | ||
commands: | ||
- python process_data.py | ||
|
||
triggers: | ||
- id: watch | ||
type: io.kestra.plugin.aws.s3.Trigger | ||
interval: "PT1S" | ||
accessKeyId: "{{ secret('AWS_ACCESS_KEY_ID') }}" | ||
secretKeyId: "{{ secret('AWS_SECRET_KEY_ID') }}" | ||
region: "{{ vars.region }}" | ||
bucket: "{{ vars.bucket }}" | ||
filter: FILES | ||
action: MOVE | ||
moveTo: | ||
key: archive/ | ||
maxKeys: 1 | ||
extend: | ||
title: "Detect New Files in S3 and process them in Python" | ||
description: >- | ||
This flow will be triggered whenever a new file is | ||
detected in the specified S3 bucket. It will download the file into the | ||
internal storage and move the S3 object to an `archive` folder (i.e. S3 | ||
object prefix with the name `archive`). | ||
The Python code will read the file as an `inputFile` called `input.csv` | ||
and processing it to generate a new file called `data.csv`. | ||
It's recommended to set the `accessKeyId` and `secretKeyId` properties as | ||
secrets. | ||
This flow assumes AWS credentials stored as secrets `AWS_ACCESS_KEY_ID`, | ||
`AWS_SECRET_ACCESS_KEY`. | ||
tags: | ||
- S3 | ||
- Trigger | ||
ee: false | ||
demo: false | ||
meta_description: This flow triggers on new file detection in a specified S3 | ||
bucket. It downloads files to internal storage and moves objects to an | ||
'archive' folder. The file is processed by a Python script. |