Terraform module to provision ECS service with daemon scheduling strategy.
It's 100% Open Source and licensed under the APACHE2.
This module helps to provision ECS service scheduled on ECS container instances (EC2) daemon scheduling strategy. It can be useful when you need to run a software on every EC2 host in your ECS cluster, e.g. host monitoring agents, service discovery agents, log collectors etc.
This module is backed by best of breed terraform modules maintained by Cloudposse.
IMPORTANT: The master
branch is used in source
just as an example. In your code, do not pin to master
because there may be breaking changes between releases.
Instead pin to the release tag (e.g. ?ref=tags/x.y.z
) of one of our latest releases.
This example creates an ECS cluster service scheduled with daemon scheduling strategy:
module "daemon_service" {
source = "git::https://github.com/aleks-fofanov/terraform-aws-ecs-service-task-daemonset?ref=master"
name = "daemon"
namespace = "cp"
stage = "prod"
ecs_cluster_arn = "XXXXXXXXXXX"
container_definition_json = "${module.container_definition.json}"
container_name = "daemon"
task_cpu = "256"
task_memory = "512"
}
This example provisions Fluent ECS services scheduled as a daemon on every ECS container instance (EC2):
module "fluentd_container_definition" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition?ref=master"
container_name = "fluentd"
container_image = "aleksfofanov/ecs-datadog-logs-aggregator:0.1.0"
container_memory = "512"
container_memory_reservation = "512"
container_cpu = "256"
port_mappings = [
{
containerPort = "24224"
hostPort = "24224"
protocol = "udp"
},
{
containerPort = "24224"
hostPort = "24224"
protocol = "tcp"
},
]
}
module "fluentd_logs_aggregator" {
source = "git::https://github.com/aleks-fofanov/terraform-aws-ecs-service-task-daemonset?ref=master"
name = "fluentd"
namespace = "cp"
stage = "prod"
ecs_cluster_arn = "XXXXXXXXXXX"
container_definition_json = "${module.fluentd_container_definition.json}"
task_cpu = "256"
task_memory = "512"
}
Available targets:
help Help screen
help/all Display help for all targets
help/short This help short screen
lint Lint terraform code
Name | Description | Type | Default | Required |
---|---|---|---|---|
attributes | Additional attributes (e.g. 1 ) |
list | <list> |
no |
container_definition_json | The JSON of the task container definition | string | - | yes |
delimiter | Delimiter to be used between name , namespace , stage , etc. |
string | - |
no |
ecs_cluster_arn | The ARN of the ECS cluster where service will be provisioned | string | - | yes |
ignore_changes_task_definition | Whether to ignore changes in container definition and task definition in the ECS service | string | true |
no |
name | Solution name, e.g. 'app' or 'cluster' | string | - | yes |
namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes |
stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | - | yes |
tags | Additional tags (e.g. map('BusinessUnit ,XYZ ) |
map | <map> |
no |
task_cpu | The number of CPU units used by the task | string | 256 |
no |
task_memory | The amount of memory (in MiB) used by the task | string | 512 |
no |
volumes | Task volume definitions as list of maps | list | <list> |
no |
Name | Description |
---|---|
ecs_exec_role_policy_id | The ECS service role policy ID, in the form of role_name:role_policy_name |
ecs_exec_role_policy_name | ECS service role name |
service_name | ECS Service name |
service_role_arn | ECS Service role ARN |
task_definition_family | ECS task definition family |
task_definition_revision | ECS task definition revision |
task_exec_role_arn | ECS Task exec role ARN |
task_exec_role_name | ECS Task role name |
task_role_arn | ECS Task role ARN |
task_role_id | ECS Task role id |
task_role_name | ECS Task role name |
Check out these related projects.
- terraform-aws-ecs-fluentd-datadog-daemonset - Terraform module to provision ECS service configured to collect logs from containers scheduled on EC2 container instances and ship them to Datadog
- terraform-aws-ecs-cluster-traefik - Terraform module to provision ECS cluster with Traefik as an edge router
- ecs-datadog-logs-aggregator - Customized Fluentd image configured to be deployed AWS ECS cluster and ship containers logs to Datadog
Got a question?
File a GitHub issue.
Please use the issue tracker to report any bugs or file feature requests.
In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull Request so that we can review your changes
NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!
Copyright © 2017-2019 Aleksandr Fofanov
See LICENSE for full details.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
All other trademarks referenced herein are the property of their respective owners.
Aleksandr Fofanov |
---|