diff --git a/README.md b/README.md
index d43e8b5..0a5c236 100644
--- a/README.md
+++ b/README.md
@@ -130,88 +130,27 @@ Terraform will display a plan showing the changes it intends to make. Review the
## Requirements
-| Name | Version |
-|------|---------|
-| [terraform](#requirement\_terraform) | >= 1.4, < 2.0.0 |
-| [aws](#requirement\_aws) | >= 4.0, < 6.0 |
+No requirements.
## Providers
-| Name | Version |
-|------|---------|
-| [aws](#provider\_aws) | 4.67.0 |
+No providers.
## Modules
-| Name | Source | Version |
-|------|--------|---------|
-| [acm](#module\_acm) | git::https://github.com/cloudposse/terraform-aws-acm-request-certificate | 0.17.0 |
-| [alb](#module\_alb) | ./modules/alb | n/a |
-| [alb\_sg](#module\_alb\_sg) | git::https://github.com/cloudposse/terraform-aws-security-group | 2.0.0 |
-| [ecs](#module\_ecs) | git::https://github.com/terraform-aws-modules/terraform-aws-ecs | v5.11.1 |
-| [health\_check](#module\_health\_check) | ./modules/health-check | n/a |
+No modules.
## Resources
-| Name | Type |
-|------|------|
-| [aws_cloudwatch_log_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
-| [aws_iam_role.execution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
-| [aws_iam_role_policy_attachment.execution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
-| [aws_lb_listener.http](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener) | resource |
-| [aws_lb_listener.https](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener) | resource |
-| [aws_service_discovery_private_dns_namespace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/service_discovery_private_dns_namespace) | resource |
-| [aws_ssm_parameter.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
-| [aws_iam_policy_document.assume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
+No resources.
## Inputs
-| Name | Description | Type | Default | Required |
-|------|-------------|------|---------|:--------:|
-| [access\_logs\_enabled](#input\_access\_logs\_enabled) | A boolean flag to enable/disable access\_logs | `bool` | `true` | no |
-| [acm\_domain\_name](#input\_acm\_domain\_name) | Domain name the ACM Certificate belongs to | `string` | n/a | yes |
-| [acm\_process\_domain\_validation\_options](#input\_acm\_process\_domain\_validation\_options) | Flag to enable/disable processing of the record to add to the DNS zone to complete certificate validation | `bool` | `true` | no |
-| [acm\_process\_domain\_validation\_record\_ttl](#input\_acm\_process\_domain\_validation\_record\_ttl) | The TTL of the record to add to the DNS zone to complete certificate validation | `string` | `"300"` | no |
-| [acm\_subject\_alternative\_names](#input\_acm\_subject\_alternative\_names) | Subject alternative names for the ACM Certificate | `list(string)` | `[]` | no |
-| [additional\_ssm\_params](#input\_additional\_ssm\_params) | Additional SSM Parameters you would like to add for your ECS configuration.
The optional value defaults are:
description = "Managed by Terraform"
type = "SecureString"
overwrite = true |
list(object({| `[]` | no | -| [alb\_access\_logs\_s3\_bucket\_force\_destroy](#input\_alb\_access\_logs\_s3\_bucket\_force\_destroy) | A boolean that indicates all objects should be deleted from the ALB access logs S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no | -| [alb\_access\_logs\_s3\_bucket\_force\_destroy\_enabled](#input\_alb\_access\_logs\_s3\_bucket\_force\_destroy\_enabled) | When `true`, permits `force_destroy` to be set to `true`.
name = string
value = string
description = string
type = string
overwrite = bool
}))
[| no | -| [externally\_managed\_route\_53\_record](#input\_externally\_managed\_route\_53\_record) | If there is a Route 53 Zone externally managed from the account you are running in. If `true`, you will have to manage your DNS yourself. | `bool` | `false` | no | -| [health\_check\_route\_53\_records](#input\_health\_check\_route\_53\_records) | List of Route 53 records for the health check service. | `list(string)` | n/a | yes | -| [health\_check\_subnet\_ids](#input\_health\_check\_subnet\_ids) | Subnet IDs for the health check tasks to run in. If not defined, this will use `var.alb_subnet_ids`. | `list(string)` | `[]` | no | -| [log\_group\_retention\_days](#input\_log\_group\_retention\_days) | Specifies the number of days you want to retain log events in the specified log group.
"arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess",
"arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
]
[| no | -| [tags](#input\_tags) | Tags to assign the resources. | `map(string)` | `{}` | no | -| [vpc\_id](#input\_vpc\_id) | Id of the VPC where the resources will live | `string` | n/a | yes | +No inputs. ## Outputs -| Name | Description | -|------|-------------| -| [alb\_arn](#output\_alb\_arn) | ARN to the ALB | -| [alb\_certificate\_arn](#output\_alb\_certificate\_arn) | ACM Certificate ARN | -| [alb\_dns\_name](#output\_alb\_dns\_name) | External DNS name to the ALB | -| [alb\_dns\_zone\_id](#output\_alb\_dns\_zone\_id) | External DNS name to the ALB | -| [alb\_http\_listener\_arn](#output\_alb\_http\_listener\_arn) | HTTP listener ARN for downstream services to use | -| [alb\_https\_listener\_arn](#output\_alb\_https\_listener\_arn) | HTTPS listener ARN for downstream services to use | -| [alb\_security\_group\_id](#output\_alb\_security\_group\_id) | ALB Security Group | -| [cluster\_arn](#output\_cluster\_arn) | ECS Cluster ARN | -| [cluster\_id](#output\_cluster\_id) | ECS Cluster ID | -| [cluster\_name](#output\_cluster\_name) | ECS Cluster name | -| [health\_check\_fqdn](#output\_health\_check\_fqdn) | Health check FQDN record created in Route 53. | +No outputs. ## SSM Parameters diff --git a/example/.terraform.lock.hcl b/example/.terraform.lock.hcl new file mode 100644 index 0000000..c62e06d --- /dev/null +++ b/example/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.76.0" + constraints = ">= 4.0.0, >= 5.0.0, < 6.0.0" + hashes = [ + "h1:JSLR3JP9naVcnH0PHcDwwHr3aQB9vlW0+b8HQma1GpU=", + "zh:05b2a0d25fc07576f6698d4840d0d2ae2599484c49f1b911ea1154584557bc13", + "zh:1b22dd1d9c482739e133adb996a9c8b285ca7d978d0fe04deaa5588eba5d254c", + "zh:216088c8800e7b8d7eff7b1a822317bc6faec64f27946ffd22bb3494ac4175cb", + "zh:43e994112b1484bf49945c4885aa2fee32486c9a5d64b9146bbd6f309f24e332", + "zh:46a28ba800f176eef500f998217bccc331605ef05f11abb1728f727a81f3a8b0", + "zh:4fad2743174a600da76a0cceeec2fef8399a18d880ba8929d811cd5cea1b5dee", + "zh:5c42a2c1438cd7533456026f52b562715664490711fdea809f44610a7565c145", + "zh:792d4fd4be434682e4540d2579505c7f11f39d0efe1d12ee2761ed0d46c8cd51", + "zh:7bb5f9f87c9da6d62d6f89504f01a9d6d2f19dcaa0efc46ea51ebdc4bb6fd536", + "zh:81cdbd97f81b1110fce793944d5668a4389904979eb7d178d3142a6b0e175e5e", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:ab4b881eb0f3812b702aaecf921c5c16bbcc33d61d668be4d72d6da9c57ded85", + "zh:c1d9d1166fd948845614deef81f3197568d0d3c2a03b8b97fff308ebc59043f9", + "zh:cda7530f2c01434e483d3faf62fc0685295e7f844176aa38df1ba65fa6a4407a", + "zh:fdad558b1c41aa68123d0da82cc0d65bc86d09eaa1ab1d3a167ec3bce0fc0c66", + ] +} diff --git a/example/container/container_definition.json.tftpl b/example/container/container_definition.json.tftpl index 9d981ff..e818476 100644 --- a/example/container/container_definition.json.tftpl +++ b/example/container/container_definition.json.tftpl @@ -22,4 +22,4 @@ } } } -] \ No newline at end of file +] diff --git a/example/container/execution_role.json b/example/container/execution_role.json index 8dc41cc..293e28a 100644 --- a/example/container/execution_role.json +++ b/example/container/execution_role.json @@ -15,4 +15,4 @@ "Resource": "*" } ] - } \ No newline at end of file + } diff --git a/example/iam.tf b/example/iam.tf index 4b2014b..99b0937 100644 --- a/example/iam.tf +++ b/example/iam.tf @@ -5,9 +5,9 @@ resource "aws_iam_role_policy" "policies" { role = module.aws_service.task_role_id policy = templatefile("${path.module}/container/task_role/${each.value}", { - aws_region = var.region - aws_account = var.aws_account - environment = var.environment + aws_region = var.region + aws_account = var.aws_account + environment = var.environment }) depends_on = [ diff --git a/example/main.tf b/example/main.tf index cb1aac3..11fe373 100644 --- a/example/main.tf +++ b/example/main.tf @@ -58,8 +58,8 @@ module "ecs" { container_memory = 2048 environment_variables = { - PORT = var.container_port - URL_EXPIRE_SECONDS = "3600" + PORT = var.container_port + URL_EXPIRE_SECONDS = "3600" } container_definition = "container/container_definition.json.tftpl" diff --git a/example/outputs.tf b/example/outputs.tf index 44064e4..2bc84d6 100644 --- a/example/outputs.tf +++ b/example/outputs.tf @@ -10,4 +10,3 @@ output "cluster_id" { description = "ECS Cluster ID" value = module.ecs.cluster_id } - diff --git a/example/variables.tf b/example/variables.tf index f6354cd..f7a19af 100644 --- a/example/variables.tf +++ b/example/variables.tf @@ -68,4 +68,3 @@ variable "tasks_desired_max" { type = number description = "The maximum number of tasks desired" } - diff --git a/modules/ecs-fargate/.terraform.lock.hcl b/modules/ecs-fargate/.terraform.lock.hcl new file mode 100644 index 0000000..8612731 --- /dev/null +++ b/modules/ecs-fargate/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.76.0" + constraints = ">= 4.0.0, < 6.0.0" + hashes = [ + "h1:JSLR3JP9naVcnH0PHcDwwHr3aQB9vlW0+b8HQma1GpU=", + "zh:05b2a0d25fc07576f6698d4840d0d2ae2599484c49f1b911ea1154584557bc13", + "zh:1b22dd1d9c482739e133adb996a9c8b285ca7d978d0fe04deaa5588eba5d254c", + "zh:216088c8800e7b8d7eff7b1a822317bc6faec64f27946ffd22bb3494ac4175cb", + "zh:43e994112b1484bf49945c4885aa2fee32486c9a5d64b9146bbd6f309f24e332", + "zh:46a28ba800f176eef500f998217bccc331605ef05f11abb1728f727a81f3a8b0", + "zh:4fad2743174a600da76a0cceeec2fef8399a18d880ba8929d811cd5cea1b5dee", + "zh:5c42a2c1438cd7533456026f52b562715664490711fdea809f44610a7565c145", + "zh:792d4fd4be434682e4540d2579505c7f11f39d0efe1d12ee2761ed0d46c8cd51", + "zh:7bb5f9f87c9da6d62d6f89504f01a9d6d2f19dcaa0efc46ea51ebdc4bb6fd536", + "zh:81cdbd97f81b1110fce793944d5668a4389904979eb7d178d3142a6b0e175e5e", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:ab4b881eb0f3812b702aaecf921c5c16bbcc33d61d668be4d72d6da9c57ded85", + "zh:c1d9d1166fd948845614deef81f3197568d0d3c2a03b8b97fff308ebc59043f9", + "zh:cda7530f2c01434e483d3faf62fc0685295e7f844176aa38df1ba65fa6a4407a", + "zh:fdad558b1c41aa68123d0da82cc0d65bc86d09eaa1ab1d3a167ec3bce0fc0c66", + ] +} diff --git a/modules/ecs-fargate/cloudwatch.tf b/modules/ecs-fargate/cloudwatch.tf index add66af..9b260da 100644 --- a/modules/ecs-fargate/cloudwatch.tf +++ b/modules/ecs-fargate/cloudwatch.tf @@ -2,11 +2,11 @@ resource "aws_cloudwatch_log_group" "proxy" { name = "/aws/ecs/${var.ecs.cluster_name}/${var.ecs.service_name}/${var.environment}" retention_in_days = 90 tags = { - Name = "/aws/ecs/${var.ecs.cluster_name}/${var.ecs.service_name}/${var.environment}", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "/aws/ecs/${var.ecs.cluster_name}/${var.ecs.service_name}/${var.environment}", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } @@ -25,11 +25,11 @@ resource "aws_cloudwatch_metric_alarm" "cpu_high" { alarm_actions = [aws_appautoscaling_policy.scale_up.arn] tags = { - Name = "${local.service_name_full}-cpu-high-alarm", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-cpu-high-alarm", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } // Autoscaling - Alarm CPU Low @@ -47,9 +47,9 @@ resource "aws_cloudwatch_metric_alarm" "cpu_low" { alarm_actions = [aws_appautoscaling_policy.scale_down.arn] tags = { - Name = "${local.service_name_full}-cpu-low-alarm", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-cpu-low-alarm", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } diff --git a/modules/ecs-fargate/iam.tf b/modules/ecs-fargate/iam.tf index 7fec6aa..c3aaedb 100644 --- a/modules/ecs-fargate/iam.tf +++ b/modules/ecs-fargate/iam.tf @@ -3,11 +3,11 @@ resource "aws_iam_role" "task_role" { name = "${local.service_name_full}-task-role" assume_role_policy = data.aws_iam_policy_document.document.json tags = { - Name = "${local.service_name_full}-task-role", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-task-role", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } # The ECS Task Execution role IAM permissions @@ -15,11 +15,11 @@ resource "aws_iam_role" "execution_role" { name = "${local.service_name_full}-execution-role" assume_role_policy = data.aws_iam_policy_document.document.json tags = { - Name = "${local.service_name_full}-execution-role", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-execution-role", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } resource "aws_iam_role_policy" "execution_role" { diff --git a/modules/ecs-fargate/json/container_definition.json.tftpl b/modules/ecs-fargate/json/container_definition.json.tftpl index ab26d5e..5a5eb5f 100644 --- a/modules/ecs-fargate/json/container_definition.json.tftpl +++ b/modules/ecs-fargate/json/container_definition.json.tftpl @@ -23,4 +23,4 @@ } } } -] \ No newline at end of file +] diff --git a/modules/ecs-fargate/json/execution_role.json b/modules/ecs-fargate/json/execution_role.json index 8dc41cc..293e28a 100644 --- a/modules/ecs-fargate/json/execution_role.json +++ b/modules/ecs-fargate/json/execution_role.json @@ -15,4 +15,4 @@ "Resource": "*" } ] - } \ No newline at end of file + } diff --git a/modules/ecs-fargate/lb.tf b/modules/ecs-fargate/lb.tf index b234127..3ddd81d 100644 --- a/modules/ecs-fargate/lb.tf +++ b/modules/ecs-fargate/lb.tf @@ -16,11 +16,11 @@ resource "aws_lb_target_group" "tg" { } } tags = { - Name = "${local.service_name_full}-tg", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${local.service_name_full}-tg", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } resource "aws_lb_listener" "listener" { @@ -33,8 +33,8 @@ resource "aws_lb_listener" "listener" { target_group_arn = aws_lb_target_group.tg.arn } tags = { - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } diff --git a/modules/ecs-fargate/locals.tf b/modules/ecs-fargate/locals.tf index 4da2a0b..3975f6c 100644 --- a/modules/ecs-fargate/locals.tf +++ b/modules/ecs-fargate/locals.tf @@ -1,7 +1,7 @@ locals { - service_name_full = "${var.ecs.service_name}-${var.environment}" - cluster_name_full = "${var.ecs.cluster_name}-${var.environment}" - + service_name_full = "${var.ecs.service_name}-${var.environment}" + cluster_name_full = "${var.ecs.cluster_name}-${var.environment}" + region_code = (var.aws_region == "us-west-1") ? "uw1" : "ue1" task = defaults(var.task, { diff --git a/modules/ecs-fargate/main.tf b/modules/ecs-fargate/main.tf index 3ae0391..e383c19 100644 --- a/modules/ecs-fargate/main.tf +++ b/modules/ecs-fargate/main.tf @@ -27,11 +27,11 @@ resource "aws_ecs_service" "service" { security_groups = [aws_security_group.ecs.id] } tags = { - Name = "${var.ecs.service_name}-${var.environment}", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${var.ecs.service_name}-${var.environment}", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } propagate_tags = "TASK_DEFINITION" } @@ -58,9 +58,9 @@ resource "aws_ecs_task_definition" "definition" { }) tags = { - Name = "${var.ecs.service_name}-${var.environment}-task-definition", - Environment = "${var.environment}", - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}" - } + Name = "${var.ecs.service_name}-${var.environment}-task-definition", + Environment = "${var.environment}", + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}" + } } diff --git a/modules/ecs-fargate/sg.tf b/modules/ecs-fargate/sg.tf index fe147a3..2703c4f 100644 --- a/modules/ecs-fargate/sg.tf +++ b/modules/ecs-fargate/sg.tf @@ -20,12 +20,12 @@ resource "aws_security_group" "alb" { } tags = { - Name = "${local.service_name_full}-alb", - Environment = var.environment, - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}", - Description = "Allow HTTP traffic to the application proxy" - owner = "devops" + Name = "${local.service_name_full}-alb", + Environment = var.environment, + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}", + Description = "Allow HTTP traffic to the application proxy" + owner = "devops" } } @@ -51,11 +51,11 @@ resource "aws_security_group" "ecs" { } tags = { - Name = "${local.service_name_full}-ecs", - Environment = var.environment, - Project = "${var.project}", - Service = "${var.ecs.service_name_tag}", - Description = "Allow traffic from the ALB into the Docker containers." - owner = "devops" + Name = "${local.service_name_full}-ecs", + Environment = var.environment, + Project = "${var.project}", + Service = "${var.ecs.service_name_tag}", + Description = "Allow traffic from the ALB into the Docker containers." + owner = "devops" } } diff --git a/modules/ecs-fargate/version.tf b/modules/ecs-fargate/version.tf index 9796a57..318aeda 100644 --- a/modules/ecs-fargate/version.tf +++ b/modules/ecs-fargate/version.tf @@ -7,4 +7,4 @@ terraform { version = ">= 4.0, < 6.0" } } -} \ No newline at end of file +}
"default.example.local"
]