Skip to content

Commit

Permalink
polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqiglantz committed Jan 5, 2024
1 parent ae9e12b commit aca94e4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 81 deletions.
46 changes: 28 additions & 18 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,37 @@
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 5.31.0 |
| <a name="requirement_github"></a> [github](#requirement\_github) | 5.42.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
| <a name="provider_github"></a> [github](#provider\_github) | 5.42.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_cluster_alb"></a> [cluster\_alb](#module\_cluster\_alb) | github.com/wenqiglantz/reusable-workflows-modules//terraform/modules/ecs/cluster_alb | main |
| <a name="module_fargate"></a> [fargate](#module\_fargate) | github.com/wenqiglantz/reusable-workflows-modules//terraform/modules/ecs/service_taskdef | main |
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | 9.4.0 |
| <a name="module_ecr"></a> [ecr](#module\_ecr) | terraform-aws-modules/ecr/aws | n/a |
| <a name="module_ecs"></a> [ecs](#module\_ecs) | terraform-aws-modules/ecs/aws | 5.7.4 |
| <a name="module_log_bucket"></a> [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 3.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 5.4.0 |

## Resources

| Name | Type |
|------|------|
| [aws_service_discovery_http_namespace.this](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/service_discovery_http_namespace) | resource |
| [github_actions_environment_variable.container_name](https://registry.terraform.io/providers/integrations/github/5.42.0/docs/resources/actions_environment_variable) | resource |
| [github_actions_environment_variable.ecr_repository_name](https://registry.terraform.io/providers/integrations/github/5.42.0/docs/resources/actions_environment_variable) | resource |
| [github_actions_environment_variable.ecs_cluster](https://registry.terraform.io/providers/integrations/github/5.42.0/docs/resources/actions_environment_variable) | resource |
| [github_actions_environment_variable.ecs_service](https://registry.terraform.io/providers/integrations/github/5.42.0/docs/resources/actions_environment_variable) | resource |
| [github_actions_environment_variable.ecs_task_definition](https://registry.terraform.io/providers/integrations/github/5.42.0/docs/resources/actions_environment_variable) | resource |
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/data-sources/availability_zones) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/data-sources/caller_identity) | data source |
| [aws_ssm_parameter.cert](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/data-sources/ssm_parameter) | data source |

## Inputs
Expand All @@ -31,33 +44,30 @@
|------|-------------|------|---------|:--------:|
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region | `string` | `"us-east-1"` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the cluster (up to 255 letters, numbers, hyphens, and underscores) | `string` | `""` | no |
| <a name="input_context_path"></a> [context\_path](#input\_context\_path) | application's path, used for ALB listener rule configuration | `string` | `""` | no |
| <a name="input_cpu"></a> [cpu](#input\_cpu) | The CPU size | `string` | `"512"` | no |
| <a name="input_create_cluster"></a> [create\_cluster](#input\_create\_cluster) | flag to create new cluster or use existing one | `bool` | `true` | no |
| <a name="input_deploy_env"></a> [deploy\_env](#input\_deploy\_env) | CI injected variable, deployment environment | `string` | `"dev"` | no |
| <a name="input_deploy_repo"></a> [deploy\_repo](#input\_deploy\_repo) | CI injected variable, application's repo name | `string` | `"sharedactions"` | no |
| <a name="input_container_cpu"></a> [container\_cpu](#input\_container\_cpu) | The container CPU size | `string` | `"512"` | no |
| <a name="input_container_memory"></a> [container\_memory](#input\_container\_memory) | The container memory size | `string` | `"1024"` | no |
| <a name="input_deploy_env"></a> [deploy\_env](#input\_deploy\_env) | deployment environment | `string` | `"dev"` | no |
| <a name="input_deploy_repo"></a> [deploy\_repo](#input\_deploy\_repo) | application's repo name | `string` | n/a | yes |
| <a name="input_ecr_repository_name"></a> [ecr\_repository\_name](#input\_ecr\_repository\_name) | The ECR repository name | `string` | `"default"` | no |
| <a name="input_github_repo_owner"></a> [github\_repo\_owner](#input\_github\_repo\_owner) | GitHub repo owner | `string` | `""` | no |
| <a name="input_healthcheck_path"></a> [healthcheck\_path](#input\_healthcheck\_path) | application's health check path | `string` | `""` | no |
| <a name="input_log_group_retention_in_days"></a> [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, etc. | `number` | `7` | no |
| <a name="input_memory"></a> [memory](#input\_memory) | The memory size | `string` | `"1024"` | no |
| <a name="input_pipeline_token"></a> [pipeline\_token](#input\_pipeline\_token) | CI injected variable, pipeline token | `string` | `""` | no |
| <a name="input_requester_name"></a> [requester\_name](#input\_requester\_name) | requestor name tag | `string` | n/a | yes |
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | service name, the same as the ECR image name | `string` | n/a | yes |
| <a name="input_service_port_target_group"></a> [service\_port\_target\_group](#input\_service\_port\_target\_group) | application's service port | `number` | `8080` | no |
| <a name="input_service_port"></a> [service\_port](#input\_service\_port) | application's service port | `number` | `8501` | no |
| <a name="input_service_prefix"></a> [service\_prefix](#input\_service\_prefix) | service prefix to be used in naming resources such as ALB, target group, security group, etc. | `string` | n/a | yes |
| <a name="input_task_cpu"></a> [task\_cpu](#input\_task\_cpu) | The task CPU size | `string` | `"512"` | no |
| <a name="input_task_memory"></a> [task\_memory](#input\_task\_memory) | The task memory size | `string` | `"1024"` | no |
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | The CIDR block of the vpc | `string` | n/a | yes |
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | The name of the vpc | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_alb_security_group_id"></a> [alb\_security\_group\_id](#output\_alb\_security\_group\_id) | n/a |
| <a name="output_app_test"></a> [app\_test](#output\_app\_test) | n/a |
| <a name="output_container_name"></a> [container\_name](#output\_container\_name) | n/a |
| <a name="output_ecr_repository_name"></a> [ecr\_repository\_name](#output\_ecr\_repository\_name) | n/a |
| <a name="output_ecs_alb_target_group_arn"></a> [ecs\_alb\_target\_group\_arn](#output\_ecs\_alb\_target\_group\_arn) | n/a |
| <a name="output_ecs_cluster"></a> [ecs\_cluster](#output\_ecs\_cluster) | n/a |
| <a name="output_ecs_service"></a> [ecs\_service](#output\_ecs\_service) | n/a |
| <a name="output_ecs_task_definition"></a> [ecs\_task\_definition](#output\_ecs\_task\_definition) | n/a |
| <a name="output_fargate_task_security_group_id"></a> [fargate\_task\_security\_group\_id](#output\_fargate\_task\_security\_group\_id) | n/a |
| <a name="output_repository_arn"></a> [repository\_arn](#output\_repository\_arn) | Full ARN of the repository |
| <a name="output_repository_registry_id"></a> [repository\_registry\_id](#output\_repository\_registry\_id) | The registry ID where the repository was created |
| <a name="output_repository_url"></a> [repository\_url](#output\_repository\_url) | The URL of the repository |
| <a name="output_services"></a> [services](#output\_services) | n/a |
<!-- END_TF_DOCS -->
60 changes: 0 additions & 60 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ data "aws_ssm_parameter" "cert" {
name = "/base/certificateArn"
}

data "aws_ssm_parameter" "fluentbit" {
name = "/aws/service/aws-for-fluent-bit/stable"
}

data "aws_caller_identity" "current" {}
data "aws_availability_zones" "available" {}

Expand Down Expand Up @@ -131,15 +127,6 @@ module "alb" {
}

listeners = {
/* ex-http-https-redirect = {
port = "80"
protocol = "HTTP"
redirect = {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
} */
ex-https = {
port = 443
protocol = "HTTPS"
Expand Down Expand Up @@ -224,7 +211,6 @@ module "ecs" {
memory = 1024
essential = true
image = "amazon/aws-for-fluent-bit:latest"
#image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.aws_region}.amazonaws.com/${var.ecr_repository_name}:aws-for-fluent-bit"
firelens_configuration = {
type = "fluentbit"
}
Expand Down Expand Up @@ -381,49 +367,3 @@ resource "github_actions_environment_variable" "ecr_repository_name" {
variable_name = "ECR_REPOSITORY_NAME"
value = var.ecr_repository_name
}


# module "cluster_alb" {
# source = "github.com/wenqiglantz/reusable-workflows-modules//terraform/modules/ecs/cluster_alb?ref=main"

# deploy_env = var.deploy_env
# requester_name = var.requester_name

# create_cluster = var.create_cluster
# cluster_name = var.cluster_name
# alb_name = "${var.service_prefix}-alb"
# service_port_target_group = var.service_port_target_group
# context_path = var.context_path
# alb_https_certificate_arn = data.aws_ssm_parameter.cert.value

# deploy_repo = var.deploy_repo
# pipeline_token = var.pipeline_token
# github_repo_owner = var.github_repo_owner
# }

# module "fargate" {
# source = "github.com/wenqiglantz/reusable-workflows-modules//terraform/modules/ecs/service_taskdef?ref=main"

# deploy_env = var.deploy_env
# requester_name = var.requester_name

# create_cluster = var.create_cluster
# cluster_name = var.cluster_name
# alb_security_group_id = module.cluster_alb.alb_security_group_id
# alb_target_group_arn = module.cluster_alb.ecs_alb_target_group_arn
# cpu = var.cpu
# memory = var.memory
# service_name = var.service_name
# ecr_repository_name = var.ecr_repository_name
# service_port_target_group = var.service_port_target_group
# log_group_retention_in_days = var.log_group_retention_in_days
# healthcheck_path = var.healthcheck_path
# target_group_name = "${var.service_prefix}-tgt-group"
# alb_request_count_per_target = var.alb_request_count_per_target
# ecs_autoscaling_target_max_capacity = var.ecs_autoscaling_target_max_capacity
# ecs_autoscaling_target_min_capacity = var.ecs_autoscaling_target_min_capacity

# deploy_repo = var.deploy_repo
# pipeline_token = var.pipeline_token
# github_repo_owner = var.github_repo_owner
# }
5 changes: 2 additions & 3 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
variable "deploy_repo" {
description = "CI injected variable, application's repo name"
description = "application's repo name"
type = string
default = "sharedactions"
}

variable "deploy_env" {
description = "CI injected variable, deployment environment"
description = "deployment environment"
type = string
default = "dev"
}
Expand Down

0 comments on commit aca94e4

Please sign in to comment.