Github Example
This example sets up a Github integration for your Cloudomation account. With a Github integration, you can write and edit flow scripts offline in your favourite editor. Simply push your flow scripts (and other resources such as settings) to your Github repository and they will be automatically copied over to your Cloudomation account.
The example consists of three flow scripts. The first two flow scripts set up the Github integration for your Cloudomation account. You only need to run them once. The third flow script synchronises flow scripts and other content from your Github repository to Cloudomation continuously.
The example here is set up for Github, but the principle is the same for any git repository.
Find all three flow scripts in the public flow script library:
- Flow 1: Set up webhooks
- Flow 2: Set up Github repository (optional)
- Flow 3: Synchronise resources
To run the full process, make sure that you have all three flow scripts in your Cloudomation account, and that the flow scripts are named the same as they are in Github (without the .py extension). Start with Flow 1 (Configure Github and Cloudomation) and see what happens. Enjoy!
Flow 1: Set up Webhooks
The first flow script configures two webhooks: one on Cloudomation, and one on Github. This flow script is called "configure_webhooks_github_cloudomation.py" in the public flow script library. The webhook on Github pushes a notification to the webhook on Cloudomation every time there is a push to the Github repository for which the webhook is set up. The Cloudomation webhook receives the notification from Github and triggers Flow 3, which synchronises flow scripts and settings from the Github repository into Cloudomation.
The Cloudomation webhook can be configured to trigger any flow script, and the webhook on Github can be configured to push different notifications: e.g. when there is a pull request on the repository. The synchronisation of flow scripts into Cloudomation is only one of many possible examples of how such a setup could be used. Other uses could be to trigger a build for a software whenever there is a push to a repository (the build can be triggered on a build server, or be implemented within Cloudomation). Or you could simply set up a notification system: notify certain people whenever there is a pull request on your git repository.
Flow 2: Set up Github Repository
The second flow script is called "request_github_info.py" in the public flow script library. It asks you for your Github information. If you do not yet have a Github repository that you want to use together with Cloudomation, this flow script will guide you through the process of setting up a repository. Once this flow script has received all necessary Github information from you, it will provide this information back to Flow 1, which will automatically configure a webhook for your Github repository.
Flow 3: Synchronise Resources
The third flow script is called "sync_from_github.py" in the public flow script library. Every time there is a push to your Github repository, the Github webhook will trigger the Cloudomation webhook which will start this flow script. This flow script copies all resources from your Github repository to Cloudomation and creates flow scripts and settings from .py and .yaml files in your Github repository.
Note that files with endings other than .yaml and .py will be ignored.
Note also that this script is not intended for synchronisation of very large files or very large github repositories with thousands of files.