{"id":16306009,"url":"https://github.com/songmu/ecschedule","last_synced_at":"2025-04-09T12:04:38.538Z","repository":{"id":37713513,"uuid":"207194081","full_name":"Songmu/ecschedule","owner":"Songmu","description":"ecschedule is a tool to manage ECS Scheduled Tasks.","archived":false,"fork":false,"pushed_at":"2024-07-04T15:10:28.000Z","size":568,"stargazers_count":171,"open_issues_count":5,"forks_count":30,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-11T21:09:24.357Z","etag":null,"topics":["cron","ecs","go","golang","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Songmu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-09T00:49:51.000Z","updated_at":"2024-09-21T05:15:47.000Z","dependencies_parsed_at":"2023-11-10T14:41:32.148Z","dependency_job_id":"f5e00a58-361b-4e50-834a-8fd34b1bac35","html_url":"https://github.com/Songmu/ecschedule","commit_stats":null,"previous_names":["songmu/ecsched"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Songmu%2Fecschedule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Songmu%2Fecschedule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Songmu%2Fecschedule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Songmu%2Fecschedule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Songmu","download_url":"https://codeload.github.com/Songmu/ecschedule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036063,"owners_count":21037092,"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","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":["cron","ecs","go","golang","yaml"],"created_at":"2024-10-10T21:09:25.083Z","updated_at":"2025-04-09T12:04:38.518Z","avatar_url":"https://github.com/Songmu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"ecschedule\n=======\n\n[![Test Status](https://github.com/Songmu/ecschedule/workflows/test/badge.svg?branch=main)][actions]\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/Songmu/ecschedule)][PkgGoDev]\n\n[actions]: https://github.com/Songmu/ecschedule/actions?workflow=test\n[license]: https://github.com/Songmu/ecschedule/blob/main/LICENSE\n[PkgGoDev]: https://pkg.go.dev/github.com/Songmu/ecschedule\n\necschedule is a tool to manage ECS Scheduled Tasks.\n\n## Synopsis\n\n```command\n% ecschedule [dump|apply|run|diff] -conf ecschedule.yaml -rule $ruleName\n```\n\n## Description\n\nThe ecschedule manages ECS Schedule tasks using a configuration file (YAML, JSON or Jsonnet format) like following.\n\n```yaml\nregion: us-east-1\ncluster: clusterName\nrules:\n- name: taskName1\n  description: task 1\n  scheduleExpression: cron(30 15 ? * * *)\n  taskDefinition: taskDefName\n  containerOverrides:\n  - name: containerName\n    command: [subcommand1, arg]\n    environment:\n      HOGE: foo\n      FUGA: {{ must_env `APP_FUGA` }}\n- name: taskName2\n  description: task2\n  scheduleExpression: cron(30 16 ? * * *)\n  taskDefinition: taskDefName2\n  containerOverrides:\n  - name: containerName2\n    command: [subcommand2, arg]\n```\n\n## Installation\n\n```console\n% brew install Songmu/tap/ecschedule\n# or\n% go install github.com/Songmu/ecschedule/cmd/ecschedule@latest\n```\n\n### GitHub Actions\n\nAction Songmu/ecschedule@main installs ecschedule binary for Linux into /usr/local/bin. This action runs install only.\n\n```yaml\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - uses: Songmu/ecschedule@main\n      - run: |\n          ecschedule -conf ecschedule.yaml apply -all\n```\n\n### aqua\n\nA declarative CLI Version Manager [aqua](https://aquaproj.github.io/) can install ecschedule.\n\n```console\n% aqua g -i Songmu/ecschedule\n```\n\n## Quick Start\n\n### dump configuration YAML\n\n```console\n% ecschedule dump --cluster clusterName --region us-east-1 \u003e ecschedule.yaml\n```\n\nedit and adjust configuration file after it.\n\n### apply new or updated rule\n\n```console\n% ecschedule -conf ecschedule.yaml apply -rule $ruleName\n```\n\nBefore you apply it, you can check the diff in the following way.\n\n```console\n% ecschedule -conf ecschedule.yaml diff -rule $ruleName\n```\n\n### run rule\n\nExecute `run` subcommand when want execute arbitrary timing.\n\n```console\n% ecschedule -conf ecschedule.yaml run -rule $ruleName\n```\n\n### Using the `-prune` option to manage rules\n\nIn version `v0.9.1` and earlier, when rules were renamed or deleted from the configuration, the old rules remained and had to be deleted manually. With the `-prune` option introduced in `v0.10.0`, you can now automatically remove these old rules.\n\n```console\n% ecschedule -conf ecschedule.yaml apply -all -prune\n```\n\nTo see which rules would be deleted without actually removing them, combine with the `-dry-run` option.\n\n```console\n% ecschedule -conf ecschedule.yaml apply -all -prune -dry-run\n```\n\n## Functions\n\nYou can use following functions in the configuration file.\n\n- `env`\n    - expand environment variable or using default value\n    - `{{ env \"ENV_NAME\" \"DEFAULT_VALUE\" }}`\n- `must_env`\n    - expand environment variable\n    - `{{ must_env \"ENV_NAME\" }}`\n\ninspired by [ecspresso](https://github.com/kayac/ecspresso).\n\n## Plugins\n\n### tfstate\n\ntfstate plugin introduces a template function `tfstate`.\n\n```yaml\nregion: us-east-1\ncluster: api\nrole: ecsEventsRole\nrules:\n- name: hoge-task-name\n  description: hoge description\n  scheduleExpression: cron(0 0 * * ? *)\n  taskDefinition: task1\n  group: xxx\n  platform_version: 1.4.0\n  launch_type: FARGATE\n  network_configuration:\n    aws_vpc_configuration:\n      subnets:\n      - {{ tfstate `aws_subnet.private-a.id` }}\n      - {{ tfstate `aws_subnet.private-c.id` }}\n      security_groups:\n      - {{ tfstatef `data.aws_security_group.default['%s'].id` `first` }}\n      - {{ tfstatef `data.aws_security_group.default['%s'].id` `second` }}\n      assign_public_ip: ENABLED\n  containerOverrides:\n  - name: container1\n    command: [\"subcmd\", \"argument\"]\n    environment:\n      HOGE_ENV: {{ env \"DUMMY_HOGE_ENV\" \"HOGEGE\" }}\n    cpu: 1024\n    memory: 1024\n    memoryReservation: 512\n  dead_letter_config:\n    sqs: queue1\n  propagateTags: TASK_DEFINITION\nplugins:\n- name: tfstate\n  config:\n    path: testdata/terraform.tfstate    # path to tfstate file\n      # or url: s3://my-bucket/terraform.tfstate\n```\n\n`{{ tfstate \"resource_type.resource_name.attr\" }}` will expand to an attribute value of the resource in tfstate.\n\n`{{ tfstatef \"resource_type.resource_name['%s'].attr\" \"index\" }}` is similar to `{{ tfstatef \"resource_type.resource_name['index'].attr\" }}`.\nThis function is useful to build a resource address with environment variables.\n\n```\n{{ tfstatef `aws_subnet.ecs['%s'].id` (must_env `SERVICE`) }}\n```\n\n#### Multiple tfstate support\n\nYou can specify multiple tfstate files. Specify the `func_prefix` option to avoid conflicts between functions.\n\n```yaml\nplugins:\n- name: tfstate\n  func_prefix: first_\n  config:\n    path: testdata/first_terraform.tfstate    # path to tfstate file\n- name: tfstate\n  func_prefix: second_\n  config:\n    path: testdata/second_terraform.tfstate    # path to tfstate file\n```\n\nIn this case, the function must be called by the `plugin` function.\n\nThe `plugin` function takes the prefixed function name as the first argument and the function arguments as the second or later arguments.\n\n```\n{{ plugin `first_tfstate` `aws_subnet.private-a.id` }}\n{{ plugin `second_tfstate` `aws_subnet.private-a.id` }}\n```\n\n### ssm\n\nssm plugin introduces a template function `ssm`.\n\n```yaml\nregion: us-east-1\ncluster: api\nrole: ecsEventsRole\nrules:\n- name: fuga-task-name\n  description: fuga description\n  scheduleExpression: cron(0 0 * * ? *)\n  taskDefinition: task1\n  group: xxx\n  platform_version: 1.4.0\n  launch_type: FARGATE\n  network_configuration:\n    aws_vpc_configuration:\n      subnets:\n      - {{ ssm `/subnet/private/a/id` }} # String type.\n      - {{ ssm `/subnet/private/c/id` }}\n      security_groups:\n      - {{ ssm `security_group/default/id` 1 }} # StringList type.\n      - {{ ssm `security_group/default/id` 2 }}\n      assign_public_ip: ENABLED\n  containerOverrides:\n  - name: container1\n    command: [\"subcmd\", \"argument\"]\n    environment:\n      FUGA_ENV: {{ ssm \"/path/to/secretstring/fuga\" }} # SecureString type.\n    cpu: 1024\n    memory: 1024\n    memoryReservation: 512\n  dead_letter_config:\n    sqs: queue1\n  propagateTags: TASK_DEFINITION\nplugins:\n- name: ssm\n```\n\n`{{ ssm \"/path/to/parameter\" }}` will retrieve a parameter from the AWS Systems Manager Parameter Store.\n\nThis function supports String, StringList, and SecureString types.\n\n## Pitfalls\n\n### Rule Name Uniqueness and Overwrite Risks\n\necschedule is designed to guarantee the uniqueness of job definitions by rule name in the configuration file.\n\nIf ecschedule is run in an environment where a Rule that is not managed by ecschedule already exists, ecschedule will overwrite that Rule. If you do not intend to overwrite, please ensure that the names written in the configuration file do not duplicate with existing Rules.\n\n### Note on Previous Versions\n\nIn versions `v0.9.1` and earlier, there were issues related to rule name changes causing garbage definitions and rules not being deleted from AWS when removed from the configuration file. These issues have been addressed in version `v0.10.0` with the introduction of the `-prune` option.\n\n## Author\n\n[Songmu](https://github.com/Songmu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongmu%2Fecschedule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsongmu%2Fecschedule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongmu%2Fecschedule/lists"}