Skip to content

Commit 1ddbdd9

Browse files
committed
refactor!: create ecs cluster using resources instead of external module
Remove LICENSE and notice from README.
1 parent 86eb5b2 commit 1ddbdd9

File tree

6 files changed

+101
-201
lines changed

6 files changed

+101
-201
lines changed

.header.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
# terraform-aws-ecs
22

33
A Terraform module to create ECS Cluster that relies on self-managed EC2 instances.
4-
5-
## Notice
6-
7-
This module depends on and includes configuration for the [terraform-aws-modules/terraform-aws-ecs](https://github.com/terraform-aws-modules/terraform-aws-ecs), which is licensed under the Apache License 2.0. You can find the original license in the `LICENSE` file of the public module.

LICENSE

Lines changed: 0 additions & 176 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
A Terraform module to create ECS Cluster that relies on self-managed EC2 instances.
55

6-
## Notice
7-
8-
This module depends on and includes configuration for the [terraform-aws-modules/terraform-aws-ecs](https://github.com/terraform-aws-modules/terraform-aws-ecs), which is licensed under the Apache License 2.0. You can find the original license in the `LICENSE` file of the public module.
9-
106
## Requirements
117

128
| Name | Version |
@@ -15,28 +11,35 @@ This module depends on and includes configuration for the [terraform-aws-modules
1511

1612
## Providers
1713

18-
No providers.
14+
| Name | Version |
15+
|------|---------|
16+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.57.0 |
1917

2018
## Modules
2119

22-
| Name | Source | Version |
23-
|------|--------|---------|
24-
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | terraform-aws-modules/ecs/aws//modules/cluster | ~> 5.11.3 |
20+
No modules.
2521

2622
## Resources
2723

28-
No resources.
24+
| Name | Type |
25+
|------|------|
26+
| [aws_ecs_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster) | resource |
2927

3028
## Inputs
3129

3230
| Name | Description | Type | Default | Required |
3331
|------|-------------|------|---------|:--------:|
34-
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the ECS Cluster to create | `string` | `""` | no |
35-
| <a name="input_cluster_tags"></a> [cluster\_tags](#input\_cluster\_tags) | Resource Tags for ECS Cluster | `map(any)` | `{}` | no |
32+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the ECS Cluster to create | `string` | n/a | yes |
33+
| <a name="input_execute_command_configuration"></a> [execute\_command\_configuration](#input\_execute\_command\_configuration) | Details of the execute command configuration | <pre>object({<br> kms_key_id = optional(string)<br> logging = optional(string)<br> log_configuration = optional(object({<br> cloud_watch_encryption_enabled = optional(bool)<br> cloud_watch_log_group_name = optional(string)<br> s3_bucket_name = optional(string)<br> s3_bucket_encryption_enabled = optional(bool)<br> s3_key_prefix = optional(string)<br> }))<br> })</pre> | `null` | no |
34+
| <a name="input_service_connect_defaults"></a> [service\_connect\_defaults](#input\_service\_connect\_defaults) | Default Service Connect namespace | <pre>object({<br> namespace = string<br> })</pre> | `null` | no |
35+
| <a name="input_setting"></a> [setting](#input\_setting) | Details of the setting configuration | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
36+
| <a name="input_tags"></a> [tags](#input\_tags) | Resource Tags for ECS Cluster | `map(any)` | `{}` | no |
3637

3738
## Outputs
3839

3940
| Name | Description |
4041
|------|-------------|
4142
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | ARN of the ECS Cluster |
43+
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Identifier of the ECS Cluster |
44+
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | Name of the ECS Cluster |
4245
<!-- END_TF_DOCS -->

main.tf

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,53 @@
22
# ECS Cluster
33
################################################################################
44

5-
module "ecs_cluster" {
6-
source = "terraform-aws-modules/ecs/aws//modules/cluster"
7-
version = "~> 5.11.3"
5+
resource "aws_ecs_cluster" "this" {
6+
name = var.cluster_name
87

9-
cluster_name = var.cluster_name
10-
default_capacity_provider_use_fargate = false
8+
dynamic "configuration" {
9+
for_each = var.execute_command_configuration != null != null ? [1] : []
1110

12-
create_cloudwatch_log_group = false
11+
content {
12+
dynamic "execute_command_configuration" {
13+
for_each = var.execute_command_configuration != null ? [1] : []
1314

14-
tags = var.cluster_tags
15+
content {
16+
kms_key_id = try(var.execute_command_configuration.kms_key_id, null)
17+
logging = try(var.execute_command_configuration.logging, null)
18+
19+
dynamic "log_configuration" {
20+
for_each = try(var.execute_command_configuration.log_configuration, null) != null ? [1] : []
21+
22+
content {
23+
cloud_watch_encryption_enabled = try(var.execute_command_configuration.log_configuration.cloud_watch_encryption_enabled, null)
24+
cloud_watch_log_group_name = try(var.execute_command_configuration.log_configuration.cloud_watch_log_group_name, null)
25+
s3_bucket_name = try(var.execute_command_configuration.log_configuration.s3_bucket_name, null)
26+
s3_bucket_encryption_enabled = try(var.execute_command_configuration.log_configuration.s3_bucket_encryption_enabled, null)
27+
s3_key_prefix = try(var.execute_command_configuration.log_configuration.s3_key_prefix, null)
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
35+
dynamic "service_connect_defaults" {
36+
for_each = var.service_connect_defaults != null ? [1] : []
37+
38+
content {
39+
namespace = var.service_connect_defaults.namespace
40+
}
41+
}
42+
43+
dynamic "setting" {
44+
for_each = var.setting
45+
iterator = setting
46+
47+
content {
48+
name = setting.value.name
49+
value = setting.value.value
50+
}
51+
}
52+
53+
tags = var.tags
1554
}

outputs.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
# ECS Cluster
33
##############################
44

5+
output "cluster_id" {
6+
description = "Identifier of the ECS Cluster"
7+
value = aws_ecs_cluster.this.id
8+
}
9+
510
output "cluster_arn" {
611
description = "ARN of the ECS Cluster"
7-
value = module.ecs_cluster.arn
12+
value = aws_ecs_cluster.this.arn
813
}
914

1015
output "cluster_name" {

variables.tf

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
11
#######################
2-
# ECS Cluster Variables
2+
# ECS Cluster
33
#######################
44

55
variable "cluster_name" {
66
description = "Name of the ECS Cluster to create"
77
type = string
88
}
99

10-
variable "cluster_tags" {
10+
variable "execute_command_configuration" {
11+
description = "Details of the execute command configuration"
12+
type = object({
13+
kms_key_id = optional(string)
14+
logging = optional(string)
15+
log_configuration = optional(object({
16+
cloud_watch_encryption_enabled = optional(bool)
17+
cloud_watch_log_group_name = optional(string)
18+
s3_bucket_name = optional(string)
19+
s3_bucket_encryption_enabled = optional(bool)
20+
s3_key_prefix = optional(string)
21+
}))
22+
})
23+
default = null
24+
}
25+
26+
variable "service_connect_defaults" {
27+
description = "Default Service Connect namespace"
28+
type = object({
29+
namespace = string
30+
})
31+
default = null
32+
}
33+
34+
variable "setting" {
35+
description = "Details of the setting configuration"
36+
type = list(object({
37+
name = string
38+
value = string
39+
}))
40+
default = []
41+
}
42+
43+
variable "tags" {
1144
description = "Resource Tags for ECS Cluster"
1245
type = map(any)
1346
default = {}

0 commit comments

Comments
 (0)