Skip to content

Commit

Permalink
Update var and examples (#15)
Browse files Browse the repository at this point in the history
* Remove unused vars. Update README with examples and descriptions. Add example

* Remove unused vars. Update README with examples and descriptions. Add example

* Update README

* Address PR comments
  • Loading branch information
aknysh authored Oct 5, 2018
1 parent f2e354a commit 23f7a7a
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 98 deletions.
125 changes: 96 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->


[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)

# terraform-aws-ecs-alb-service-task [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-ecs-alb-service-task.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-ecs-alb-service-task) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-ecs-alb-service-task.svg)](https://github.com/cloudposse/terraform-aws-ecs-alb-service-task/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
Expand All @@ -26,16 +27,63 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE).

## Usage


For a complete example, see [examples/complete](examples/complete)

```hcl
module "ecs_alb_service_task" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.2.0"
name = "app"
module "label" {
source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=master"
namespace = "eg"
stage = "staging"
name = "app"
}
module "container_definition" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=master"
container_name = "app"
container_image = "cloudposse/geodesic:latest"
environment = [
{
name = "string_var"
value = "I am a string"
},
{
name = "true_boolean_var"
value = true
},
{
name = "false_boolean_var"
value = false
},
{
name = "integer_var"
value = 42
},
]
port_mappings = [
{
containerPort = 8080
hostPort = 80
protocol = "tcp"
},
{
containerPort = 8081
hostPort = 443
protocol = "udp"
},
]
}
module "alb_service_task" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=master"
namespace = "eg"
stage = "staging"
name = "app"
alb_target_group_arn = "xxxxxxx"
container_definition_json = "${module.container_definition.json}"
container_name = "${module.default_label.id}"
ecr_repository_name = "${module.ecr.repository_name}"
container_name = "${module.label.id}"
ecs_cluster_arn = "xxxxxxx"
launch_type = "FARGATE"
vpc_id = "xxxxxxx"
Expand All @@ -44,6 +92,27 @@ module "ecs_alb_service_task" {
}
```

The `container_image` in the `container_definition` module is the Docker image used to start a container.

This string is passed directly to the Docker daemon. Images in the Docker Hub registry are available by default.
Other repositories are specified with either `repository-url/image:tag` or `repository-url/image@digest`.
Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed.
This parameter maps to Image in the Create a container section of the Docker Remote API and the IMAGE parameter of `docker run`.

When a new task starts, the Amazon ECS container agent pulls the latest version of the specified image and tag for the container to use.
However, subsequent updates to a repository image are not propagated to already running tasks.

Images in Amazon ECR repositories can be specified by either using the full `registry/repository:tag` or `registry/repository@digest`.
For example, `012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:latest` or `012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>@sha256:94afd1f2e64d908bc90dbca0035a5b567EXAMPLE`.

Images in official repositories on Docker Hub use a single name (for example, `ubuntu` or `mongo`).

Images in other repositories on Docker Hub are qualified with an organization name (for example, `amazon/amazon-ecs-agent`).

Images in other online repositories are qualified further by a domain name (for example, `quay.io/assemblyline/ubuntu`).

For more info, see [Container Definition](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html).




