- Event triggers
- Trigger from AWS events
Trigger from AWS events
Run a pipeline whenever an AWS event occurs.
Event triggered pipelines only work when Mage is running in a cloud provider like AWS, GCP, or Azure.
- Create a CloudWatch event rule.
- Add AWS credentials to environment variables for Mage to use.
- Create an event trigger for a pipeline.
Create a CloudWatch event rule
The following steps will walk you through how to create an event rule for SQS.
- Go to the AWS CloudWatch dashboard; e.g. https://us-west-2.console.aws.amazon.com/cloudwatch/home
- Under the Events section, click the Rules link.
- Click the button Create rule; it should take you to a page like this https://us-west-2.console.aws.amazon.com/cloudwatch/home?#rules:action=create
- Under the Event Source section, select the option for Event Pattern.
- In the dropdown menu next to Service Name, select any option; e.g.
Simple Queue Service.
- In the dropdown menu next to Event Type, select an option; e.g.
- Under the Targets section, click the + Add target button.
- In the 1st dropdown menu, select a service; e.g.
- In the dropdown menu next to Queue, select an option.
- In the Configure input radio selection, choose Matched event.
- In the bottom right corner, click the button labeled Configure details.
- Enter a name for this event rule; e.g.
- Check the status box labeled
- In the bottom right corner, click the button labeled Create rule.
Add AWS credentials to environment variables
If you’re using Mage in Docker, add the following environment variables when you run Mage:
The AWS credentials need to have the following permissions:
Follow these instructions to learn more how to add environment variables when running Docker. For example:
docker run -it -p 6789:6789 -v $(pwd):/home/src mageai/mageai \ -e AWS_ACCESS_KEY_ID=... \ -e AWS_SECRET_ACCESS_KEY=... \ /app/run_app.sh mage start [project_name]
If you’re not using Docker to run Mage, run the following commands:
export AIRBNB_AWS_ACCESS_KEY_ID=... export AIRBNB_AWS_SECRET_ACCESS_KEY=...
Create an event trigger
- Follow these instructions to create a trigger.
- When you choose the trigger type, select
- Under the Events section, in the Provider dropdown menu, select the option
- Under the Events section, in the Event dropdown menu, select the name of the event
you created in the previous steps; e.g.
- At the top left corner, click the button Save changes.
Test pipeline trigger
- Go to the AWS SQS dashboard; e.g. https://us-west-2.console.aws.amazon.com/sqs/v2/home
- Click on a row for the queue that is referenced from the event you created in a previous step.
- In the top right corner, click the button Send and receive messages.
- In the input field labeled Message body, type
- In the top right corner, click the button Send message.