Skip to content

Commit 28820fc

Browse files
committed
improve validate-resources-from-desired-regions
1 parent ef5d51e commit 28820fc

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

governance/third-generation/aws/aws-functions/aws-functions.sentinel

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,10 @@ validate_assumed_roles_with_map = func(roles_map, workspace_name) {
157157
}
158158

159159
### filter_resources_by_region ###
160-
# Filter resources to those from a specific provider alias in a specific region
161-
# using the tfconfig/v2 import.
160+
# Filter resources to those in a specific region using the tfconfig/v2 import.
162161
# The parameter, resources, should be a collection of AWS resources from tfconfig
163-
# The parameter, provider, should be a provider derived from tfconfig.providers.
164162
# The parameter, region, should be given as a string such as "us-east-1"
165-
filter_resources_by_region = func(resources, provider, region) {
163+
filter_resources_by_region = func(resources, region) {
166164

167165
resources_from_region = {}
168166

governance/third-generation/aws/aws-functions/docs/filter_resources_by_region.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# filter_resources_by_region
2-
This function filters a collection of AWS resources to those created by a specific alias of the AWS provider and a specific region. The resources should come from the tfconfig/v2 import
2+
This function filters a collection of AWS resources to those created in a specific region. The resources should come from the tfconfig/v2 import
33

44
## Sentinel Module
55
This function is contained in the [aws-functions.sentinel](../aws-functions.sentinel) module.
@@ -9,7 +9,6 @@ This function is contained in the [aws-functions.sentinel](../aws-functions.sent
99

1010
## Arguments
1111
* **resources**: a collection of AWS resources derived from the tfconfig.resources.
12-
* **provider**: a specific alias of the AWS provider derived from tfconfig.providers.
1312
* **region**: a specific AWS region, provided as a string
1413

1514
## Common Functions Used
@@ -24,10 +23,8 @@ This function does not print anything.
2423
## Examples
2524
Here is an example of calling this function, assuming that the aws-functions.sentinel file that contains it has been imported with the alias `aws`:
2625
```
27-
for all_aws_providers as p {
28-
for allowed_regions as region {
29-
filtered_resources = aws.filter_resources_by_region(all_aws_resources, p, region)
30-
}
26+
for allowed_regions as region {
27+
filtered_resources = aws.filter_resources_by_region(all_aws_resources, region)
3128
}
3229
```
3330

governance/third-generation/aws/validate-resources-from-desired-regions.sentinel

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ allowed_regions = ["us-east-1", "us-west-1"]
1414
# Get all AWS resources
1515
all_aws_resources = config.find_resources_by_provider("aws")
1616

17-
// Get all providers
18-
all_aws_providers = config.find_providers_by_type("aws")
19-
2017
# Find all AWS resources for allowed regions
2118
aws_resources_from_allowed_regions = {}
22-
for all_aws_providers as p {
23-
for allowed_regions as region {
24-
filtered_resources = aws.filter_resources_by_region(all_aws_resources, p, region)
25-
# Add the filtered resources to aws_resources_from_allowed_regions
26-
for filtered_resources as address, r {
27-
aws_resources_from_allowed_regions[address] = r
28-
}
19+
for allowed_regions as region {
20+
filtered_resources = aws.filter_resources_by_region(all_aws_resources, region)
21+
# Add the filtered resources to aws_resources_from_allowed_regions
22+
for filtered_resources as address, r {
23+
aws_resources_from_allowed_regions[address] = r
2924
}
3025
}
3126

0 commit comments

Comments
 (0)