{"id":26010017,"url":"https://github.com/byu-oit/terraform-aws-fargate-api","last_synced_at":"2025-03-05T22:26:52.453Z","repository":{"id":38443373,"uuid":"258340886","full_name":"byu-oit/terraform-aws-fargate-api","owner":"byu-oit","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-18T19:35:49.000Z","size":316,"stargazers_count":1,"open_issues_count":1,"forks_count":5,"subscribers_count":20,"default_branch":"main","last_synced_at":"2024-04-14T06:10:01.479Z","etag":null,"topics":["standard","terraform-module"],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byu-oit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-04-23T22:00:52.000Z","updated_at":"2022-06-03T17:21:28.000Z","dependencies_parsed_at":"2024-03-18T20:23:33.040Z","dependency_job_id":null,"html_url":"https://github.com/byu-oit/terraform-aws-fargate-api","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-fargate-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-fargate-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-fargate-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-fargate-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byu-oit","download_url":"https://codeload.github.com/byu-oit/terraform-aws-fargate-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242112780,"owners_count":20073669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["standard","terraform-module"],"created_at":"2025-03-05T22:26:51.971Z","updated_at":"2025-03-05T22:26:52.436Z","avatar_url":"https://github.com/byu-oit.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Latest GitHub Release](https://img.shields.io/github/v/release/byu-oit/terraform-aws-fargate-api?sort=semver)\n\n# Terraform AWS Fargate API\n\nTerraform module pattern to build a standard Fargate API.\n\nThis module creates a Fargate service with an ALB, AutoScaling, CodeDeploy configuration and a DNS record in front.\n\n**Note:** This module has many preset standards to make creating an API using Fargate easy. If you require a more\ncustomized solution you may need to use this code more as a pattern or guideline in how to build the resources you need.\n\n## Usage\n\n```hcl\nmodule \"my_app\" {\n  source                       = \"github.com/byu-oit/terraform-aws-fargate-api?ref=v6.2.0\"\n  app_name                     = \"example-api\"\n  container_port               = 8000\n  primary_container_definition = {\n    name                  = \"example\"\n    image                 = \"crccheck/hello-world\"\n    ports                 = [8000]\n    environment_variables = null\n    secrets               = null\n    efs_volume_mounts     = null\n    ulimits               = null\n  }\n\n  autoscaling_config            = null\n  codedeploy_test_listener_port = 8443\n  codedeploy_lifecycle_hooks    = {\n    BeforeInstall         = null\n    AfterInstall          = null\n    AfterAllowTestTraffic = \"testLifecycle\"\n    BeforeAllowTraffic    = null\n    AfterAllowTraffic     = null\n  }\n\n  hosted_zone                   = module.acs.route53_zone\n  https_certificate_arn         = module.acs.certificate.arn\n  public_subnet_ids             = module.acs.public_subnet_ids\n  private_subnet_ids            = module.acs.private_subnet_ids\n  vpc_id                        = module.acs.vpc.id\n  codedeploy_service_role_arn   = module.acs.power_builder_role.arn\n  role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn\n\n  tags = {\n    env              = \"dev\"\n    data-sensitivity = \"internal\"\n    repo             = \"https://github.com/byu-oit/terraform-aws-fargate-api\"\n  }\n}\n```\n\u003e **Note**\n\u003e * If your application's `site_url` is a subdomain within your AWS account's default hosted zone, you must input both the default `hosted_zone` and `https_certificate_arn` from the [terraform-aws-acs-info module's](https://github.com/byu-oit/terraform-aws-acs-info) output. This is shown in the example above.\n\u003e * If your application requires a custom `site_url` outside of your AWS account's default hosted zone, input your custom `hosted_zone` and do not input `https_certificate_arn`. The module will create an ACM certificate for your custom domain.\n\n## Created Resources\n\n* ECS Cluster (if not provided)\n* ECS Service\n    * with security group\n* ECS Task Definition\n    * with IAM role\n* CloudWatch Log Group\n* ALB\n    * with security group\n* 2 Target Groups (for blue-green deployment)\n* CodeDeploy App\n    * with IAM role\n* CodeDeploy Group\n* DNS A-Record\n* HTTPS Certificate (if not provided)\n  * with DNS validation record\n* AutoScaling Target\n* AutoScaling Policies (one for stepping up and one for stepping down)\n* CloudWatch Metric Alarms (one for stepping up and one for stepping down)\n\n## Requirements\n\n* Terraform version 1.3.0 or greater\n\n## Inputs\n\n| Name                              | Type                                        | Description                                                                                                                                                                                                                                                                                                                                                                                          | Default                                                                                |\n|-----------------------------------|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| app_name                          | string                                      | Application name to name your Fargate API and other resources (Must be \u003c= 24 alphanumeric characters)                                                                                                                                                                                                                                                                                                |                                                                                        |\n| primary_container_definition      | [object](#container_definition)             | The primary container definition for your application. This one will be the only container that receives traffic from the ALB, so make sure the `ports` field contains the same port as the `image_port`                                                                                                                                                                                             |                                                                                        |\n| extra_container_definitions       | list([object](#container_definition))       | A list of extra container definitions (side car containers)                                                                                                                                                                                                                                                                                                                                          | []                                                                                     |\n| existing_ecs_cluster              | [object](#existing_ecs_cluster)             | Existing ECS Cluster configuration to host the fargate server. Defaults to creating its own cluster.\t                                                                                                                                                                                                                                                                                                | \u003capp_name\u003e                                                                             |\n| container_port                    | number                                      | The port the primary docker container is listening on                                                                                                                                                                                                                                                                                                                                                |                                                                                        |\n| health_check_path                 | string                                      | Health check path for the image                                                                                                                                                                                                                                                                                                                                                                      | \"/\"                                                                                    |\n| health_check_matcher              | string                                      | Expected status code for health check. [See docs for syntax](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html)                                                                                                                                                                                                                                    | 200                                                                                    | \n| health_check_interval             | number                                      | Amount of time, in seconds, between health checks of an individual target                                                                                                                                                                                                                                                                                                                            | 30                                                                                     |\n| health_check_timeout              | number                                      | Amount of time, in seconds, during which no response means a failed health check                                                                                                                                                                                                                                                                                                                     | 5                                                                                      |\n| health_check_healthy_threshold    | number                                      | Number of consecutive health checks required before considering target as healthy                                                                                                                                                                                                                                                                                                                    | 3                                                                                      |\n| health_check_unhealthy_threshold  | number                                      | Number of consecutive failed health checks required before considering target as unhealthy                                                                                                                                                                                                                                                                                                           | 3                                                                                      |\n| health_check_grace_period         | number                                      | Health check grace period in seconds                                                                                                                                                                                                                                                                                                                                                                 | 0                                                                                      |\n| task_policies                     | list(string)                                | List of IAM Policy ARNs to attach to the task execution IAM Policy                                                                                                                                                                                                                                                                                                                                   | []                                                                                     |\n| task_cpu                          | number                                      | CPU for the task definition                                                                                                                                                                                                                                                                                                                                                                          | 256                                                                                    |\n| task_memory                       | number                                      | Memory for the task definition                                                                                                                                                                                                                                                                                                                                                                       | 512                                                                                    |\n| cpu_architecture                  | string                                      | CPU architecture for the task definition. [See docs for options](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#runtime-platform)                                                                                                                                                                                                                       | \"X86_64\"                                                                               |\n| security_groups                   | list(string)                                | List of extra security group IDs to attach to the fargate task                                                                                                                                                                                                                                                                                                                                       | []                                                                                     |\n| vpc_id                            | string                                      | VPC ID to deploy the ECS fargate service and ALB                                                                                                                                                                                                                                                                                                                                                     |                                                                                        |\n| public_subnet_ids                 | list(string)                                | List of subnet IDs for the ALB                                                                                                                                                                                                                                                                                                                                                                       |                                                                                        |\n| alb_internal_flag                 | bool                                        | Marks an ALB as Internal (Inaccessible to public internet)                                                                                                                                                                                                                                                                                                                                           | false                                                                                  |\n| alb_sg_ingress_cidrs              | list(string)                                | List of cidrs to allow alb ingress for                                                                                                                                                                                                                                                                                                                                                               | [\"0.0.0.0/0\"]                                                                          |\n| alb_sg_ingress_sg_ids             | list(string)                                | List of security groups to allow ingress                                                                                                                                                                                                                                                                                                                                                             | []                                                                                     |\n| alb_idle_timeout                  | number                                      | The time in seconds that the connection is allowed to be idle. Defaults to 60 seconds.                                                                                                                                                                                                                                                                                                               |\n| private_subnet_ids                | list(string)                                | List of subnet IDs for the fargate service                                                                                                                                                                                                                                                                                                                                                           |                                                                                        |\n| codedeploy_service_role_arn       | string                                      | ARN of the IAM Role for the CodeDeploy to use to initiate new deployments. (usually the PowerBuilder Role)                                                                                                                                                                                                                                                                                           |                                                                                        |\n| codedeploy_termination_wait_time  | number                                      | the number of minutes to wait after a successful blue/green deployment before terminating instances from the original environment                                                                                                                                                                                                                                                                    | 15                                                                                     |\n| codedeploy_test_listener_port     | number                                      | The port for a codedeploy test listener. If provided CodeDeploy will use this port for test traffic on the new replacement set during the blue-green deployment process before shifting production traffic to the replacement set                                                                                                                                                                    | `null`                                                                                 |\n| codedeploy_lifecycle_hooks        | [object](#codedeploy_lifecycle_hooks)       | Define Lambda Functions for each CodeDeploy [lifecycle event hooks](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html). Use the Lambda function names as the values. Omit or set specific hooks to `null` if you don't want to invoke a lambda function at that hook. Omit or set this variable to `null` to not have any lifecycle hooks invoked. | `null`                                                                                 |\n| appspec_filename                  | string                                      | Filename (including path) to use when outputing appspec json.                                                                                                                                                                                                                                                                                                                                        | `appspec.json` in the current working directory (i.e. where you ran `terraform apply`) |\n| role_permissions_boundary_arn     | string                                      | ARN of the IAM Role permissions boundary to place on each IAM role created                                                                                                                                                                                                                                                                                                                           |                                                                                        |\n| target_group_deregistration_delay | number                                      | Deregistration delay in seconds for ALB target groups                                                                                                                                                                                                                                                                                                                                                | 60                                                                                     |\n| target_group_sticky_sessions      | boolean                                     | Enables sticky sessions on the ALB target groups                                                                                                                                                                                                                                                                                                                                                     | false                                                                                  |\n| site_url                          | string                                      | The URL for the site.                                                                                                                                                                                                                                                                                                                                                                                | Concatenates app_name with hosted_zone_name.                                           |\n| overwrite_records                 | bool                                        | Allow creation of Route53 records in Terraform to overwrite an existing record, if any.                                                                                                                                                                                                                                                                                                              | false                                                                                  |\n| hosted_zone                       | [object](#hosted_zone)                      | Hosted Zone object to redirect to ALB. (Can pass in the aws_hosted_zone object). A and AAAA records created in this hosted zone                                                                                                                                                                                                                                                                      |                                                                                        |\n| https_certificate_arn             | string                                      | ARN of the HTTPS certificate of the hosted zone/domain. Defaults to creating its own certificate.                                                                                                                                                                                                                                                                                                    | `null`                                                                                  |\n| autoscaling_config                | [object](#autoscaling_config)               | Configuration for default autoscaling policies and alarms. Additional advanced scaling options, which are optional, can be made with the \"scaling_up_policy_config\", \"scaling_up_metric_alarm_config\", \"scaling_down_policy_config\", and \"scaling_down_metric_alarm_config\" variables. Omit or set to `null` if you want to set up your own autoscaling policies and alarms.                         | `null`                                                                                 |\n| scaling_up_policy_config          | [object](#scaling_up_policy_config)         | Optional advanced configuration for the scaling up policy if 'autoscaling_config' is in use.                                                                                                                                                                                                                                                                                                         | See object definition [object](#scaling_up_policy_config)                              |                                                                        \n| scaling_up_metric_alarm_config    | [object](#scaling_up_metric_alarm_config)   | Optional advanced configuration for the scaling up metric alarm if 'autoscaling_config' is in use.                                                                                                                                                                                                                                                                                                   | See object definition [object](#scaling_up_metric_alarm_config)                        |                                                                        \n| scaling_down_policy_config        | [object](#scaling_down_policy_config)       | Optional advanced configuration for the scaling down policy if 'autoscaling_config' is in use.                                                                                                                                                                                                                                                                                                       | See object definition [object](#scaling_down_policy_config)                            |                                                                        \n| scaling_down_metric_alarm_config  | [object](#scaling_down_metric_alarm_config) | Optional advanced configuration for scaling the down metric alarm if 'autoscaling_config' is in use.\"                                                                                                                                                                                                                                                                                                | See object definition [object](#scaling_down_metric_alarm_config)                      |\n| log_group_name                    | string                                      | CloudWatch log group name.                                                                                                                                                                                                                                                                                                                                                                           |                                                                                        |\n| log_retention_in_days             | number                                      | CloudWatch log group retention in days                                                                                                                                                                                                                                                                                                                                                               | 120                                                                                    |\n| tags                              | map(string)                                 | A map of AWS Tags to attach to each resource created                                                                                                                                                                                                                                                                                                                                                 | `null`                                                                                 |\n| lb_logging_enabled                | bool                                        | Option to enable logging of load balancer requests.                                                                                                                                                                                                                                                                                                                                                  | false                                                                                  |\n| lb_logging_bucket_name            | string                                      | Required if `lb_logging_enabled` is true. A bucket to store the logs in with an a [load balancer access policy](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy) attached.                                                                                                                                                              |                                                                                        |\n| fargate_platform_version          | string                                      | Version of the Fargate platform to run.                                                                                                                                                                                                                                                                                                                                                              | 1.4.0                                                                                  |\n| xray_enabled                      | bool                                        | Whether or not the X-Ray daemon should be created with the Fargate API.                                                                                                                                                                                                                                                                                                                              | false                                                                                  |\n\n#### existing_ecs_cluster\nObject with following attributes to define an existing ECS cluster to deploy the fargate tasks.\n* **`arn`** - (Required) string of the ARN of the existing ECS cluster\n* **`name`** - (Required) string of the name of the existing ECS cluster\n\nIf you want to deploy this scheduled fargate task onto an existing cluster you would need to define this variable. For example:\n```hcl\nmodule \"test_api\" {\n  source = \"github.com/byu-oit/terraform-aws-fargate-api?ref=v6.2.0\"\n  app_name             = \"example-api\"\n  existing_ecs_cluster = {\n    arn  = aws_ecs_cluster.my_cluster.arn\n    name = aws_ecs_cluster.my_cluster.name\n  }\n  // ...\n}\n```\n\n#### container_definition\n\nObject with following attributes to define the docker container(s) your fargate needs to run.\n\n* **`name`** - (Required) container name (referenced in CloudWatch logs, and possibly by other containers)\n* **`image`** - (Required) the ecr_image_url with the tag like: `\u003cacct_num\u003e.dkr.ecr.us-west-2.amazonaws.com/myapp:dev`\n  or the image URL from dockerHub or some other docker registry\n* **`ports`** - (Required) a list of ports this container is listening on\n* **`environment_variables`** - a map of environment variables to pass to the docker container\n* **`secrets`** - a map of secrets from the parameter store to be assigned to env variables\n* **`efs_volume_mounts`** - a list of efs_volume_mount [objects](#efs_volume_mount) to be mounted into the\n  container.\n* **`ulimits`** - a list of ulimit [objects](#ulimit) to be set on the container.\n\n**Before running this configuration** make sure that your ECR repo exists and an image has been pushed to the repo.\n\n#### efs_volume_mount\n\nExample\n\n```\n    efs_volume_mounts = [\n      {\n        name = \"persistent_data\"\n        file_system_id = aws_efs_file_system.my_efs.id\n        root_directory = \"/\"\n        container_path = \"/usr/app/data\"\n      }\n    ]\n```\n\n* **`name`** - A logical name used to describe what the mount is for.\n* **`file_system_id`** - ID of the EFS to mount.\n* **`root_directory`** - Source path inside the EFS.\n* **`container_path`** - Target path inside the container.\n\nSee the following docs for more details:\n\n* https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#volume-block-arguments\n* https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#efs-volume-configuration-arguments\n* https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html\n* https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_MountPoint.html\n\n#### ulimit\n\nExample\n\n```\n    ulimits = [\n      {\n        name = \"nofile\"\n        soft_limit = 2048\n        hard_limit = 8192\n      }\n    ]\n```\n\nSee the following docs for more details:\n\n* https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html\n* https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Ulimit.html\n\n#### codedeploy_lifecycle_hooks\n\nThis variable is used when generating the [appspec.json](#appspec) file. This will define what Lambda Functions to\ninvoke at\nspecific [lifecycle hooks](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html)\n. Omit this variable or set it to `null` if you don't want to invoke any lambda functions. Omit or set a hook to `null` if you don't\nneed that specific lifecycle hook function.\n\n* **`before_install`** - lambda function name to run before new task set is created\n* **`after_install`** - lambda function name to run after new task set is created before test traffic points to new task\n  set\n* **`after_allow_test_traffic`** - lambda function name to run after test traffic points to new task set\n* **`before_allow_traffic`** - lambda function name to run before public traffic points to new task set\n* **`after_allow_traffic`** - lambda function name to run after public traffic points to new task set\n\n#### hosted_zone\n\nYou can pass in either the object from the AWS terraform provider for an AWS Hosted Zone, or just an object with the\nfollowing attributes:\n\n* **`name`** - (Required) Name of the hosted zone\n* **`id`** - (Required) ID of the hosted zone\n\n#### autoscaling_config\n\nThis module will create basic default autoscaling policies and alarms and you can define some variables of these default\nautoscaling policies.\n\n* **`min_capacity`** - (Required) Minimum task count for autoscaling (this will also be used to define the initial\n  desired count of the ECS Fargate Service)\n* **`max_capacity`** - (Required) Maximum task count for autoscaling\n\n**Note:** If you want to define your own autoscaling policies/alarms then you need to set this field to `null` at which\npoint this module will not create any policies/alarms.\n\n**Note:** the desired count of the ECS Fargate Service will be set the first time terraform runs but changes to desired\ncount will be ignored after the first time.\n\n#### scaling_up_policy_config\n\nThis will allow the scaling up policy to be configured if necessary.\n\n* **`adjustment_type`** - (Required) Specifies whether the adjustment is an absolute number or a percentage of the\n  current capacity.\n* **`metric_aggregation_type`** - (Required) The aggregation type for the policy's metrics.\n* **`cooldown`** - (Required) The amount of time, in seconds, after a scaling activity completes and before the next\n  scaling activity can start.\n* **`scaling_adjustment`** - (Required) The number of members by which to scale, when the adjustment bounds are\n  breached. A positive value scales up. A negative value scales down.\n* **`metric_interval_lower_bound`** - (Required) The lower bound for the difference between the alarm threshold and the\n  CloudWatch metric.\n* Default:\n  ```\n    {\n      adjustment_type             = \"ChangeInCapacity\"\n      metric_aggregation_type     = \"Average\"\n      cooldown                    = 300\n      scaling_adjustment          = 1\n      metric_interval_lower_bound = 0\n    }\n  ```\n\n#### scaling_down_policy_config\n\nThis will allow the scaling down policy to be configured if necessary.\n\n* **`adjustment_type`** - (Required) Specifies whether the adjustment is an absolute number or a percentage of the\n  current capacity.\n* **`metric_aggregation_type`** - (Required) The aggregation type for the policy's metrics.\n* **`cooldown`** - (Required) The amount of time, in seconds, after a scaling activity completes and before the next\n  scaling activity can start.\n* **`scaling_adjustment`** - (Required) The number of members by which to scale, when the adjustment bounds are\n  breached. A positive value scales up. A negative value scales down.\n* **`metric_interval_upper_bound`** - The upper bound for the difference between the alarm threshold and the CloudWatch\n  metric.\n* Default:\n  ```\n    {\n      adjustment_type             = \"ChangeInCapacity\"\n      metric_aggregation_type     = \"Average\"\n      cooldown                    = 300\n      scaling_adjustment          = -1\n      metric_interval_upper_bound = 0\n    }\n  ```\n\n#### scaling_up_metric_alarm_config\n\nThis will allow the scaling up alarm to be configured if necessary.\n\n* **`statistic`** - (Required) The statistic to apply to the alarm's associated metric.\n* **`metric_name`** - (Required) The name for the alarm's associated metric.\n* **`comparison_operator`** - (Required) The arithmetic operation to use when comparing the specified Statistic and\n  Threshold.\n* **`threshold`** - (Required) The value against which the specified statistic is compared.\n* **`period`** - (Required) The period in seconds over which the specified statistic is applied.\n* **`evaluation_periods`** - (Required) The number of periods over which data is compared to the specified threshold.\n* Default:\n  ```\n    {\n      statistic           = \"Average\"\n      metric_name         = \"CPUUtilization\"\n      comparison_operator = \"GreaterThanThreshold\"\n      threshold           = 75\n      period              = 300\n      evaluation_periods  = 5\n    }\n  ```\n\n#### scaling_down_metric_alarm_config\n\nThis will allow the scaling down alarm to be configured if necessary.\n\n* **`statistic`** - (Required) The statistic to apply to the alarm's associated metric.\n* **`metric_name`** - (Required) The name for the alarm's associated metric.\n* **`comparison_operator`** - (Required) The arithmetic operation to use when comparing the specified Statistic and\n  Threshold.\n* **`threshold`** - (Required) The value against which the specified statistic is compared.\n* **`period`** - (Required) The period in seconds over which the specified statistic is applied.\n* **`evaluation_periods`** - (Required) The number of periods over which data is compared to the specified threshold.\n* Default:\n  ```\n    {\n      statistic           = \"Average\"\n      metric_name         = \"CPUUtilization\"\n      comparison_operator = \"LessThanThreshold\"\n      threshold           = 25\n      period              = 300\n      evaluation_periods  = 5\n    }\n  ```\n\n#### CloudWatch logs\n\nThis module will create a CloudWatch log group named `fargate/\u003capp_name\u003e` with log streams\nnamed `\u003capp_name\u003e/\u003ccontainer_name\u003e/\u003ccontainer_id\u003e`.\n\nFor instance with the [above example](#usage) the logs could be found in the CloudWatch log group: `fargate/example-api`\nwith the container logs in `example-api/example/12d344fd34b556ae4326...`\n\n## Outputs\n\n| Name                           | Type                                                                                                                | Description                                                                                                         |\n|--------------------------------|---------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| fargate_service                | [object](https://www.terraform.io/docs/providers/aws/r/ecs_service.html#attributes-reference)                       | Fargate ECS Service object                                                                                          |\n| new_ecs_cluster                | [object](https://www.terraform.io/docs/providers/aws/r/ecs_cluster.html#attributes-reference)                       | Newly created ECS Cluster the service is deployed on, if var.existing_ecs_cluster is provided this will return null |\n| fargate_service_security_group | [object](https://www.terraform.io/docs/providers/aws/r/security_group.html#attributes-reference)                    | Security Group object assigned to the Fargate service                                                               |\n| task_definition                | [object](https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#attributes-reference)               | The task definition object of the fargate service                                                                   |\n| codedeploy_deployment_group    | [object](https://www.terraform.io/docs/providers/aws/r/codedeploy_deployment_group.html#attributes-reference)       | The CodeDeploy deployment group object.                                                                             |\n| codedeploy_appspec_json_file   | string                                                                                                              | Filename of the generated appspec.json file                                                                         |\n| alb                            | [object](https://www.terraform.io/docs/providers/aws/r/lb.html#attributes-reference)                                | The Application Load Balancer (ALB) object                                                                          |\n| alb_target_group_blue          | [object](https://www.terraform.io/docs/providers/aws/r/lb_target_group.html#attributes-reference)                   | The Application Load Balancer Target Group (ALB Target Group) object for the blue deployment                        |\n| alb_target_group_green         | [object](https://www.terraform.io/docs/providers/aws/r/lb_target_group.html#attributes-reference)                   | The Application Load Balancer Target Group (ALB Target Group) object  for the green deployment                      |\n| alb_security_group             | [object](https://www.terraform.io/docs/providers/aws/r/security_group.html#attributes-reference)                    | The ALB's security group object                                                                                     |\n| dns_record                     | [object](https://www.terraform.io/docs/providers/aws/r/route53_record.html#attributes-reference)                    | The DNS A-record mapped to the ALB                                                                                  |\n| cloudwatch_log_group           | [object](https://www.terraform.io/docs/providers/aws/r/cloudwatch_log_group#attributes-reference)                   | The CloudWatch Log group for the fargate service                                                                    |\n| autoscaling_step_up_policy     | [object](https://www.terraform.io/docs/providers/aws/r/autoscaling_policy.html#attributes-reference)                | Autoscaling policy to step up                                                                                       |\n| autoscaling_step_down_policy   | [object](https://www.terraform.io/docs/providers/aws/r/autoscaling_policy.html#attributes-reference)                | Autoscaling policy to step down                                                                                     |\n| task_role                      | [object](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role#attributes-reference) | IAM role created for the tasks.                                                                                     |\n| task_execution_role            | [object](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role#attributes-reference) | IAM role created for the execution of tasks.                                                                        |\n\n#### appspec\n\nThis module also creates a JSON file in the project directory: `appspec.json` used to initiate a CodeDeploy Deployment.\n\nHere's an example appspec.json file this creates:\n\n```json\n{\n  \"Resources\": [\n    {\n      \"TargetService\": {\n        \"Properties\": {\n          \"LoadBalancerInfo\": {\n            \"ContainerName\": \"example\",\n            \"ContainerPort\": 8000\n          },\n          \"TaskDefinition\": \"arn:aws:ecs:us-west-2:123456789123:task-definition/example-api-def:2\"\n        },\n        \"Type\": \"AWS::ECS::SERVICE\"\n      }\n    }\n  ],\n  \"version\": 1\n}\n```\n\nAnd example with [lifecycle hooks](#codedeploy_lifecycle_hooks):\n\n```json\n{\n  \"Hooks\": [\n    {\n      \"BeforeInstall\": null\n    },\n    {\n      \"AfterInstall\": \"AfterInstallHookFunctionName\"\n    },\n    {\n      \"AfterAllowTestTraffic\": \"AfterAllowTestTrafficHookFunctionName\"\n    },\n    {\n      \"BeforeAllowTraffic\": null\n    },\n    {\n      \"AfterAllowTraffic\": null\n    }\n  ],\n  \"Resources\": [\n    {\n      \"TargetService\": {\n        \"Properties\": {\n          \"LoadBalancerInfo\": {\n            \"ContainerName\": \"example\",\n            \"ContainerPort\": 8000\n          },\n          \"TaskDefinition\": \"arn:aws:ecs:us-west-2:123456789123:task-definition/example-api-def:2\"\n        },\n        \"Type\": \"AWS::ECS::SERVICE\"\n      }\n    }\n  ],\n  \"version\": 1\n}\n```\n\n## CodeDeploy Blue-Green Deployment\n\nThis module creates a blue-green deployment process with CodeDeploy. If a `codedeploy_test_listener_port` is provided\nthis module will create an ALB listener that will allow public traffic from that port to the running fargate service.\n\nWhen a CodeDeploy deployment is initiated (either via a pipeline or manually) CodeDeploy will:\n\n1. call lambda function defined for `BeforeInstall` hook\n2. attempt to create a new set of tasks (called the replacement set) with the new task definition etc. in the unused ALB\n   Target Group\n3. call lambda function defined for `AfterInstall` hook\n4. associate the test listener (if defined) to the new target group\n5. call lambda function defined for `AfterAllowTestTraffic` hook\n6. call lambda function defined for `BeforeAllowTraffic` hook\n7. associate the production listener to the new target group\n8. call lambda function defined for `AfterAllowTraffic` hook\n9. wait for the `codedeploy_termination_wait_time` in minutes before destroying the original task set (this is useful if\n   you need to manually rollback)\n\nAt any step (except step #1) the deployment can rollback (either manually or by the lambda functions in the lifecycle\nhooks or if there was an error trying to actually deploy)\n\n##### TODO add diagrams to explain the blue-green deployment process\n\n## Note\n\nIf you require additional variables please create\nan [issue](https://github.com/byu-oit/terraform-aws-fargate-api/issues)\nand/or a [pull request](https://github.com/byu-oit/terraform-aws-fargate-api/pulls) to add the variable and reach out to\nthe Terraform Working Group on slack (`#terraform` channel).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyu-oit%2Fterraform-aws-fargate-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyu-oit%2Fterraform-aws-fargate-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyu-oit%2Fterraform-aws-fargate-api/lists"}