An open API service indexing awesome lists of open source software.

https://github.com/tbobm/terraform-aws-ecs

Terraform module to deploy ECS tasks with addons. Bootstrap an ECS service exposed with an Application Load Balancer, ECR, simple IAM Policy and generate CI credentials.
https://github.com/tbobm/terraform-aws-ecs

aws cloud containers ecr ecs fargate iac terraform terraform-module terraform-modules

Last synced: 5 months ago
JSON representation

Terraform module to deploy ECS tasks with addons. Bootstrap an ECS service exposed with an Application Load Balancer, ECR, simple IAM Policy and generate CI credentials.

Awesome Lists containing this project

README

          

# Terraform ECS Module

[![terraform-aws-ecs](https://github.com/tbobm/terraform-aws-ecs/actions/workflows/terraform.yml/badge.svg)](https://github.com/tbobm/terraform-aws-ecs/actions/workflows/terraform.yml)

Simple Terraform module to deploy an ECS task using AWS Fargate including addons (Load Balancer, ECR, CI credentials)

## Example usage

### Bootstrapped setup

```hcl
module "ecr" {
source = "tbobm/ecs/aws"
# version = "" use latest version

container = {
image = "particuleio/helloworld"
}

networking = {
vpc_id = "vpc-xxxxxxxx"
subnet_ids = ["subnet-xxxxxxxx"]
}
}
```

### Restricted setup

Simply setup an ECS Cluster and Service based on `container.image`.

```hcl
module "ecr" {
source = "tbobm/ecs/aws"
# version = "" use latest version

container = {
image = "particuleio/helloworld"
}

networking = {
vpc_id = "vpc-xxxxxxxx"
subnet_ids = ["subnet-xxxxxxxx"]
}
addons = {
iam = {
enable = false
}
ecr = {
enable = false
}
loadbalancer = {
enable = false
}
}
}
```

### Use an external ECS Task definition

```hcl
module "ecr" {
source = "tbobm/ecs/aws"
# version = "" use latest version

ecs_values = {
ecs_task_arn = "arn:aws:ecs:::task-definition/:1"
}
networking = {
vpc_id = "vpc-xxxxxxxx"
subnet_ids = ["subnet-xxxxxxxx"]
}
}
```

## Doc generation

Code formatting and documentation for variables and outputs is generated using
[pre-commit-terraform
hooks](https://github.com/antonbabenko/pre-commit-terraform) which uses
[terraform-docs](https://github.com/segmentio/terraform-docs).

Follow [these
instructions](https://github.com/antonbabenko/pre-commit-terraform#how-to-install)
to install pre-commit locally.

And install `terraform-docs` with `go get github.com/segmentio/terraform-docs`
or `brew install terraform-docs`.

## Contributing

Report issues/questions/feature requests on in the
[issues](https://github.com/particuleio/terraform-kubernetes-addons/issues/new)
section.

## Requirements

| Name | Version |
|------|---------|
| [aws](#requirement\_aws) | ~> 3.0 |

## Providers

| Name | Version |
|------|---------|
| [aws](#provider\_aws) | ~> 3.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_ecr_repository.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository) | resource |
| [aws_ecr_repository_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository_policy) | resource |
| [aws_ecs_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster) | resource |
| [aws_ecs_service.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service) | resource |
| [aws_ecs_task_definition.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition) | resource |
| [aws_iam_access_key.publisher](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource |
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
| [aws_iam_user.publisher](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource |
| [aws_iam_user_policy.publisher](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy) | resource |
| [aws_lb.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb) | resource |
| [aws_lb_listener.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener) | resource |
| [aws_lb_target_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [addons](#input\_addons) | Configuration of each addon that can be toggles on and off | `any` | `{}` | no |
| [aws\_region](#input\_aws\_region) | AWS region | `string` | `"eu-west-3"` | no |
| [container](#input\_container) | Container configuration to deploy | `any` | `{}` | no |
| [ecr\_values](#input\_ecr\_values) | AWS ECR configuration | `any` | `{}` | no |
| [ecs\_values](#input\_ecs\_values) | AWS ECS configuration | `any` | `{}` | no |
| [lb\_values](#input\_lb\_values) | AWS Load Balancer configuration | `any` | `{}` | no |
| [networking](#input\_networking) | AWS networking configuration (subnet\_ids, vpc\_id) |

object({
vpc_id = string
subnet_ids = list(string)
})
| n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| [addons](#output\_addons) | The Addons configuration |
| [app\_url](#output\_app\_url) | The public ALB DNS |
| [aws\_region](#output\_aws\_region) | The AWS region used |
| [container\_name](#output\_container\_name) | Container name for the ECS task |
| [ecr\_repository\_name](#output\_ecr\_repository\_name) | The ECR repository name |
| [ecr\_url](#output\_ecr\_url) | The ECR repository URL |
| [ecs\_cluster](#output\_ecs\_cluster) | The ECS cluster name |
| [ecs\_service](#output\_ecs\_service) | The ECS service name |
| [loadbalancer](#output\_loadbalancer) | The AWS Load Balancer resources (`loadbalancer`, `target_group` and `lb_listener`) |
| [publisher\_access\_key](#output\_publisher\_access\_key) | AWS\_ACCESS\_KEY to publish to ECR |
| [publisher\_secret\_key](#output\_publisher\_secret\_key) | AWS\_SECRET\_ACCESS\_KEY to upload to the ECR |