Skip to content

Commit ce44f75

Browse files
author
iru
authored
chore: infer region from provider (#42)
* chore: remove providers from examples * chore(test): add region to module * chore(doc): update provider READMES * chore(qa): org region KO :/
1 parent 5709599 commit ce44f75

File tree

16 files changed

+39
-45
lines changed

16 files changed

+39
-45
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ All the required resources and workloads will be run under the same AWS account,
1515

1616
Minimum requirements:
1717

18-
1. **AWS** profile credentials configured within yor `aws` provider
19-
2. A **Kubernetes** cluster configured within your `helm` provider
18+
1. Configure [Terraform **AWS** Provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
19+
2. Configure [**Helm** Provider](https://registry.terraform.io/providers/hashicorp/helm/latest/docs) for **Kubernetes** cluster
2020
3. **Sysdig** Secure API token , as input variable value
2121
```
2222
sysdig_secure_api_token=<SECURE_API_TOKEN>
@@ -32,12 +32,13 @@ For quick testing, use this snippet on your terraform files.
3232
3333
```terraform
3434
provider "aws" {
35-
region = var.region
36-
...
35+
region = "<AWS-REGION>; ex. us-east-1"
3736
}
3837
3938
provider "helm" {
40-
...
39+
kubernetes {
40+
config_path = "~/.kube/config"
41+
}
4142
}
4243
4344
module "org_k8s_threat_reuse_cloudtrail" {
@@ -80,6 +81,7 @@ Notice that:
8081

8182
| Name | Version |
8283
|------|---------|
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.50.0 |
8385
| <a name="provider_helm"></a> [helm](#provider\_helm) | >=2.3.0 |
8486

8587
## Modules
@@ -94,6 +96,7 @@ Notice that:
9496
| Name | Type |
9597
|------|------|
9698
| [helm_release.cloud_connector](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
99+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
97100

98101
## Inputs
99102

@@ -104,7 +107,6 @@ Notice that:
104107
| <a name="input_cloudtrail_s3_sns_sqs_url"></a> [cloudtrail\_s3\_sns\_sqs\_url](#input\_cloudtrail\_s3\_sns\_sqs\_url) | Organization cloudtrail event notification S3-SNS-SQS URL to listen to | `string` | n/a | yes |
105108
| <a name="input_sysdig_secure_api_token"></a> [sysdig\_secure\_api\_token](#input\_sysdig\_secure\_api\_token) | Sysdig Secure API token | `string` | n/a | yes |
106109
| <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 |
107-
| <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 |
108110
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
109111
| <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 |
110112

examples-internal/organizational-k8s-threat-reuse_cloudtrail/cloud-connector.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "helm_release" "cloud_connector" {
3232

3333
set {
3434
name = "aws.region"
35-
value = var.region
35+
value = data.aws_region.current.name
3636
}
3737

3838
set {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_region" "current" {}

examples-internal/organizational-k8s-threat-reuse_cloudtrail/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ variable "aws_secret_access_key" {
3131
#
3232
# general
3333
#
34-
variable "region" {
35-
type = string
36-
default = "eu-central-1"
37-
description = "Default region for resource creation in both organization master and secure-for-cloud member account"
38-
}
39-
4034
variable "name" {
4135
type = string
4236
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"

examples/organizational/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ Minimum requirements:
1919
1. Have an existing AWS account as the organization management account
2020
* Organizational CloudTrail service must be enabled
2121
* [Organizational CloudFormation StackSets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-enable-trusted-access.html) service must be enabled
22-
2. AWS profile credentials configuration of the `management` account of the organization
22+
1. Configure [Terraform **AWS** Provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) of the `management` account of the organization
2323
* This account credentials must be [able to manage cloudtrail creation](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html)
2424
> You must be logged in with the management account for the organization to create an organization trail. You must also have sufficient permissions for the IAM user or role in the management account to successfully create an organization trail.
2525
* When an account becomes part of an organization, AWS will create an `OrganizationAccountAccessRole` [for account management](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html), which Sysdig Secure for Cloud will use for member-account provisioning and role assuming.
2626
<br/>This Role name is currently hardcoded.
27-
3. Provide a member account ID for Sysdig Secure for Cloud workload to be deployed.
27+
3. Provide a member **account ID for Sysdig Secure for Cloud workload** to be deployed.
2828
Our recommendation is for this account to be empty, so that deployed resources are not mixed up with your workload.
2929
This input must be provided as terraform required input value
3030
```
3131
sysdig_secure_for_cloud_member_account_id=<ORGANIZATIONAL_SECURE_FOR_CLOUD_ACCOUNT_ID>
3232
```
33-
4. Sysdig Secure requirements, as input variable value with the `api-token`
33+
4. **Sysdig Secure** requirements, as input variable value with the `api-token`
3434
```
3535
sysdig_secure_api_token=<SECURE_API_TOKEN>
3636
```
@@ -41,13 +41,14 @@ For quick testing, use this snippet on your terraform files
4141
4242
```terraform
4343
provider "aws" {
44-
region = var.region
45-
...
44+
region = "<AWS_REGION>; ex. us-east-1"
4645
}
4746
4847
module "secure_for_cloud_organizational" {
4948
source = "sysdiglabs/secure-for-cloud/aws//examples/organizational"
5049
50+
region = "<AWS_REGION>; ex. us-east-1"
51+
5152
sysdig_secure_api_token = "00000000-1111-2222-3333-444444444444"
5253
sysdig_secure_for_cloud_member_account_id = "<ORG_MEMBER_ACCOUNT_FOR_SYSDIG_SECURE_FOR_CLOUD>"
5354
}
@@ -80,6 +81,7 @@ Notice that:
8081

8182
| Name | Version |
8283
|------|---------|
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.62.0 |
8385
| <a name="provider_aws.member"></a> [aws.member](#provider\_aws.member) | >= 3.62.0 |
8486

8587
## Modules
@@ -103,6 +105,7 @@ Notice that:
103105
|------|------|
104106
| [aws_iam_role.connector_ecs_task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
105107
| [aws_iam_policy_document.task_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
108+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
106109

107110
## Inputs
108111

examples/organizational/data.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_region" "current" {}

examples/organizational/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
provider "aws" {
2-
alias = "member"
2+
alias = "member"
3+
# NOTE. this won't work with test, workaround with var
4+
# region = data.aws_region.current.name
35
region = var.region
46
assume_role {
57
role_arn = "arn:aws:iam::${var.sysdig_secure_for_cloud_member_account_id}:role/${var.organizational_member_default_admin_role}"
@@ -147,6 +149,6 @@ module "cloud_bench" {
147149
name = "${var.name}-cloudbench"
148150
tags = var.tags
149151
is_organizational = true
150-
region = var.region
152+
region = data.aws_region.current.name
151153
benchmark_regions = var.benchmark_regions
152154
}

examples/single-account-k8s/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ All the required resources and workloads will be run under the same AWS account.
1616

1717
Minimum requirements:
1818

19-
1. **AWS** profile credentials configuration
20-
2. **Kubernetes** cluster configured within your helm provider
19+
1. Configure [Terraform **AWS** Provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
20+
2. Configure [**Helm** Provider](https://registry.terraform.io/providers/hashicorp/helm/latest/docs) for **Kubernetes** cluster
2121
3. **Sysdig** Secure requirements, as input variable value
2222
```
2323
sysdig_secure_api_token=<SECURE_API_TOKEN>
@@ -29,12 +29,13 @@ For quick testing, use this snippet on your terraform files
2929

3030
```terraform
3131
provider "aws" {
32-
region = var.region
33-
...
32+
region = "<AWS-REGION>; ex. us-east-1"
3433
}
3534
3635
provider "helm" {
37-
...
36+
kubernetes {
37+
config_path = "~/.kube/config"
38+
}
3839
}
3940
4041
module "secure_for_cloud_aws_single_account" {
@@ -73,6 +74,7 @@ Notice that:
7374

7475
| Name | Version |
7576
|------|---------|
77+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.50.0 |
7678
| <a name="provider_helm"></a> [helm](#provider\_helm) | >=2.3.0 |
7779

7880
## Modules
@@ -93,6 +95,7 @@ Notice that:
9395
|------|------|
9496
| [helm_release.cloud_connector](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
9597
| [helm_release.cloud_scanning](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
98+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
9699

97100
## Inputs
98101

@@ -104,7 +107,6 @@ Notice that:
104107
| <a name="input_deploy_image_scanning"></a> [deploy\_image\_scanning](#input\_deploy\_image\_scanning) | true/false whether to deploy cloud\_scanning | `bool` | `true` | no |
105108
| <a name="input_deploy_threat_detection"></a> [deploy\_threat\_detection](#input\_deploy\_threat\_detection) | true/false whether to deploy cloud\_connector | `bool` | `true` | no |
106109
| <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 |
107-
| <a name="input_region"></a> [region](#input\_region) | Default region for resource creation | `string` | `"eu-central-1"` | no |
108110
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
109111
| <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 |
110112

examples/single-account-k8s/cloud-connector.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource "helm_release" "cloud_connector" {
4141

4242
set {
4343
name = "aws.region"
44-
value = var.region
44+
value = data.aws_region.current.name
4545
}
4646

4747
set {

examples/single-account-k8s/cloud-scanning.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ resource "helm_release" "cloud_scanning" {
5757

5858
set {
5959
name = "aws.region"
60-
value = var.region
60+
value = data.aws_region.current.name
6161
}
6262

6363
set {

examples/single-account-k8s/data.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_region" "current" {}

examples/single-account-k8s/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ variable "cloudtrail_kms_enable" {
3737
description = "true/false whether s3 should be encrypted. testing/economization purpose."
3838
}
3939

40-
41-
#
42-
# general
43-
#
44-
variable "region" {
45-
type = string
46-
default = "eu-central-1"
47-
description = "Default region for resource creation"
48-
}
49-
5040
variable "name" {
5141
type = string
5242
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"

examples/single-account/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All the required resources and workloads will be run under the same account.
99

1010
Minimum requirements:
1111

12-
1. AWS profile credentials configuration
12+
1. Configure [Terraform **AWS** Provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
1313
1. Secure requirements, as input variable value
1414
```
1515
sysdig_secure_api_token=<SECURE_API_TOKEN>
@@ -21,14 +21,13 @@ For quick testing, use this snippet on your terraform files
2121
2222
```terraform
2323
provider "aws" {
24-
region = var.region
25-
...
24+
region = "<AWS-REGION>; ex. us-east-1"
2625
}
2726
2827
module "secure_for_cloud_aws_single_account" {
2928
source = "sysdiglabs/secure-for-cloud/aws//examples/single-account"
3029
31-
sysdig_secure_api_token = "00000000-1111-2222-3333-444444444444"
30+
sysdig_secure_api_token = "00000000-1111-2222-3333-444444444444"
3231
}
3332
```
3433

test/fixtures/organizational-k8s/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ module "org_k8s_threat_reuse_cloudtrail" {
5757
}
5858
source = "../../../examples-internal/organizational-k8s-threat-reuse_cloudtrail"
5959
name = "${var.name}-orgk8s"
60-
region = var.region
6160

6261
sysdig_secure_api_token = var.sysdig_secure_api_token
6362
sysdig_secure_endpoint = var.sysdig_secure_endpoint

test/fixtures/organizational/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ module "cloudvision_aws_organizational" {
66
source = "../../../examples/organizational"
77
name = "${var.name}-org"
88

9+
region = var.region
10+
911
sysdig_secure_api_token = var.sysdig_secure_api_token
1012
sysdig_secure_endpoint = var.sysdig_secure_endpoint
1113
sysdig_secure_for_cloud_member_account_id = var.sysdig_secure_for_cloud_member_account_id
12-
region = var.region
1314
}

test/fixtures/single-account-k8s/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ module "cloudvision_aws_single_account_k8s" {
1414

1515
sysdig_secure_api_token = var.sysdig_secure_api_token
1616
sysdig_secure_endpoint = var.sysdig_secure_endpoint
17-
region = var.region
1817
}

0 commit comments

Comments
 (0)