{"id":15704035,"url":"https://github.com/rams3sh/c7n-mailer_playground","last_synced_at":"2025-07-21T17:32:31.567Z","repository":{"id":54913329,"uuid":"342825476","full_name":"rams3sh/c7n-mailer_playground","owner":"rams3sh","description":"Playground for testing c7n-mailer templates.","archived":false,"fork":false,"pushed_at":"2021-02-27T18:01:02.000Z","size":255,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-30T10:23:42.065Z","etag":null,"topics":["c7n","c7n-mailer","cloud-custodian","cloudcustodian"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rams3sh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-27T10:07:26.000Z","updated_at":"2022-08-08T23:52:11.000Z","dependencies_parsed_at":"2022-08-14T06:30:38.432Z","dependency_job_id":null,"html_url":"https://github.com/rams3sh/c7n-mailer_playground","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rams3sh/c7n-mailer_playground","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rams3sh%2Fc7n-mailer_playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rams3sh%2Fc7n-mailer_playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rams3sh%2Fc7n-mailer_playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rams3sh%2Fc7n-mailer_playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rams3sh","download_url":"https://codeload.github.com/rams3sh/c7n-mailer_playground/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rams3sh%2Fc7n-mailer_playground/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266342809,"owners_count":23914262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c7n","c7n-mailer","cloud-custodian","cloudcustodian"],"created_at":"2024-10-03T20:09:59.156Z","updated_at":"2025-07-21T17:32:31.543Z","avatar_url":"https://github.com/rams3sh.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# c7n-mailer Playground\n\nThis is a very simple flask based app that helps in creating and testing Jinja templates for [c7n-mailer](https://cloudcustodian.io/docs/tools/c7n-mailer.html).\n\nThis was created for helping me write custom mailer templates for my organization's c7n setup.\n\n## 1. Background\n\nI was bored with custodian's default template and I had some use case to add some disclaimers and add some flashy message \nto get the attention of the teams violating certain compliances.\n\nTesting the new template was difficult as I had to keep sending emails to my inbox as test mails to check the rendered\ntemplate.\n\nHence the birth of this simple setup.\n\nIt uses flask to serve the API service. It uses jinja (same as what c7n-mailer uses) as \nit's template engine along with same jinja filters that c7n-mailer provides for usage.\n\n## 2. Installation\n\n* Clone this repository \n  ```\n  git clone https://github.com/rams3sh/c7n-mailer_playground\n  cd c7n-mailer_playground/\n  ```\n\n* Install the Virtual Environment Package for Python\n  ```\n  pip3 install virtualenv\n  ``` \n* Create virtualenvironment in the folder\n    ```\n    python3 -m virtualenv env\n    ```\n* Activate the virtual environment\n    ```\n    source env/bin/activate\n    ```\n* Install the dependencies \n    ```\n    pip install -r requirements.txt\n    ```\n\n## 3. Running the app\n```bash\npython3 playground.py\n```\n\nThere are two endpoints for the app.\n\n* `/webhook` - This is used as an endpoint to get the raw json of cloudcustodian output and save it in the \n  data folder. It supports `POST` method.\n  \n\n* `/template?name=\u003ctemplate_name\u003e` - This endpoint is used to check how the rendered output will look like.\nIt supports `GET` method. One can use custom template name being passed as part of name parameter. \n  By default, it uses test_template.html.j2 as template if no name is passed.\n  \n## 4. Usage\n\n### 4.1 Getting the raw custodian result json \nAdd the below snippet as part of the actions in your policy for which the template is being prepared. \n\n```\n      - type: webhook\n        url: http://127.0.0.1:5000/webhook\n        method: POST\n        body: \"@\" \n```\n\nEnsure that the actions section also has your `notify` action, since certain sections of the rendered template \nwould require it.\n\nThe above snippet basically results in your policy hitting this API service endpoint with the json\nthat c7n-mailer would end up receiving in it's SQS queue otherwise.\n\n\nRun the c7n_mailer playground in the background and then execute the custodian policy. \nOnce the webhook is hit , the posted  result is saved as custodian_result.json in data folder within the same project.\n\nNow you have the base json to work on and create / test jinja template based on it.\n\n**Note:** \n\nAssumption of the above snippet is that the policy and the playground is being run in your local system.\n\nIf there is any change to the above assumption in your setup, then change and use the webhook url in the above snippet accordingly. \n\n### 4.2 Testing the mailer template\n\nOnce the policy's sample result data is collected in data folder,  you can start creating / testing the template. \n\nOne can access the playground at :-\n\n\u0026nbsp; \u0026nbsp; http://127.0.0.1:5000/template\n\nBy default, it renders, `test_template.html.j2`.\n\nYou can keep making changes to the template in the side and refresh the site to see the changes getting reflected.\n\n\n**Note :**\n  \nIf you are using a custom template, you have to place your template in the templates folder. \nYou can pass the template name as value to `name` parameter to the same url.\n\n\n## 5. Sample Screenshot\n\n#### Sample template prepared and rendered via playground \n\n![img.png](assets/sample_playground_template.png)\n\n\n#### Sample mail alert received through c7n-mailer \n\n![img.png](assets/sample_email.png)\n\n**Note:**\n  \nThere are some subtle changes in the above mail's template from provided template. \nHence, a slight difference. However, majority of the template content is same.\n\n## 6. Disclaimer(s)\n\n* The flask app by default runs in DEBUG mode for testing purposes.\n\n\n* Currently the playground only caters to c7n-mailer's email template testing.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frams3sh%2Fc7n-mailer_playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frams3sh%2Fc7n-mailer_playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frams3sh%2Fc7n-mailer_playground/lists"}