Skip to content

Commit d950902

Browse files
irur2bit
andauthored
feat: parametrize ecs-task cpu/memory limits + aws module 4.0 bump changes (#64)
* feat(connector): add ability to set CPU and mempry limits for ECS task * chore: expose ecs cpu/mem variables to examples * chore: upgrade bucket acl/lifecycle/versioning usage to 4.0 * chore: testing minor changes Co-authored-by: Janar K <[email protected]>
1 parent f7774a2 commit d950902

File tree

21 files changed

+109
-31
lines changed

21 files changed

+109
-31
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ It may take some time, but you should see logs detecting the new image in the EC
144144

145145
## Troubleshooting
146146

147+
### Q: Getting error "Error: failed creating ECS Task Definition: ClientException: No Fargate configuration exists for given values.
148+
A: Your ECS task_size values aren't valid for Fargate. Specifically, your mem_limit value is too big for the cpu_limit you specified
149+
S: Check [supported task cpu and memory values](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html)
150+
147151
### Q: Getting error "404 Invalid parameter: TopicArn" when trying to reuse an existing cloudtrail-sns
148152

149153
```text

examples-internal/organizational-k8s-threat-reuse_cloudtrail_s3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Notice that:
8181

8282
| Name | Version |
8383
|------|---------|
84-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.1 |
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.0.0 |
8585
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.4.1 |
8686

8787
## Modules

examples/organizational/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ Notice that:
7474
| Name | Version |
7575
|------|---------|
7676
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
77-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.62.0 |
77+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0 |
7878
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.29 |
7979

8080
## Providers
8181

8282
| Name | Version |
8383
|------|---------|
84-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.1 |
85-
| <a name="provider_aws.member"></a> [aws.member](#provider\_aws.member) | 3.74.1 |
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.0.0 |
85+
| <a name="provider_aws.member"></a> [aws.member](#provider\_aws.member) | 4.0.0 |
8686

8787
## Modules
8888

@@ -122,6 +122,8 @@ Notice that:
122122
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `true` | no |
123123
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `true` | no |
124124
| <a name="input_ecs_cluster_name"></a> [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | Name of a pre-existing ECS (elastic container service) cluster. If defaulted, a new ECS cluster/VPC/Security Group will be created. For both options, ECS location will/must be within the `sysdig_secure_for_cloud_member_account_id` parameter accountID | `string` | `"create"` | no |
125+
| <a name="input_ecs_task_cpu"></a> [ecs\_task\_cpu](#input\_ecs\_task\_cpu) | Amount of CPU (in CPU units) to reserve for cloud-connector task | `string` | `"256"` | no |
126+
| <a name="input_ecs_task_memory"></a> [ecs\_task\_memory](#input\_ecs\_task\_memory) | Amount of memory (in megabytes) to reserve for cloud-connector task | `string` | `"512"` | no |
125127
| <a name="input_ecs_vpc_id"></a> [ecs\_vpc\_id](#input\_ecs\_vpc\_id) | ID of the VPC where the workload is to be deployed. Defaulted to be created when `ecs_cluster_name is not provided.` | `string` | `"create"` | no |
126128
| <a name="input_ecs_vpc_region_azs"></a> [ecs\_vpc\_region\_azs](#input\_ecs\_vpc\_region\_azs) | List of Availability Zones for ECS VPC creation. e.g.: ["apne1-az1", "apne1-az2"]. If defaulted, two of the default 'aws\_availability\_zones' datasource will be taken | `list(string)` | `[]` | no |
127129
| <a name="input_ecs_vpc_subnets_private_ids"></a> [ecs\_vpc\_subnets\_private\_ids](#input\_ecs\_vpc\_subnets\_private\_ids) | List of VPC subnets where workload is to be deployed. Defaulted to be created when `ecs_cluster_name is not provided.` | `list(string)` | `[]` | no |

examples/organizational/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ module "cloud_connector" {
8080
ecs_cluster_name = local.ecs_cluster_name
8181
ecs_vpc_id = local.ecs_vpc_id
8282
ecs_vpc_subnets_private_ids = local.ecs_vpc_subnets_private_ids
83+
ecs_task_cpu = var.ecs_task_cpu
84+
ecs_task_memory = var.ecs_task_memory
8385

8486
tags = var.tags
8587
depends_on = [local.cloudtrail_sns_arn, module.ssm]

examples/organizational/variables.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ variable "ecs_vpc_region_azs" {
120120
default = []
121121
}
122122

123+
# Configure CPU and memory in pairs.
124+
# See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size
125+
variable "ecs_task_cpu" {
126+
type = string
127+
description = "Amount of CPU (in CPU units) to reserve for cloud-connector task"
128+
default = "256"
129+
}
130+
131+
variable "ecs_task_memory" {
132+
type = string
133+
description = "Amount of memory (in megabytes) to reserve for cloud-connector task"
134+
default = "512"
135+
}
136+
123137

124138

125139
#

examples/organizational/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.15.0"
33
required_providers {
44
aws = {
5-
version = ">= 3.62.0"
5+
version = ">= 4.0.0"
66
}
77
sysdig = {
88
source = "sysdiglabs/sysdig"

examples/single-account-k8s/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Notice that:
7272

7373
| Name | Version |
7474
|------|---------|
75-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.1 |
75+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.0.0 |
7676
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.4.1 |
7777

7878
## Modules

examples/single-account/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Notice that:
5050
| Name | Version |
5151
|------|---------|
5252
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
53-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.62.0 |
53+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0 |
5454
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.29 |
5555

5656
## Providers
@@ -86,6 +86,8 @@ No resources.
8686
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `true` | no |
8787
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `true` | no |
8888
| <a name="input_ecs_cluster_name"></a> [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | Name of a pre-existing ECS (elastic container service) cluster. If defaulted, a new ECS cluster/VPC/Security Group will be created | `string` | `"create"` | no |
89+
| <a name="input_ecs_task_cpu"></a> [ecs\_task\_cpu](#input\_ecs\_task\_cpu) | Amount of CPU (in CPU units) to reserve for cloud-connector task | `string` | `"256"` | no |
90+
| <a name="input_ecs_task_memory"></a> [ecs\_task\_memory](#input\_ecs\_task\_memory) | Amount of memory (in megabytes) to reserve for cloud-connector task | `string` | `"512"` | no |
8991
| <a name="input_ecs_vpc_id"></a> [ecs\_vpc\_id](#input\_ecs\_vpc\_id) | ID of the VPC where the workload is to be deployed. Defaulted to be created when 'ecs\_cluster\_name' is not provided. | `string` | `"create"` | no |
9092
| <a name="input_ecs_vpc_region_azs"></a> [ecs\_vpc\_region\_azs](#input\_ecs\_vpc\_region\_azs) | List of Availability Zones for ECS VPC creation. e.g.: ["apne1-az1", "apne1-az2"]. If defaulted, two of the default 'aws\_availability\_zones' datasource will be taken | `list(string)` | `[]` | no |
9193
| <a name="input_ecs_vpc_subnets_private_ids"></a> [ecs\_vpc\_subnets\_private\_ids](#input\_ecs\_vpc\_subnets\_private\_ids) | List of VPC subnets where workload is to be deployed. Defaulted to be created when 'ecs\_cluster\_name' is not provided. | `list(string)` | `[]` | no |

examples/single-account/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ module "cloud_connector" {
4949
ecs_cluster_name = local.ecs_cluster_name
5050
ecs_vpc_id = local.ecs_vpc_id
5151
ecs_vpc_subnets_private_ids = local.ecs_vpc_subnets_private_ids
52-
52+
ecs_task_cpu = var.ecs_task_cpu
53+
ecs_task_memory = var.ecs_task_memory
5354

5455
tags = var.tags
5556
depends_on = [local.cloudtrail_sns_arn, module.ssm]

examples/single-account/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ variable "ecs_vpc_region_azs" {
6060
default = []
6161
}
6262

63+
# Configure CPU and memory in pairs.
64+
# See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size
65+
variable "ecs_task_cpu" {
66+
type = string
67+
description = "Amount of CPU (in CPU units) to reserve for cloud-connector task"
68+
default = "256"
69+
}
70+
71+
variable "ecs_task_memory" {
72+
type = string
73+
description = "Amount of memory (in megabytes) to reserve for cloud-connector task"
74+
default = "512"
75+
}
6376

6477
#
6578
# scanning configuration

0 commit comments

Comments
 (0)