Skip to content

Commit 20bc9c9

Browse files
iruukitazume
iru
andauthored
Feature: enable vpc region availability zone variables (#53)
* feature: enable vpc-region-azs Co-authored-by: Yu Kitazume <[email protected]>
1 parent 4d5c843 commit 20bc9c9

File tree

10 files changed

+66
-8
lines changed

10 files changed

+66
-8
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,24 @@ Upload any image to the ECR repository of AWS.
132132
<br/>You should see a log in the ECS-cloud-scanner task + CodeBuild project being launched successfully
133133

134134
<br/><br/>
135+
135136
## Troubleshooting
136137

138+
139+
### Q: Getting error when creating the ECS subnet due to nats not being supported
140+
```
141+
│ Error: error creating subnet: InvalidParameterValue: Value (apne1-az3) for parameter availabilityZoneId is invalid. Subnets can currently only be created in the following availability zones: apne1-az1, apne1-az2, apne1-az4.
142+
│ status code: 400, request id: 6e32d757-2e61-4220-8106-22ccf814e1fe
143+
144+
│ with module.vpc.aws_subnet.public[1],
145+
│ on .terraform/modules/vpc/main.tf line 376, in resource "aws_subnet" "public":
146+
│ 376: resource "aws_subnet" "public" {
147+
```
148+
149+
A: For the ECS workload deployment a VPC is being created under the hood. Some AWS zones, such as the 'apne1-az3' in the 'ap-northeast' region does not support NATS, which is activated by default.
150+
S: Specify the desired VPC region availability zones for the vpc module, using the `ecs_vpc_region_azs` variable to explicit its desired value and workaround the error until AWS gives support for your region.
151+
152+
137153
### Q: I'm not able to see Cloud Infrastructure Entitlements Management (CIEM) results
138154
A: Make sure you installed both [cloud-bench](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-bench) and [cloud-connector](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-connector) modules
139155

examples/organizational/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Notice that:
121121
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If it does not exist, it will be inferred from created cloudtrail | `string` | `"create"` | no |
122122
| <a name="input_connector_ecs_task_role_name"></a> [connector\_ecs\_task\_role\_name](#input\_connector\_ecs\_task\_role\_name) | Name for the ecs task role. This is only required to resolve cyclic dependency with organizational approach | `string` | `"organizational-ECSTaskRole"` | no |
123123
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
124+
| <a name="input_ecs_vpc_region_azs"></a> [ecs\_vpc\_region\_azs](#input\_ecs\_vpc\_region\_azs) | Explicit list of availability zones for ECS VPC creation. eg: ["apne1-az1", "apne1-az2"]. If left empty it will be defaulted to two from the default datasource | `list(string)` | `[]` | no |
124125
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
125126
| <a name="input_organizational_member_default_admin_role"></a> [organizational\_member\_default\_admin\_role](#input\_organizational\_member\_default\_admin\_role) | Default role created by AWS for managed-account users to be able to admin member accounts.<br/>https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html | `string` | `"OrganizationAccountAccessRole"` | no |
126127
| <a name="input_region"></a> [region](#input\_region) | Default region for resource creation in both organization master and secure-for-cloud member account | `string` | `"eu-central-1"` | no |

examples/organizational/main.tf

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ module "ecs_fargate_cluster" {
3434
providers = {
3535
aws = aws.member
3636
}
37-
source = "../../modules/infrastructure/ecs-fargate-cluster"
38-
name = var.name
39-
tags = var.tags
37+
source = "../../modules/infrastructure/ecs-fargate-cluster"
38+
name = var.name
39+
ecs_vpc_region_azs = var.ecs_vpc_region_azs
40+
tags = var.tags
4041
}
4142

4243

examples/organizational/variables.tf

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ variable "benchmark_regions" {
7474
default = []
7575
}
7676

77+
78+
#
79+
# ecs vpc configuration
80+
#
81+
variable "ecs_vpc_region_azs" {
82+
type = list(string)
83+
description = "Explicit list of availability zones for ECS VPC creation. eg: [\"apne1-az1\", \"apne1-az2\"]. If left empty it will be defaulted to two from the default datasource"
84+
default = []
85+
}
86+
87+
7788
#
7889
# general
7990
#

examples/single-account/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ No resources.
8383
| <a name="input_cloudtrail_kms_enable"></a> [cloudtrail\_kms\_enable](#input\_cloudtrail\_kms\_enable) | true/false whether cloudtrail delivered events to S3 should persist encrypted | `bool` | `true` | no |
8484
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If it does not exist, it will be inferred from created cloudtrail | `string` | `"create"` | no |
8585
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
86+
| <a name="input_ecs_vpc_region_azs"></a> [ecs\_vpc\_region\_azs](#input\_ecs\_vpc\_region\_azs) | Explicit list of availability zones for ECS VPC creation. eg: ["apne1-az1", "apne1-az2"]. If left empty it will be defaulted to two from the default datasource | `list(string)` | `[]` | no |
8687
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
8788
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
8889
| <a name="input_tags"></a> [tags](#input\_tags) | sysdig secure-for-cloud tags | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |

examples/single-account/main.tf

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ module "resource_group" {
88
}
99

1010
module "ecs_fargate_cluster" {
11-
source = "../../modules/infrastructure/ecs-fargate-cluster"
12-
name = var.name
13-
tags = var.tags
11+
source = "../../modules/infrastructure/ecs-fargate-cluster"
12+
name = var.name
13+
ecs_vpc_region_azs = var.ecs_vpc_region_azs
14+
tags = var.tags
1415
}
1516

1617
module "ssm" {

examples/single-account/variables.tf

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ variable "sysdig_secure_api_token" {
99
# optionals - with defaults
1010
#---------------------------------
1111

12+
1213
#
1314
# cloudtrail configuration
1415
#
@@ -47,6 +48,16 @@ variable "benchmark_regions" {
4748
}
4849

4950

51+
#
52+
# ecs vpc configuration
53+
#
54+
variable "ecs_vpc_region_azs" {
55+
type = list(string)
56+
description = "Explicit list of availability zones for ECS VPC creation. eg: [\"apne1-az1\", \"apne1-az2\"]. If left empty it will be defaulted to two from the default datasource"
57+
default = []
58+
}
59+
60+
5061

5162
#
5263
# general

modules/infrastructure/ecs-fargate-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
| Name | Description | Type | Default | Required |
3434
|------|-------------|------|---------|:--------:|
35+
| <a name="input_ecs_vpc_region_azs"></a> [ecs\_vpc\_region\_azs](#input\_ecs\_vpc\_region\_azs) | Explicit list of availability zones for VPC creation. eg: ["apne1-az1", "apne1-az2"]. If left empty it will be defaulted to two from the default datasource | `list(string)` | `[]` | no |
3536
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
3637
| <a name="input_tags"></a> [tags](#input\_tags) | sysdig secure-for-cloud tags | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |
3738

modules/infrastructure/ecs-fargate-cluster/variables.tf

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
# optionals - with defaults
33
#---------------------------------
44

5+
#
6+
# vpc configuration
7+
#
8+
variable "ecs_vpc_region_azs" {
9+
type = list(string)
10+
description = "Explicit list of availability zones for VPC creation. eg: [\"apne1-az1\", \"apne1-az2\"]. If left empty it will be defaulted to two from the default datasource"
11+
default = []
12+
}
13+
14+
15+
#
16+
# general
17+
#
518
variable "name" {
619
type = string
720
description = "Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances"

modules/infrastructure/ecs-fargate-cluster/vpc.tf

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
data "aws_availability_zones" "zones" {}
1+
data "aws_availability_zones" "zones" {
2+
}
3+
24

35
module "vpc" {
46
source = "terraform-aws-modules/vpc/aws"
@@ -9,7 +11,7 @@ module "vpc" {
911
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
1012
public_subnets = ["10.0.101.0/24", "10.0.102.0/24"]
1113

12-
azs = [data.aws_availability_zones.zones.names[0], data.aws_availability_zones.zones.names[1]]
14+
azs = length(var.ecs_vpc_region_azs) > 0 ? var.ecs_vpc_region_azs : [data.aws_availability_zones.zones.names[0], data.aws_availability_zones.zones.names[1]]
1315

1416
enable_dns_hostnames = true
1517
enable_dns_support = true

0 commit comments

Comments
 (0)