Skip to content

Commit 05a3f46

Browse files
committed
feat: respect RegionsInScope parameter in RDS multitenant module
- Update Lambda function to use REGIONS_IN_SCOPE environment variable - Fallback to all regions if parameter is empty - Improves performance by limiting data collection to specified regions
1 parent a7c3697 commit 05a3f46

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

data-collection/deploy/module-rds-multitenant.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,14 @@ Resources:
175175
176176
print(f"Collecting CloudWatch Database Insights data for account: {account_id}")
177177
178-
# Get all active AWS regions
179-
ec2_client = boto3.client('ec2')
180-
regions = [region['RegionName'] for region in ec2_client.describe_regions()['Regions']]
178+
# Get regions in scope from environment variable
179+
regions_in_scope = os.environ.get('REGIONS_IN_SCOPE', '')
180+
if regions_in_scope:
181+
regions = [region.strip() for region in regions_in_scope.split(',') if region.strip()]
182+
else:
183+
# Fallback to all regions if none specified
184+
ec2_client = boto3.client('ec2')
185+
regions = [region['RegionName'] for region in ec2_client.describe_regions()['Regions']]
181186
182187
# Create S3 client
183188
s3_client = boto3.client('s3')
@@ -431,6 +436,7 @@ Resources:
431436
METRICS_PERIOD_IN_SECONDS: '3600'
432437
METRICS_S3_PREFIX: 'rds-multitenant'
433438
ROLENAME: !Ref MultiAccountRoleName
439+
REGIONS_IN_SCOPE: !Ref RegionsInScope
434440

435441
# EventBridge Scheduler to run the data collection hourly
436442
ModuleRefreshSchedule:

0 commit comments

Comments
 (0)