{"id":18395308,"url":"https://github.com/acidlemon/mirage-ecs","last_synced_at":"2025-09-09T12:33:25.758Z","repository":{"id":43179771,"uuid":"202047548","full_name":"acidlemon/mirage-ecs","owner":"acidlemon","description":"mirage (github.com/acidlemon/mirage) for Amazon ECS","archived":false,"fork":false,"pushed_at":"2025-03-25T01:18:31.000Z","size":835,"stargazers_count":74,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"v2","last_synced_at":"2025-03-31T06:08:33.762Z","etag":null,"topics":["amazon-ecs","docker"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/acidlemon.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-13T02:30:39.000Z","updated_at":"2025-03-25T01:18:06.000Z","dependencies_parsed_at":"2024-01-22T11:33:54.411Z","dependency_job_id":"2a437ffc-7a34-443b-978d-3178f532c6a8","html_url":"https://github.com/acidlemon/mirage-ecs","commit_stats":{"total_commits":316,"total_committers":13,"mean_commits":"24.307692307692307","dds":0.2626582278481012,"last_synced_commit":"3cf35db0f92ceadd1a4b01d247045def7db28879"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acidlemon%2Fmirage-ecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acidlemon%2Fmirage-ecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acidlemon%2Fmirage-ecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acidlemon%2Fmirage-ecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acidlemon","download_url":"https://codeload.github.com/acidlemon/mirage-ecs/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615385,"owners_count":20967184,"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":["amazon-ecs","docker"],"created_at":"2024-11-06T02:08:46.668Z","updated_at":"2025-04-07T08:21:23.225Z","avatar_url":"https://github.com/acidlemon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mirage-ecs - reverse proxy frontend for Amazon ECS\n\nmirage-ecs is a reverse proxy for ECS tasks and a manager for the tasks.\n\nmirage-ecs can run and stop ECS tasks and proxy HTTP requests to the tasks with a specified subdomain. Additionally, mirage passes variables to containers in tasks using environment variables.\n\n## Usage\n\n### Minimal Configuration\n\nSet a single environment variable.\n\n`MIRAGE_DOMAIN=.dev.example.net` (default is `.local`)\n\n1. mirage-ecs accepts HTTP request on \"https://mirage.dev.example.net\".\n2. Launch ECS task container specified subdomain by API or Web UI.\n3. Now, you can access to the task using \"https://\u003csubdomain\u003e.dev.exmaple.net/\".\n\n`*.dev.example.net` should be resolved to mirage-ecs webapi.\n\n### Launch a mirage-ecs on ECS\n\nmirage-ecs is designed to work as an ECS service deployed under an Application Load Balancer (ALB).\n\nAn example of terraform configuration for deploying mirage-ecs is [terraform/](terraform/).\n\nAn example of task definition of mirage-ecs is [ecs-task-def.json](ecs-task-def.json).\n\nPre build container images are available at [ghcr.io/acidlemon/mirage-ecs](https://github.com/acidlemon/mirage-ecs/pkgs/container/mirage-ecs).\n\nRequirements:\n- `awsvpc` network mode.\n- A public IP address or NAT Gateway or VPC endpoints to call AWS APIs.\n- IAM Permissions to launch ECS tasks, and report metrics and get logs.\n  - `iam:PassRole`\n  - `ecs:RunTask`\n  - `ecs:DescribeTasks`\n  - `ecs:DescribeTaskDefinition`\n  - `ecs:DescribeServices`\n  - `ecs:StopTask`\n  - `ecs:ListTasks`\n  - `cloudwatch:PutMetricData`\n  - `cloudwatch:GetMetricData`\n  - `logs:GetLogEvents`\n  - `route53:GetHostedZone` (optional for mirage link)\n  - `route53:ChangeResourceRecordSets` (optional for mirage link)\n  - `s3:GetObject` (optional for loading config/html files from S3)\n  - `s3:ListBucket` (optional for loading html files from S3)\n\nSee also [terraform/iam.tf](terraform/iam.tf).\n\n### Using Web Interface\n\n1. Access to mirage web interface via \"https://mirage.dev.example.net/\".\n1. Press \"Launch New Task\".\n1. Fill launch options.\n   - subdomain: cool-feature\n   - branch: feature/cool\n   - taskdef: myapp\n1. Now, you can access to container using \"https://cool-feature.dev.exmaple.net/\".\n1. Press \"Terminate\" button.\n\n![](docs/mirage-ecs-list.png)\n\n![](docs/mirage-ecs-launcher.png)\n\n### API Usage\n\nLaunch an ECS task using curl.\n\n```console\n$ curl https://mirage.dev.example.net/api/launch \\\n  -d subdomain=cool-feature \\\n  -d branch=feature/cool \\\n  -d taskdef=myapp\n```\n\nTerminate the task using curl.\n\n```console\n$ curl https://mirage.dev.example.net/api/terminate \\\n  -d subdomain=cool-feature\n```\n\n`subdomain` supports wildcard (e.g. `www*`,`foo[0-9]`, `api-?-test`).\n\n#### Specification of wildcard match\n\nmirage-ecs supports wildcard in `subdomain` parameter.\n\nMatches a pattern to hostname using Go's [path/#Match](https://golang.org/pkg/path/#Match).\n\nIf multiple tasks match the pattern, mirage-ecs prefer the task with the earliest launch time. Not a longest match. For example,\n\n1. Launches a task with `subdomain=foo-*`.\n2. Launches a task with `subdomain=foo-bar-*`.\n3. Launches a task with `subdomain=*-baz`.\n\n`foo-bar-baz` matches 1 and 2 and 3, but mirage-ecs prefer 1.\n\nAfter `foo-*` is terminated, `foo-bar-baz` matches 2 and 3, but mirage-ecs prefer 2.\n\n### Full Configuration\n\nmirage-ecs can be configured by a config file.\n\nWrite a YAML file, and specify the file by the `-conf` CLI option or the `MIRAGE_CONF` environment variable.\n\nmirage-ecs can load config file from S3 and local file. To load config file from S3, specify the S3 URL (e.g. `s3://example-bucket/config.yaml`) to the `MIRAGE_CONF` environment variable.\n\nThe default configuration is same as below.\n\n```yaml\nhost:\n  webapi: mirage.local\n  reverse_proxy_suffix: .local\nlisten:\n  foreign_address: 0.0.0.0\n  http:\n    - listen: 80\n      target: 80\nnetwork:\n  proxy_timeout: 0\nhtmldir: ./html\nparameters:\n  - name: branch\n    env: GIT_BRANCH\n    rule: \"\"\n    required: true\n```\n\n#### `host` section\n\n`host` section configures hostname of mirage-ecs webapi and suffix of launched ECS task hostname.\n\n```yaml\nhost:\n  webapi: mirage.dev.example.net         # hostname of mirage-ecs webapi\n  reverse_proxy_suffix: .dev.example.net # suffix of launched ECS task hostname\n```\n\n#### `listen` section\n\n`listen` section configures port number of mirage-ecs webapi and target ECS task.\n\n```yaml\nlisten:\n  http:\n    - listen: 80 # port number of mirage-ecs webapi\n      target: 80 # port number of target ECS task\n      require_auth_cookie: true # require auth cookie to access to target ECS task\n```\n\nWhen `require_auth_cookie` is true, mirage-ecs requires a cookie to access to target ECS task. mirage-ecs sets a cookie to the browser if authorized by other authentication methods. The cookie is used to authenticate the request to target ECS task. See also `cookie_secret` section in `auth` configuration.\n\nWhen `require_auth_cookie` is false (default), mirage-ecs does not restrict access to target ECS task.\n\nThis configuration allows to specify multiple ports. mirage-ecs listens to all ports and proxies to the target ECS task.\n\n```yaml\nlisten:\n  http:\n    - listen: 3000\n      target: 3000\n      require_auth_cookie: true\n    - listen: 5000\n      target: 5000\n      require_auth_cookie: false\n```\n\n#### `network` section\n\n`network` section configures network settings of mirage-ecs reverse proxy.\n\n```yaml\nnetwork:\n  proxy_timeout: 30s # timeout of reverse proxy\n```\n\n`proxy_timeout` default is 0 (means no timeout). If `proxy_timeout` is not 0, mirage-ecs timeouts the request to backends after the specified duration and returns HTTP status 504 (Gateway Timeout).\n\n#### `parameters` section\n\n`parameters` section configures parameters for launched ECS task for subdomains.\n\nThe default parameter \"branch\" as below.\n\n```yaml\nparameters:\n  - name: branch\n    env: GIT_BRANCH\n    rule: \"\"\n    required: true\n```\n\nYou can add any custom parameters. \"rule\" option is regexp string.\n\nThese parameters are passed to ECS task as environment variables and tags of the task.\n\n##### default value\n\nA parameter can have a default value. The default value is used when the parameter is not specified.\n\n```yaml\nparameters:\n  - name: foo\n    env: FOO\n    default: bar\n```\n\n##### regexp rule\n\nA parameter can have a regexp rule. The rule is used to validate the parameter value.\n\n```yaml\nparameters:\n  - name: foo\n    env: FOO\n    rule: \"^[a-z]+$\"\n```\n\n##### description\n\nA parameter can have a description. The description is used to show the parameter in the web interface.\n\n```yaml\nparameters:\n  - name: foo\n    env: FOO\n    description: \"foo parameter\"\n```\n\n##### required\n\nA parameter can be required. If the parameter is required, mirage-ecs returns an error when the parameter is not specified.\n\nThis option can use with `default` option.\n\n```yaml\nparameters:\n  - name: foo\n    env: FOO\n    required: true\n```\n\n##### options\n\nA parameter defines selectable options. The options are used to create a select box in the web interface.\n\n```yaml\nparameters:\n  - name: foo\n    env: FOO\n    options:\n      - label: bar  # if label is not specified, use value\n        value: bar\n      - label: baz\n        value: baz\n```\n\n#### `htmldir` section\n\n`htmldir` section configures directory of mirage-ecs webapi template files.\n\nSee [html/](html/) directory for default template files. If you want to customize the web interface, copy the files to your directory and modify them.\n\nRequired files are below.\n\n```\nhtml\n├── launcher.html\n├── layout.html\n└── list.html\n```\n\n`htmldir` allows to specify a directory path or a S3 URL.\n\n```yaml\nhtmldir: s3://example-bucket/html/\n```\n\nWhen a s3 URL is specified, mirage-ecs loads template files from the S3 bucket at startup.\n\n#### `ecs` section\n\nmirage-ecs configures `ecs` section automatically based on the ECS service and task of itself.\n\n- `region` is set to `AWS_REGION` enviroment variable.\n- `cluster` and `network_configuration` is set to same as the ECS service.\n- `launch_type` is set to `FARGATE`.\n- `enable_execute_command` is set to `true`.\n- `capacity_provider_strategy` is set to null.\n  - If you want to use capacity provider, write the `ecs` section and remove `launch_type`.\n- `default_task_definition` is not set.\n  - Need to specify the task definition name when launching a task.\n\nIf you want to partially override the settings, write the `ecs` section.\n\n```yaml\necs:\n  region: \"ap-northeast-1\"\n  cluster: mycluster\n  default_task_definition: myapp\n  enable_execute_command: true\n  launch_type: FARGATE\n  network_configuration:\n    awsvpc_configuration:\n      subnets:\n        - subnet-aaaa0000\n        - subnet-bbbb1111\n        - subnet-cccc2222\n      security_groups:\n        - sg-11112222\n        - sg-aaaagggg\n      assign_public_ip: ENABLED\n```\n\n#### `link` section\n\n`link` section configures mirage link.\n\n```yaml\nlink:\n  hosted_zone_id: ZZZZZZZZZZZZZZ  # Route53 hosted zone ID\n  default_task_definitions:\n    - frontend-taskdef\n    - backend-taskdef\n```\n\nSee [\"mirage link\"](#mirage-link) for details.\n\n#### `purge` section\n\n`purge` section configures purge settings.\n\n```yaml\npurge:\n  schedule: \"13 4 * * ? *\" # cron expression\n  request:\n    duration: 86400\n    excludes:\n      - foo\n      - bar\n    exclude_tags:\n      - \"branch:preview\"\n    exclude_regexp: \"^(foo|bar)\"\n```\n\nThe `schedule` is a cron expression to run the purge task.\n\n- mirage-ecs runs the purge task at the specified schedule.\n- The expression is the same as the Amazon EventBridge `cron()`.\n  - See the document of [Cron expressions](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html#eb-cron-expressions) for details.\n  - Timezone is depends on the ECS task timezone.\n\nThe `request` section is the same as the `/api/purge` API. See [API Documents](#post-apipurge).\n\n#### `auth` section\n\n`auth` section configures authentication to restrict access to webapi. The access via reverse proxy is not restricted by auth methods.\n\nThis section is optional.\n\nmirage-ecs supports token authentication, basic authentication and Amazon OIDC authentication by Application Load Balancer for web browser access (excludes requests for `/api/*`). You can use multiple authentication methods at the same time.\n\nFor `/api/*` requests, mirage-ecs allows access by token authentication only.\n\nIf you configure multiple authentication methods, mirage-ecs checks the methods in order token, Amazon OIDC, and basic.  When some method succeeds, mirage-ecs allows access.\n\n```yaml\nauth:\n  cookie_secret: \"{{ env `MIRAGE_COOKIE_SECRET` }}\"\n  token:\n    header: x-mirage-token\n    token: \"{{ env `MIRAGE_TOKEN` }}\"\n  amzn_oidc:\n    claim: email\n    matchers:\n      - suffix: \"@example.com\"\n      - exact: \"foo@example.net\"\n  basic:\n    username: mirage\n    password: \"{{ env `MIRAGE_PASSWORD` }}\"\n```\n\n##### `cookie_secret` sub section\n\n`cookie_secret` section configures secret key for cookie authentication.\n\nWhen you configure `cookie_secret`, mirage-ecs sets a cookie to the browser after being authorized by other authentication methods. The cookie is used to authenticate the next request for web browser access and reverse proxy to the target ECS tasks.\n\nWhen `/api/*` is accessed, mirage-ecs does not set a cookie to the clients. The `/api/*`\npaths allow authentication by token only.\n\n##### `token` sub section\n\n`token` section configures token authentication. The token is passed by specfied HTTP header.\n\n```yaml\nauth:\n  token:\n    header: x-mirage-token\n    token: foobarbaz\n```\n\nThis configuration requires `x-mirage-token: foobarbaz` HTTP header to access mirage-ecs.\n\n##### `basic` sub section\n\n`basic` section configures HTTP Basic authentication.\n\n```yaml\nauth:\n  basic:\n    username: mirage\n    password: foobarbaz\n```\n\nThis configuration requires username and password to access mirage-ecs by Basic authentication.\n\n##### `amzn_oidc` sub section\n\n`amzn_oidc` section configures OIDC authentication by Application Load Balancer. See also [Authenticate users using an Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html)\n\n```yaml\nauth:\n  amzn_oidc:\n    claim: email\n    matchers:\n      - suffix: \"@example.com\"\n      - exact: \"foo@example.net\"\n```\n\nWhen ALB passes an OIDC token, mirage-ecs validates the token and checks the claim value. If the claim value matches any matchers, mirage-ecs allows access.\n\n##### OIDC authentication with ALB\n\nWhen you configure OIDC authentication at ALB, you must prepare two listener rules. One is for mirege webapi access with OIDC authentication, and the other is for the URLs of launched ECS tasks without OIDC authentication.\n\nFor example, if you configure OIDC authentication for `https://mirage.dev.example.net/*`, you must configure the following listener rules.\n\n1. `https://mirage.dev.example.net/*` with OIDC authentication.\n2. `https://*.dev.example.net/*` without OIDC authentication.\n\nBoth listener rules must forward requests to a target group of mirage-ecs.\n\nTo explain the reason for this, a session cookie provided by ALB is used to authenticate the request to mirage-ecs webapi. But the cookie is not sent to launched ECS tasks because the host of the URL is different. So, you must configure the second listener rule to allow access to launched ECS tasks without OIDC authentication.\n\nIn this case, `auth.cookie_secret` and `listen.http[].require_auth_cookie` settings are useful to restrict access to launched ECS tasks.\n\nWhen these settings are enabled, mirage-ecs sends an original cookie to the browser after being authorized by OIDC authentication. The cookie has a domain attribute and is also sent to launched ECS tasks. mirage-ecs validates the cookie to authenticate the request to launched ECS tasks.\n\n## mirage link\n\nmirage link feature enables to launch and terminate multiple tasks that have the same subdomain.\n\nThis feature helps launch so many containers that have the same subdomain. (A single ECS task can only have up to 10 containers)\n\nmirage link works as below.\n- Launch API launches multiple tasks that have the same subdomain.\n  - `/api/launch` accepts multiple `taskdef` parameters for each tasks.\n- mirage-ecs puts to DNS name of these tasks into Route53 hosted zone.\n  -  e.g. `{container-name}.{subdomain}.{hosted-zone} A {tasks IP address}`\n\nFor example,\n- hosted zone: `mirage.example.com``\n- First task (IP address 10.1.0.1) has container `proxy`.\n- Second task (IP address 10.2.0.2) has container `app`.\n- Subdomain: `myenv`\n\nmirage-ecs puts the following DNS records.\n- `nginx.myenv.mirage.example.com A 10.1.0.1`\n- `app.myenv.mirage.example.com A 10.2.0.2`\n\nSo the proxy container can connect to the app with the DNS name `app.myenv.mirage.example.com`.\n\nTo enable mirage link, define your Route53 hosted zone ID in a config.\n\n```yaml\nlink:\n  hosted_zone_id: your route53 hosted zone ID\n```\n\n## API Documents\n\nmirage-ecs provides the following APIs.\n\nPOST APIs are accepts parameters from a request body as `content-type: application/json`.\n\nFor v1 backward compatibility, `-compat-v1` cli flag enables accepting `application/x-www-form-urlencoded`. But this feature may cause CSRF vulnerability. We recommend to use `application/json` only (v2 defaults).\n\nGET APIs only accept URL query parameters.\n\n### `GET /api/list`\n\n`/api/list` returns list of running tasks.\n\n```json\n{\n  \"result\": [\n    {\n      \"id\": \"arn:aws:ecs:ap-northeast-1:12345789012:task/dev/af8e7a6dad6e44d4862696002f41c2dc\",\n      \"short_id\": \"af8e7a6dad6e44d4862696002f41c2dc\",\n      \"subdomain\": \"b15\",\n      \"branch\": \"topic/b15\",\n      \"taskdef\": \"dev:756\",\n      \"ipaddress\": \"10.206.242.48\",\n      \"created\": \"0001-01-01T00:00:00Z\",\n      \"last_status\": \"PENDING\",\n      \"port_map\": {\n        \"nginx\": 80\n      },\n      \"env\": {\n        \"GIT_BRANCH\": \"topic/b15\",\n        \"SUBDOMAIN\": \"YjE1\"\n      }\n    },\n    {\n      \"id\": \"arn:aws:ecs:ap-northeast-1:123456789012:task/dev/d007a00bf9a0411ebbcf95291aced40f\",\n      \"short_id\": \"d007a00bf9a0411ebbcf95291aced40f\",\n      \"subdomain\": \"bench\",\n      \"branch\": \"feature/bench\",\n      \"taskdef\": \"dev:641\",\n      \"ipaddress\": \"10.206.240.60\",\n      \"created\": \"2023-03-13T00:29:08.959Z\",\n      \"last_status\": \"RUNNING\",\n      \"port_map\": {\n        \"nginx\": 80\n      },\n      \"env\": {\n        \"GIT_BRANCH\": \"feature/bench\",\n        \"SUBDOMAIN\": \"YmVuY2g=\"\n      }\n    }\n  ]\n}\n```\n\n### `POST /api/launch`\n\n`/api/launch` launches a new task.\n\n#### Form parameters\n\nContent-Type must be `application/x-www-form-urlencoded`.\n\n- `subdomain`: subdomain of the task. (required)\n- `taskdef`: ECS task definition name (maybe includes revision) for the task. (required)\n- extra parameters: Additional parameters for the task. (optional, defined in config file `parameters` section)\n  - `branch`: branch is appended to extra parameters automatically.\n\n#### JSON parameters\n\nYou can also specify parameters as JSON. Content-Type must be `application/json`.\n\n```json\n{\n  \"subdomain\": \"bench\",\n  \"taskdef\": [\"dev:641\"],\n  \"branch\": \"feature/bench\",\n  \"parameters\": {\n    \"launched_by\": \"foo\"\n  }\n}\n```\n\n#### Response\n\n```json\n{\n  \"result\": \"accepted\"\n}\n```\n\n#### Extra parameters\n\nExtra parameters are passed to ECS task as environment variables.\nFor example, if you define the following parameters in config file, and launch a task with `launched_by=foobar` parameter, mirage-ecs launches a task with `GIT_BRANCH=main` and `LAUNCHED_BY=foobar` environment variables.\n\n```yaml\nparameters:\n  - name: branch\n    env: GIT_BRANCH\n    rule: \"\"\n    required: true\n    default: main\n  - name: launched_by\n    env: LAUNCHED_BY\n    rule: \"\"\n    required: false\n```\n\nmirage-ecs also add `SUBDOMAIN` environment variable to the task.\n\n- (v0 and v1) `SUBDOMAIN` contains a base64 encoded value of `subdomain` parameter.\n- (v2) `SUBDOMAIN` contains a raw value of `subdomain` parameter.\n  `-compat-v1` cli flag enables v0,v1 behavior.\n\nmirage-ecs tags the ECS task with following keys and values.\n- `ManagedBy=mirage-ecs`\n- `Subdomain={base64 encoded subdomain}`\n- `branch={branch}`\n- `launched_by={launched_by}`\n\nThe tag value of `Subdomain` is the base64 encoded value of the `subdomain` parameter always because some special characters(for example, `*`) are not allowed in tag values.\n\n#### `GET /api/logs`\n\n`/api/logs` returns logs of the task.\n\nQuery parameters:\n- `subdomain`: subdomain of the task.\n- `since`: RFC3339 timestamp of the first log to return.\n- `tail`: number of lines to return or `all`.\n\n```json\n{\n    \"result\": [\n      \"2023/03/13 00:29:08 [notice] 1#1: using the \\\"epoll\\\" event method\",\n      \"2023/03/13 00:29:08 [notice] 1#1: nginx/1.11.10\",\n    ]\n}\n```\n\n### `POST /api/terminate`\n\n`/api/terminate` terminates the task.\n\n#### Form parameters\n\n- `subdomain`: subdomain of the task.\n- `id`: task ID of the task.\n\n- `subdomain` and `id` are exclusive. If both are specified, `id` is used.\n- `id` is a short ID of the task(e.g. `af8e7a6dad6e44d4862696002f41c2dc`) or Arn of the ECS task.(e.g. `arn:aws:ecs:ap-northeast-1:123456789012:task/dev/af8e7a6dad6e44d4862696002f41c2dc`)\n\n#### JSON parameters\n\n```json\n{\n  \"subdomain\": \"bench\"\n}\n```\n\nor\n\n```json\n{\n  \"id\": \"d007a00bf9a0411ebbcf95291aced40f\"\n}\n```\n\n#### Response\n\n```json\n{\n  \"result\": \"ok\"\n}\n```\n\n### `GET /api/access`\n\n`/api/access` returns access counter of the task.\n\nQuery parameters:\n- `subdomain`: subdomain of the task.\n- `duration`: duration(seconds) of the counter. default is 86400.\n\n```json\n{\n  \"result\": \"ok\",\n  \"duration\": 86400,\n  \"sum\": 123\n}\n```\n\n### `POST /api/purge`\n\n`/api/purge` terminates tasks that not be accessed in the specified duration.\n\nSee also [purge section](#purge-section) of config file.\n\n#### Form parameters\n\n- `excludes`: subdomains of tasks to exclude termination. multiple values are allowed.\n- `exclude_tags`: tags of tasks to exclude termination. multiple values are allowed.\n  - format is `Key:Value`\n  - See also /api/launch.\n- `exclude_regexp`: A regexp of subdomains to exclude termination.\n  - This value is compiled by [`regexp`](https://pkg.go.dev/regexp) package.\n- `duration`: duration(seconds) of the counter. required. minimum is 300 (5 min).\n\n\n#### JSON parameters\n\n```json\n{\n  \"excludes\": [\"foo\", \"bar\"],\n  \"exclude_tags\": [\"branch:preview\"],\n  \"exclude_regexp\": \"^(foo|bar)\",\n  \"duration\": 86400\n}\n```\n\nmirage-ecs counts access of all tasks the same as `/api/access` API internally. If the access count of a task is 0 and the task has an uptime over the specified duration, terminate these tasks.\n\nFor example, if you specify `duration=86400`, mirage-ecs terminates tasks that meet the following conditions both.\n- Not be accessed in the last 24 hours.\n- Uptime over 24 hours.\n\nThis API works ansynchronously. The response is returned immediately. mirage-ecs terminates tasks in the background.\n\nNote: `duration` accepts a value of integer or string. You can also specify by string type, for example, `{\"duration\":\"86400\"}`.\n\n#### Response\n\n```json\n{\n  \"result\": \"accepted\"\n}\n```\n\n## Requirements\n\nmirage-ecs requires [ECS Long ARN Format](https://aws.amazon.com/jp/blogs/compute/migrating-your-amazon-ecs-deployment-to-the-new-arn-and-resource-id-format-2/) for tagging tasks.\n\nIf your account do not enable these settings yet, you must enable that.\n\n```console\n$ aws ecs put-account-setting-default --name taskLongArnFormat --value enabled\n```\n\nLicense\n--------\n\nThe MIT License (MIT)\n\n(c) 2019 acidlemon. (c) 2019 KAYAC Inc. (c) 2019 fujiwara.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facidlemon%2Fmirage-ecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facidlemon%2Fmirage-ecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facidlemon%2Fmirage-ecs/lists"}