Expand All @@ -63,37 +132,35 @@ Available targets:

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| alb_target_group_arn | The ALB target group ARN for the ECS service. | string | - | yes |
| attributes | List of attributes to add to label. | list | `<list>` | no |
| container_definition_json | The JSON of the task container definition. | string | - | yes |
| container_name | The name of the container in task definition to associate with the load balancer. | string | - | yes |
| container_port | The port on the container to associate with the load balancer. | string | `80` | no |
| delimiter | The delimiter to be used in labels. | string | `-` | 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 |
| ecr_repository_name | The name of the ECR repository to store images. | string | - | yes |
| ecs_cluster_arn | The ARN of the ECS cluster where service will be provisioned. | string | - | yes |
| family | The name used for multiple versions of a task definition. | string | `web` | no |
| launch_type | The launch type on which to run your service. Valid values are EC2 and FARGATE. | string | `FARGATE` | no |
| name | The name of the app to be used in labels. | string | - | yes |
| namespace | The namespace to be used in labels. | string | - | yes |
| network_mode | The network mode to use for the task. This is required to be awsvpc for FARGATE launch_type. | string | `awsvpc` | no |
| private_subnet_ids | Private subnet IDs. | list | - | yes |
| security_group_ids | Security group IDs to allow in Service network_configuration. | list | - | yes |
| stage | Stage to be used in labels. | string | - | yes |
| tags | Map of key-value pairs to use for tags. | map | `<map>` | no |
| task_cpu | The number of CPU units used by the task. If using Fargate launch type task_cpu must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size). | string | `256` | no |
| task_memory | The amount of memory (in MiB) used by the task. If using Fargate launch type task_memory must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size). | string | `512` | no |
| vpc_id | The VPC ID where resources are created. | string | - | yes |
| alb_target_group_arn | The ALB target group ARN for the ECS service | string | - | yes |
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
| container_definition_json | The JSON of the task container definition | string | - | yes |
| container_name | The name of the container in task definition to associate with the load balancer | string | - | yes |
| container_port | The port on the container to associate with the load balancer | string | `80` | no |
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | 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_cluster_arn | The ARN of the ECS cluster where service will be provisioned | string | - | yes |
| launch_type | The launch type on which to run your service. Valid values are EC2 and FARGATE | string | `FARGATE` | 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 |
| network_mode | The network mode to use for the task. This is required to be awsvpc for FARGATE `launch_type` | string | `awsvpc` | no |
| private_subnet_ids | Private subnet IDs | list | - | yes |
| security_group_ids | Security group IDs to allow in Service network_configuration | list | - | 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. If using Fargate launch type `task_cpu` must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `256` | no |
| task_memory | The amount of memory (in MiB) used by the task. If using Fargate launch type `task_memory` must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `512` | no |
| vpc_id | The VPC ID where resources are created | string | - | yes |

## Outputs

| Name | Description |
|------|-------------|
| service_name | ECS Service name |
| service_role_arn | ECS Service role ARN |
| service_security_group_id | Security Group id of the ECS task |
| service_security_group_id | Security Group ID of the ECS task |
| task_role_arn | ECS Task role ARN |


