Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/npalm/terraform-aws-ecs-service
Terraform module to create ECS / FARGATE services
https://github.com/npalm/terraform-aws-ecs-service
Last synced: 29 days ago
JSON representation
Terraform module to create ECS / FARGATE services
- Host: GitHub
- URL: https://github.com/npalm/terraform-aws-ecs-service
- Owner: npalm
- License: mit
- Created: 2018-01-26T14:16:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-07T13:18:33.000Z (over 3 years ago)
- Last Synced: 2024-10-04T12:46:55.622Z (about 2 months ago)
- Language: HCL
- Size: 29.3 KB
- Stars: 31
- Watchers: 5
- Forks: 36
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS Terraform module to create Fargate / ECS service
This modules creates a Fargate or ECS service optionally with a application load balancer.
- Supports network modes: "awsvpc" and "bridge"
- Supports ECS and FARGATE
- Optionally a ALB can be created. (HTTP or HTTPS)## Example usages:
Below an example for deloy a service to Fargate. See the test directroy for more and complete examples.All variables prefix with:
- `awsvpc` : should only be required in case of network mode awsvpc (FARGATE as well).
- `lb` : should only be required in case enable_lb is set to true.```
resource "aws_security_group" "awsvpc_sg" {
name = "${var.environment}-awsvpc-cluster-sg"
vpc_id = "${module.vpc.vpc_id}"ingress {
protocol = "tcp"
from_port = 0
to_port = 65535cidr_blocks = [
"${module.vpc.vpc_cidr}",
]
}egress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}tags {
Name = "${var.environment}-ecs-cluster-sg"
Environment = "${var.environment}"
}
}locals {
container_name = "blog"
container_port = "80"
}data "template_file" "blog" {
template = <` | no |
| awsvpc_service_subnetids | List of subnet ids to which a service is deployed in fargate mode. | string | `` | no |
| awsvpc_task_execution_role_arn | The role arn used for task execution. Required for network mode awsvpc. | string | `` | no |
| ecs_cluster_id | The id of the ECS cluster | string | - | yes |
| ecs_service_role | | string | `` | no |
| enable_alb | Enable or disable the load balancer. | string | `true` | no |
| environment | Logical name of the environment, will be used as prefix and in tags. | string | - | yes |
| lb_health_check | A health check block for the load balancer, see https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_CreateTargetGroup.html more for details. | list | `` | no |
| lb_internal | Indicates if the load balancer should be internal or external. | string | `true` | no |
| lb_listener | The listner for the load balancer, SSL in only applied once a certificate arn is provided. | map | `` | no |
| lb_subnetids | List of subnets to which the load balancer needs to be attached. Mandatory when enable_alb = true. | list | `` | no |
| lb_target_group | The target group to connectect the container to the load balancer listerner. | map | `` | no |
| lb_security_group_ids | Custom Load Balancer security group ids | list | `[]` | no |
| lb_health_check_grace_period_seconds | Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 2147483647 | string | `0` | no |
| service_desired_count | The number of instances of the task definition to place and keep running. | string | `1` | no |
| service_launch_type | The launch type, can be EC2 or FARGATE. | string | `EC2` | no |
| service_name | Logical name of the service. | string | - | yes |
| task_cpu | CPU value for the task, required for FARGATE. | string | `` | no |
| task_definition | The AWS task definition of the containers to be created. | string | - | yes |
| task_memory | Memory value for the task, required for FARGATE. | string | `` | no |
| task_network_mode | The network mode to be used in the task definiton. Supported modes are awsvpc and bridge. | string | `awsvpc` | no |
| task_role_arn | The AWS IAM role that will be provided to the task to perform AWS actions. | string | `` | no |
| task_volumes | List of volume blocks for task definition | list | `[]` | no |
| vpc_cidr | CIDR for the VPC. | string | - | yes |
| vpc_id | ID of the VPC. | string | - | yes |
| public_alb_whitelist | Whitelists IP to be able to access ALB | list | ["0.0.0.0/0","::/0"] | no |## Outputs
| Name | Description |
|------|-------------|
| service_url | Service urls. |
| lb_dns_name | Load Balancer DNS Name. |
| task_definition_arn | Task definition ARN. |
| lb_target_group_arn | Load Balancer Target Group ARN. |
| lb_arn | Load Balancer ARN. |
| lb_listener_arn | Load Balancer Listener ARN. |
| lb_security_group_id | Load Balancer Security Group ID. |