Skip to content

Commit

Permalink
Merge pull request #2 from aleks-fofanov/terraform012_migration
Browse files Browse the repository at this point in the history
Port module to TF 0.12
  • Loading branch information
aleks-fofanov authored Jan 22, 2020
2 parents cfaa4ec + 5c78ceb commit fb5fe7a
Show file tree
Hide file tree
Showing 8 changed files with 455 additions and 398 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ SHELL := /bin/bash

# List of targets the `readme` target should call before generating the readme
export README_DEPS ?= docs/targets.md docs/terraform.md
export TERRAFORM_VERSION=0.12.19

-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)

## Lint terraform code
lint:
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate

override readme/sync: # Aka build with custom template
readme/sync: # Aka build with custom template
README_TEMPLATE_FILE=$(shell pwd)/templates/README.md $(SELF) readme/build
141 changes: 74 additions & 67 deletions README.md

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ related:

# Short description of this project
description: |-
Terraform module to provision [Traefik](https://traefik.io/) service in ECS
Terraform module to provision [Traefik](https://traefik.io/) service in ECS.
This module supports [traefik v1.7](https://docs.traefik.io/v1.7/).
### Terraform versions
Terraform 0.12. Pin module version to `~> 2.0`. Submit pull-requests to `master` branch.
Terraform 0.11. Pin module version to `~> 1.0`. Submit pull-requests to `terraform011` branch.
introduction: |-
Traefik service in ECS is supposed to act as an edge router and route traffic to other containers in your ECS cluster
based on their docker lables.
For more information on which docker labels to set on your container, see
[Traefik documentation](https://docs.traefik.io/configuration/backends/docker/#on-containers).
[Traefik documentation](https://docs.traefik.io/v1.7/configuration/backends/docker/#on-containers).
SSL termination is supposed to be done on AWS ALB. Traefik tasks are launched with `awsvpc` network mode and needs
Internet access to connect to ECS API in order to discover containers in your ECS cluster.
Expand All @@ -74,12 +81,12 @@ usage: |-
subnet_ids = ["XXXXXXXXXXX", "XXXXXXXXXXX", ..]
launch_type = "FARGATE"
assign_public_ip = "true"
assign_public_ip = true
}
```
examples: |-
### Example With [Traefik Dashboard](https://docs.traefik.io/configuration/api/) Enabled
### Example With [Traefik Dashboard](https://docs.traefik.io/v1.7/configuration/api/) Enabled
This example launches a Traefik setvice in ECS using `FARGATE` with enabled dashboard and API endpoints.
Basic auth is enabled by default for both. You can use `openssl` to generate password for basic auth:
Expand All @@ -103,9 +110,9 @@ examples: |-
subnet_ids = ["XXXXXXXXXXX", "XXXXXXXXXXX", ..]
launch_type = "FARGATE"
assign_public_ip = "true"
assign_public_ip = true
dashboard_enabled = "true"
dashboard_enabled = true
dashboard_host = "traefik.example.com"
dashboard_basic_auth_user = "admin"
dashboard_basic_auth_password = "$$$apr1$$$Rj21EpGU$$$KCwTHCbAIVhw0BiSdU4Me0"
Expand Down Expand Up @@ -136,23 +143,23 @@ examples: |-
subnet_ids = ["XXXXXXXXXXX", "XXXXXXXXXXX", ..]
launch_type = "FARGATE"
assign_public_ip = "true"
assign_public_ip = true
dashboard_enabled = "true"
dashboard_enabled = true
dashboard_host = "traefik.example.com"
dashboard_basic_auth_user = "admin"
dashboard_basic_auth_password = "$$$apr1$$$Rj21EpGU$$$KCwTHCbAIVhw0BiSdU4Me0"
autoscaling_enabled = "true"
autoscaling_enabled = true
autoscaling_dimension = "cpu"
autoscaling_min_capacity = "1"
autoscaling_max_capacity = "3"
autoscaling_scale_up_cooldown = "60"
autoscaling_scale_down_cooldown = "60"
ecs_alarms_enabled = "true"
ecs_alarms_cpu_utilization_high_threshold = "20"
ecs_alarms_cpu_utilization_low_threshold = "10"
autoscaling_min_capacity = 1
autoscaling_max_capacity = 3
autoscaling_scale_up_cooldown = 60
autoscaling_scale_down_cooldown = 60
ecs_alarms_enabled = true
ecs_alarms_cpu_utilization_high_threshold = 20
ecs_alarms_cpu_utilization_low_threshold = 10
}
```
Expand Down
94 changes: 47 additions & 47 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,72 @@
|------|-------------|:----:|:-----:|:-----:|
| alb_security_group_id | ALB security group id. Traefik container will accept traefik from port 80 | string | - | yes |
| alb_target_group_arn | ALB security group id. Traefik container will accept traefik from port 80 | string | - | yes |
| api_port | Port at which Traefik will expose the API and Dashboard | string | `8080` | no |
| assign_public_ip | Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false. | string | `false` | no |
| attributes | Additional attributes, e.g. `1` | list | `<list>` | no |
| api_port | Port at which Traefik will expose the API and Dashboard | number | `8080` | no |
| assign_public_ip | Assign a public IP address to the ENI (Fargate launch type only). Valid values are true or false. Default false. | bool | `false` | no |
| attributes | Additional attributes, e.g. `1` | list(string) | `<list>` | no |
| autoscaling_dimension | Dimension to autoscale on (valid options: cpu, memory) | string | `memory` | no |
| autoscaling_enabled | A boolean to enable/disable Autoscaling policy for ECS Service | string | `false` | no |
| autoscaling_max_capacity | Maximum number of running instances of a Service | string | `2` | no |
| autoscaling_min_capacity | Minimum number of running instances of a Service | string | `1` | no |
| autoscaling_scale_down_adjustment | Scaling adjustment to make during scale down event | string | `-1` | no |
| autoscaling_scale_down_cooldown | Period (in seconds) to wait between scale down events | string | `300` | no |
| autoscaling_scale_up_adjustment | Scaling adjustment to make during scale up event | string | `1` | no |
| autoscaling_scale_up_cooldown | Period (in seconds) to wait between scale up events | string | `60` | no |
| autoscaling_enabled | A boolean to enable/disable Autoscaling policy for ECS Service | bool | `false` | no |
| autoscaling_max_capacity | Maximum number of running instances of a Service | number | `2` | no |
| autoscaling_min_capacity | Minimum number of running instances of a Service | number | `1` | no |
| autoscaling_scale_down_adjustment | Scaling adjustment to make during scale down event | number | `-1` | no |
| autoscaling_scale_down_cooldown | Period (in seconds) to wait between scale down events | number | `300` | no |
| autoscaling_scale_up_adjustment | Scaling adjustment to make during scale up event | number | `1` | no |
| autoscaling_scale_up_cooldown | Period (in seconds) to wait between scale up events | number | `60` | no |
| container_name | The name of the container in task definition to associate with the load balancer | string | `traefik` | no |
| dashboard_basic_auth_enabled | Defines whther basic auth is enabled for Traefik dashboard or not | string | `true` | no |
| dashboard_basic_auth_enabled | Defines whther basic auth is enabled for Traefik dashboard or not | bool | `true` | no |
| dashboard_basic_auth_password | Basic auth password for Traefik dashboard. If left empty, a random one will be generated. | string | `` | no |
| dashboard_basic_auth_user | Basic auth username for Traefik dashboard | string | `admin` | no |
| dashboard_enabled | Defines whether traefik dashboard is enabled | string | `false` | no |
| dashboard_enabled | Defines whether traefik dashboard is enabled | bool | `false` | no |
| dashboard_host | Traefik dashboard host at which API should be exposed | string | `dashboard.example.com` | no |
| delimiter | Delimiter to be used between `namespace`, `name`, `stage` and `attributes` | string | `-` | no |
| deployment_controller_type | Type of deployment controller. Valid values: `CODE_DEPLOY`, `ECS`. | string | `ECS` | no |
| deployment_maximum_percent | The upper limit of the number of tasks (as a percentage of `desired_count`) that can be running in a service during a deployment | string | `200` | no |
| deployment_minimum_healthy_percent | The lower limit (as a percentage of `desired_count`) of the number of tasks that must remain running and healthy in a service during a deployment | string | `100` | no |
| desired_count | The number of instances of the task definition to place and keep running | string | `1` | no |
| ecs_alarms_cpu_utilization_high_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High Alarm action | list | `<list>` | no |
| ecs_alarms_cpu_utilization_high_evaluation_periods | Number of periods to evaluate for the alarm | string | `1` | no |
| ecs_alarms_cpu_utilization_high_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High OK action | list | `<list>` | no |
| ecs_alarms_cpu_utilization_high_period | Duration in seconds to evaluate for the alarm | string | `300` | no |
| ecs_alarms_cpu_utilization_high_threshold | The maximum percentage of CPU utilization average | string | `80` | no |
| ecs_alarms_cpu_utilization_low_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low Alarm action | list | `<list>` | no |
| ecs_alarms_cpu_utilization_low_evaluation_periods | Number of periods to evaluate for the alarm | string | `1` | no |
| ecs_alarms_cpu_utilization_low_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low OK action | list | `<list>` | no |
| ecs_alarms_cpu_utilization_low_period | Duration in seconds to evaluate for the alarm | string | `300` | no |
| ecs_alarms_cpu_utilization_low_threshold | The minimum percentage of CPU utilization average | string | `20` | no |
| ecs_alarms_enabled | A boolean to enable/disable CloudWatch Alarms for ECS Service metrics | string | `false` | no |
| ecs_alarms_memory_utilization_high_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High Alarm action | list | `<list>` | no |
| ecs_alarms_memory_utilization_high_evaluation_periods | Number of periods to evaluate for the alarm | string | `1` | no |
| ecs_alarms_memory_utilization_high_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High OK action | list | `<list>` | no |
| ecs_alarms_memory_utilization_high_period | Duration in seconds to evaluate for the alarm | string | `300` | no |
| ecs_alarms_memory_utilization_high_threshold | The maximum percentage of Memory utilization average | string | `80` | no |
| ecs_alarms_memory_utilization_low_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low Alarm action | list | `<list>` | no |
| ecs_alarms_memory_utilization_low_evaluation_periods | Number of periods to evaluate for the alarm | string | `1` | no |
| ecs_alarms_memory_utilization_low_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low OK action | list | `<list>` | no |
| ecs_alarms_memory_utilization_low_period | Duration in seconds to evaluate for the alarm | string | `300` | no |
| ecs_alarms_memory_utilization_low_threshold | The minimum percentage of Memory utilization average | string | `20` | no |
| deployment_maximum_percent | The upper limit of the number of tasks (as a percentage of `desired_count`) that can be running in a service during a deployment | number | `200` | no |
| deployment_minimum_healthy_percent | The lower limit (as a percentage of `desired_count`) of the number of tasks that must remain running and healthy in a service during a deployment | number | `100` | no |
| desired_count | The number of instances of the task definition to place and keep running | number | `1` | no |
| ecs_alarms_cpu_utilization_high_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High Alarm action | list(string) | `<list>` | no |
| ecs_alarms_cpu_utilization_high_evaluation_periods | Number of periods to evaluate for the alarm | number | `1` | no |
| ecs_alarms_cpu_utilization_high_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization High OK action | list(string) | `<list>` | no |
| ecs_alarms_cpu_utilization_high_period | Duration in seconds to evaluate for the alarm | number | `300` | no |
| ecs_alarms_cpu_utilization_high_threshold | The maximum percentage of CPU utilization average | number | `80` | no |
| ecs_alarms_cpu_utilization_low_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low Alarm action | list(string) | `<list>` | no |
| ecs_alarms_cpu_utilization_low_evaluation_periods | Number of periods to evaluate for the alarm | number | `1` | no |
| ecs_alarms_cpu_utilization_low_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on CPU Utilization Low OK action | list(string) | `<list>` | no |
| ecs_alarms_cpu_utilization_low_period | Duration in seconds to evaluate for the alarm | number | `300` | no |
| ecs_alarms_cpu_utilization_low_threshold | The minimum percentage of CPU utilization average | number | `20` | no |
| ecs_alarms_enabled | A boolean to enable/disable CloudWatch Alarms for ECS Service metrics | bool | `false` | no |
| ecs_alarms_memory_utilization_high_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High Alarm action | list(string) | `<list>` | no |
| ecs_alarms_memory_utilization_high_evaluation_periods | Number of periods to evaluate for the alarm | number | `1` | no |
| ecs_alarms_memory_utilization_high_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization High OK action | list(string) | `<list>` | no |
| ecs_alarms_memory_utilization_high_period | Duration in seconds to evaluate for the alarm | number | `300` | no |
| ecs_alarms_memory_utilization_high_threshold | The maximum percentage of Memory utilization average | number | `80` | no |
| ecs_alarms_memory_utilization_low_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low Alarm action | list(string) | `<list>` | no |
| ecs_alarms_memory_utilization_low_evaluation_periods | Number of periods to evaluate for the alarm | number | `1` | no |
| ecs_alarms_memory_utilization_low_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to notify on Memory Utilization Low OK action | list(string) | `<list>` | no |
| ecs_alarms_memory_utilization_low_period | Duration in seconds to evaluate for the alarm | number | `300` | no |
| ecs_alarms_memory_utilization_low_threshold | The minimum percentage of Memory utilization average | number | `20` | no |
| ecs_cluster_arn | ECS cluster ARN | string | - | yes |
| ecs_cluster_name | ECS cluster name | string | - | yes |
| ecs_cluster_region | ECS cluster region | string | `us-east-1` | no |
| health_check_grace_period_seconds | Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 7200. Only valid for services configured to use load balancers | string | `10` | no |
| http_port | Port at which Traefik will accept traffic from ALB | string | `80` | no |
| ignore_changes_task_definition | Whether to ignore changes in container definition and task definition in the ECS service | string | `true` | no |
| http_port | Port at which Traefik will accept traffic from ALB | number | `80` | no |
| ignore_changes_task_definition | Whether to ignore changes in container definition and task definition in the ECS service | bool | `true` | no |
| launch_type | The launch type on which to run your service. Valid values are `EC2` and `FARGATE` | string | `FARGATE` | no |
| log_format | Traefk log format. See https://docs.traefik.io/configuration/logs/ | string | `common` | no |
| log_level | Traefk log level. See https://docs.traefik.io/configuration/logs/ | string | `INFO` | no |
| logs_region | AWS region for storing Cloudwatch logs from traefik container. Defaults to the same as ECS Cluster region. | string | `` | no |
| logs_retention | Defines retention period in days for Traefik logs in Cloudwatch | string | `30` | no |
| mount_points | Container mount points. This is a list of maps, where each map should contain a `containerPath` and `sourceVolume` | list | `<list>` | no |
| logs_retention | Defines retention period in days for Traefik logs in Cloudwatch | number | `30` | no |
| mount_points | Container mount points. This is a list of maps, where each map should contain a `containerPath` and `sourceVolume` | list(string) | `<list>` | no |
| name | Solution name, e.g. 'app' or 'jenkins' | string | `traefik` | no |
| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | `cp` | no |
| security_group_ids | Additional security group IDs to allow in Service `network_configuration` | list | `<list>` | no |
| security_group_ids | Additional security group IDs to allow in Service `network_configuration` | list(string) | `<list>` | no |
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | `prod` | no |
| subnet_ids | Subnet IDs | list | - | yes |
| tags | Additional tags (e.g. `map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |
| task_cpu | The vCPU setting to control cpu limits of traefik container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | string | `256` | no |
| subnet_ids | Subnet IDs | list(string) | - | yes |
| tags | Additional tags (e.g. `map(`BusinessUnit`,`XYZ`) | map(string) | `<map>` | no |
| task_cpu | The vCPU setting to control cpu limits of traefik container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | number | `256` | no |
| task_image | Traefik image | string | `library/traefik:1.7` | no |
| task_memory | The amount of RAM to allow traefik container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | string | `512` | no |
| task_memory_reservation | The amount of RAM (Soft Limit) to allow traefik container to use in MB. This value must be less than container_memory if set | string | `128` | no |
| volumes | Task volume definitions as list of maps | list | `<list>` | no |
| task_memory | The amount of RAM to allow traefik container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | number | `512` | no |
| task_memory_reservation | The amount of RAM (Soft Limit) to allow traefik container to use in MB. This value must be less than container_memory if set | number | `128` | no |
| volumes | Task volume definitions as list of maps | list(string) | `<list>` | no |
| vpc_id | Id of VPC in which Traefik service should be deployed | string | - | yes |

## Outputs
Expand Down
Loading

0 comments on commit fb5fe7a

Please sign in to comment.