Expand Down
79 changes: 74 additions & 5 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,63 @@ description: |-
# How to use this project
usage: |-
For a complete example, see [examples/complete](examples/complete)
```hcl
module "ecs_alb_service_task" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.2.0"
name = "app"
module "label" {
source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=master"
namespace = "eg"
stage = "staging"
name = "app"
}
module "container_definition" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=master"
container_name = "app"
container_image = "cloudposse/geodesic:latest"
environment = [
{
name = "string_var"
value = "I am a string"
},
{
name = "true_boolean_var"
value = true
},
{
name = "false_boolean_var"
value = false
},
{
name = "integer_var"
value = 42
},
]
port_mappings = [
{
containerPort = 8080
hostPort = 80
protocol = "tcp"
},
{
containerPort = 8081
hostPort = 443
protocol = "udp"
},
]
}
module "alb_service_task" {
source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=master"
namespace = "eg"
stage = "staging"
name = "app"
alb_target_group_arn = "xxxxxxx"
container_definition_json = "${module.container_definition.json}"
container_name = "${module.default_label.id}"
ecr_repository_name = "${module.ecr.repository_name}"
container_name = "${module.label.id}"
ecs_cluster_arn = "xxxxxxx"
launch_type = "FARGATE"
vpc_id = "xxxxxxx"
Expand All @@ -81,6 +128,28 @@ usage: |-
}
```
The `container_image` in the `container_definition` module is the Docker image used to start a container.
This string is passed directly to the Docker daemon. Images in the Docker Hub registry are available by default.
Other repositories are specified with either `repository-url/image:tag` or `repository-url/image@digest`.
Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed.
This parameter maps to Image in the Create a container section of the Docker Remote API and the IMAGE parameter of `docker run`.
When a new task starts, the Amazon ECS container agent pulls the latest version of the specified image and tag for the container to use.
However, subsequent updates to a repository image are not propagated to already running tasks.
Images in Amazon ECR repositories can be specified by either using the full `registry/repository:tag` or `registry/repository@digest`.
For example, `012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:latest` or `012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>@sha256:94afd1f2e64d908bc90dbca0035a5b567EXAMPLE`.
Images in official repositories on Docker Hub use a single name (for example, `ubuntu` or `mongo`).
Images in other repositories on Docker Hub are qualified with an organization name (for example, `amazon/amazon-ecs-agent`).
Images in other online repositories are qualified further by a domain name (for example, `quay.io/assemblyline/ubuntu`).
For more info, see [Container Definition](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html).
# Other files to include in this README from the project folder
include:
- "docs/targets.md"
Expand Down
46 changes: 22 additions & 24 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| alb_target_group_arn | The ALB target group ARN for the ECS service. | string | - | yes |
| attributes | List of attributes to add to label. | list | `<list>` | no |
| container_definition_json | The JSON of the task container definition. | string | - | yes |
| container_name | The name of the container in task definition to associate with the load balancer. | string | - | yes |
| container_port | The port on the container to associate with the load balancer. | string | `80` | no |
| delimiter | The delimiter to be used in labels. | string | `-` | 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 |
| ecr_repository_name | The name of the ECR repository to store images. | string | - | yes |
| ecs_cluster_arn | The ARN of the ECS cluster where service will be provisioned. | string | - | yes |
| family | The name used for multiple versions of a task definition. | string | `web` | no |
| launch_type | The launch type on which to run your service. Valid values are EC2 and FARGATE. | string | `FARGATE` | no |
| name | The name of the app to be used in labels. | string | - | yes |
| namespace | The namespace to be used in labels. | string | - | yes |
| network_mode | The network mode to use for the task. This is required to be awsvpc for FARGATE launch_type. | string | `awsvpc` | no |
| private_subnet_ids | Private subnet IDs. | list | - | yes |
| security_group_ids | Security group IDs to allow in Service network_configuration. | list | - | yes |
| stage | Stage to be used in labels. | string | - | yes |
| tags | Map of key-value pairs to use for tags. | map | `<map>` | no |
| task_cpu | The number of CPU units used by the task. If using Fargate launch type task_cpu must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size). | string | `256` | no |
| task_memory | The amount of memory (in MiB) used by the task. If using Fargate launch type task_memory must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size). | string | `512` | no |
| vpc_id | The VPC ID where resources are created. | string | - | yes |
| alb_target_group_arn | The ALB target group ARN for the ECS service | string | - | yes |
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
| container_definition_json | The JSON of the task container definition | string | - | yes |
| container_name | The name of the container in task definition to associate with the load balancer | string | - | yes |
| container_port | The port on the container to associate with the load balancer | string | `80` | no |
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | 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_cluster_arn | The ARN of the ECS cluster where service will be provisioned | string | - | yes |
| launch_type | The launch type on which to run your service. Valid values are EC2 and FARGATE | string | `FARGATE` | 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 |
| network_mode | The network mode to use for the task. This is required to be awsvpc for FARGATE `launch_type` | string | `awsvpc` | no |
| private_subnet_ids | Private subnet IDs | list | - | yes |
| security_group_ids | Security group IDs to allow in Service network_configuration | list | - | 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. If using Fargate launch type `task_cpu` must match supported memory values (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `256` | no |
| task_memory | The amount of memory (in MiB) used by the task. If using Fargate launch type `task_memory` must match supported cpu value (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) | string | `512` | no |
| vpc_id | The VPC ID where resources are created | string | - | yes |

## Outputs

| Name | Description |
|------|-------------|
| service_name | ECS Service name |
| service_role_arn | ECS Service role ARN |
| service_security_group_id | Security Group id of the ECS task |
| service_security_group_id | Security Group ID of the ECS task |
| task_role_arn | ECS Task role ARN |

Loading

0 comments on commit 23f7a7a

Please sign in to comment.