Skip to content

andcip/aws-ecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECS SERVICE

AWS ECS Service Module


This module deploy an ECS service, useful for Continuos Deployment

Example of invocation

## Required filed to use an existing cluster
existing_cluster_name = dependency.application.outputs.cluster.name

vpc_id                = dependency.networking.outputs.vpc.id


service_policies = [
{
  actions = [
    "s3:ListBucket",
    "s3:GetObject",
    "s3:GetObjectAcl",
    "s3:PutObject",
    "s3:PutObjectAcl",
    "s3:ReplicateObject",
    "s3:DeleteObject"
  ]
  resources = [
    dependency.application.outputs.cms_assets_bucket.arn,
    "${dependency.application.outputs.cms_assets_bucket.arn}/*"
  ]
},
{
  actions = [
    "ses:SendEmail",
    "ses:SendRawEmail"
  ]
  resources = ["*"]
}
]

## Trigger input that specify service trigger, supported only ALB right now
trigger = {

lb : {
  name : dependency.application.outputs.alb.name
  rules : [
    {
      path_patterns = ["/*"]
      hosts = ["cms.assistdigital.it"]
    }
  ]
}
}

healthcheck = {
  port = 8055
  path : "/server/ping"
  ecs_enabled : false
}

service = {
name              = "cms"
version           = get_env("IMAGE_VERSION", "null")
port              = 8055
capacity_provider = [
  {
    provider = "FARGATE_SPOT"
    base     = 1
    weight   = 1
  },
  {
    provider = "FARGATE"
    base = 0
    weight = 1
  }
]


Variable Documentation

Requirements

No requirements.

Providers

Name Version
aws 4.0.0

Modules

No modules.

Resources

Name Type
aws_appautoscaling_policy.cpu_scale_policy resource
aws_appautoscaling_policy.memory_scale_policy resource
aws_appautoscaling_scheduled_action.turn_off_scheduled_action resource
aws_appautoscaling_scheduled_action.turn_on_scheduled_action resource
aws_appautoscaling_target.ecs_target resource
aws_cloudwatch_log_group.service_log_group resource
aws_cloudwatch_log_group.task_log_group resource
aws_cloudwatch_metric_alarm.service-alarm resource
aws_ecs_service.service resource
aws_ecs_task_definition.service_task_definition resource
aws_iam_role.service_autoscaling_role resource
aws_iam_role.task_execution_role resource
aws_iam_role.task_role resource
aws_iam_role_policy.function_policy resource
aws_iam_role_policy.task_role_policy resource
aws_iam_role_policy_attachment.service_autoscaling_role_policy_attach resource
aws_iam_role_policy_attachment.task_execution_role_attach resource
aws_lb_listener_rule.service resource
aws_lb_target_group.service_tg resource
aws_security_group.service_sg resource
aws_service_discovery_service.ecs_discovery_service resource
aws_ecr_repository.service_repository data source
aws_iam_policy.aws_service_autoscale_role data source
aws_iam_policy.task_execution_role_policy data source
aws_lb.lb_trigger data source
aws_lb_listener.lb_listener data source
aws_region.current data source
aws_service_discovery_dns_namespace.service_registry data source
aws_sns_topic.system-alarm data source
aws_subnets.subnets data source
aws_vpc.vpc data source

Inputs

Name Description Type Default Required
alarm_topic_name If specified, it enable error alarms to a specific sns topic. Default null. string null no
existing_cluster_name The existing ECS Cluster name. string n/a yes
healthcheck Service Healthcheck configuration. Default to root path on port 80 only from alb if present.
object({
port : number
path : string
ecs_enabled : bool
})
{
"ecs_enabled": false,
"path": "/",
"port": 80
}
no
service The service configuration parameters.
object({
name : string
version : string
port : number
capacity_provider : optional(list(object({
provider : string
weight : number
base : optional(number)
})))
env : map(string)
})
n/a yes
service_autoscaling Service autoscaling parameters with cpu, memory or schedule metrics. Default disabled
object({
max_instance_number = number
scale_on_cpu = bool
scale_on_memory = bool
scale_on_schedule = bool
stop_schedule = string
start_schedule = string
cpu_threshold = number
memory_threshold = number
scale_out_cooldown = number
scale_in_cooldown = number
})
{
"cpu_threshold": 60,
"max_instance_number": 1,
"memory_threshold": 80,
"scale_in_cooldown": 180,
"scale_on_cpu": false,
"scale_on_memory": false,
"scale_on_schedule": false,
"scale_out_cooldown": 60,
"start_schedule": "cron(0 8 * * ? *)",
"stop_schedule": "cron(0 20 * * ? *)"
}
no
service_params Service deployment parameters. Default 512 cpu, 1024 memory and 1 private instance.
object({
cpu = number,
memory = number,
desired_count = number,
is_public = bool
})
{
"cpu": 512,
"desired_count": 1,
"is_public": false,
"memory": 1024
}
no
service_policies List of all iam policy to attach to the service. Default empty.
list(object({
actions = list(string)
resources = list(string)
}))
[] no
service_registry_name Service registry name. If specified, it creates a private DNS for the service. string null no
trigger The Service trigger, supported only alb right now. Default null.
object({
lb : object({
name : string,
rules : list(object({
path_patterns : list(string)
hosts : optional(list(string))
http_headers : optional(list(map(string)))
http_methods : optional(list(string))
source_ips : optional(list(string))
query_string : optional(string)
}))
})
})
null no
vpc_id Id of the VPC where ecs have to be. string n/a yes

Outputs

Name Description
ecs_service n/a

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages