Simple Terraform module to deploy an ECS task using AWS Fargate including addons (Load Balancer, ECR, CI credentials)
module "ecr" {
source = "tbobm/ecs/aws"
# version = "" use latest version
container = {
image = "particuleio/helloworld"
}
networking = {
vpc_id = "vpc-xxxxxxxx"
subnet_ids = ["subnet-xxxxxxxx"]
}
}Simply setup an ECS Cluster and Service based on container.image.
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
}
}
}module "ecr" {
source = "tbobm/ecs/aws"
# version = "" use latest version
ecs_values = {
ecs_task_arn = "arn:aws:ecs:<region>:<aws_account_id>:task-definition/<task_family>:1"
}
networking = {
vpc_id = "vpc-xxxxxxxx"
subnet_ids = ["subnet-xxxxxxxx"]
}
}Code formatting and documentation for variables and outputs is generated using pre-commit-terraform hooks which uses terraform-docs.
Follow these instructions to install pre-commit locally.
And install terraform-docs with go get github.com/segmentio/terraform-docs
or brew install terraform-docs.
Report issues/questions/feature requests on in the issues section.
| Name | Version |
|---|---|
| aws | ~> 3.0 |
| Name | Version |
|---|---|
| aws | ~> 3.0 |
No modules.
| Name | Type |
|---|---|
| aws_ecr_repository.this | resource |
| aws_ecr_repository_policy.this | resource |
| aws_ecs_cluster.this | resource |
| aws_ecs_service.this | resource |
| aws_ecs_task_definition.this | resource |
| aws_iam_access_key.publisher | resource |
| aws_iam_role.this | resource |
| aws_iam_role_policy.this | resource |
| aws_iam_user.publisher | resource |
| aws_iam_user_policy.publisher | resource |
| aws_lb.this | resource |
| aws_lb_listener.this | resource |
| aws_lb_target_group.this | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| addons | Configuration of each addon that can be toggles on and off | any |
{} |
no |
| aws_region | AWS region | string |
"eu-west-3" |
no |
| container | Container configuration to deploy | any |
{} |
no |
| ecr_values | AWS ECR configuration | any |
{} |
no |
| ecs_values | AWS ECS configuration | any |
{} |
no |
| lb_values | AWS Load Balancer configuration | any |
{} |
no |
| networking | AWS networking configuration (subnet_ids, vpc_id) | object({ |
n/a | yes |
| Name | Description |
|---|---|
| addons | The Addons configuration |
| app_url | The public ALB DNS |
| aws_region | The AWS region used |
| container_name | Container name for the ECS task |
| ecr_repository_name | The ECR repository name |
| ecr_url | The ECR repository URL |
| ecs_cluster | The ECS cluster name |
| ecs_service | The ECS service name |
| loadbalancer | The AWS Load Balancer resources (loadbalancer, target_group and lb_listener) |
| publisher_access_key | AWS_ACCESS_KEY to publish to ECR |
| publisher_secret_key | AWS_SECRET_ACCESS_KEY to upload to the ECR |