If you have a github repository with Dockerfile, you can use this module to build an ECS that can be accessed from a custom domain. ย
Mainly works as follows:
- This module arranges CodePipeline using github as a hook and resources provisioned to it.
- The deployment destination of CodePipeline is Fargate in ECS.
- And ECS is linked to Load Balancer, enable access via its own domain.
You can publish the github source by customizing the four values.
- Application Name.
- Vpc and subnets to use.
- Port to Use(Internal and public).
- Github repository to use.
provider "aws" {
region = "ap-northeast-1"
}
locals {
# 1. Your app name.
application_name = "simple-go-ping-api"
application_name_lower = replace(lower(local.application_name), "/[^a-z0-9]/", "")
}
module "ecs-deployline" {
source = "ispec-inc/ecs-deployline/aws"
version = "0.4.3"
# 2. Your vpc and subnets id.
vpc_id = "vpc-0000000"
public_subnets = ["subnet-1112", "subnet-2222"]
cluster_name = local.application_name
app_repository_name = local.application_name
container_name = local.application_name
# 3. Port to use
alb_port = "8005"
container_port = "8005"
helth_check_path = "/ping"
# 4. Your github repository.
git_repository = {
owner = "murawakimitsuhiro"
name = "go-simple-RESTful-api"
branch = "feature/only-ping"
}
}
warning
- Dockerfile should be placed at the root of the git repository to be used, and be ready to build.
- In this simple sample, we do not link the domain or use SSL.
For a complete example, including a custom domain. see โ examples/api-server-ssl
Name | Description | Type | Default | Required |
---|---|---|---|---|
alb_port | origin application load balancer port | string |
n/a | yes |
app_repository_name | ecr repository name | string |
"" |
no |
build_args | docker build args. | map(string) |
{} |
no |
cluster_name | ecs cluster name | string |
"" |
no |
container_name | container app name | string |
"" |
no |
container_port | destination application load balancer port | string |
n/a | yes |
cpu_to_scale_down | cpu % to scale down the number of containers | number |
30 |
no |
cpu_to_scale_up | cpu % to scale up the number of containers | number |
80 |
no |
desired_task_cpu | desired cpu to run your tasks | string |
"256" |
no |
desired_task_memory | desired memory to run your tasks | string |
"512" |
no |
desired_tasks | number of containers desired to run app task | number |
2 |
no |
domain_name | domain name. (must be created in route53) | string |
"" |
no |
environment_variables | ecs task environment variables | map(string) |
{ |
no |
git_repository | git repository. It must contain the following key: owner, name, branch | map(string) |
n/a | yes |
helth_check_path | target group helth check path | string |
"/" |
no |
max_tasks | maximum | number |
4 |
no |
min_tasks | minimum | number |
2 |
no |
public_subnets | public subnet array (length>=2) | list(string) |
n/a | yes |
ssl_certificate_arn | ssl certification arn | string |
"" |
no |
vpc_id | vpc for provisioning resources | string |
n/a | yes |
Name | Description |
---|---|
alb_dns_name | DNS address linked to ALB. (automatically) |
alb_sg_id | ID of ALB security group. |
app_sg_id | ID of application security group. (ALB and ECS adapted) |
cloudwatch_log_group_arn | ARN of ecs cloudwatch log group. |
code_pipeline_artifact_s3_id | ID of s3 bucket for code pipeline artifact store. |
code_pipeline_id | ID of code pipeline. |
ecs-repository-url | URL of ECR with build artifacts. |
ecs_sg_id | ID of ECS security group. |
enable_custom_domain | Bool value of domain is valid or not. |
enable_ssl | Bool value of ssl is valid or not. |
vpc_id | vpc id. |
vpc_public_subnet_ids | List of IDs of VPC public subnets. |
Apache 2 Licensed. See LICENSE for full details.