Skip to content

Commit 7f00ce6

Browse files
committed
more updates for rule zip
1 parent e4e86ed commit 7f00ce6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

aws_sra_examples/solutions/genai/bedrock_org/lambda/src/app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ def deploy_config_rules(region, accounts, resource_properties):
498498
# for region in rule_regions:
499499
# 3b) Deploy lambda for custom config rule
500500
if DRY_RUN is False:
501+
# download rule zip file
502+
s3_key = f"rules/{rule_name}/{rule_name}.zip"
503+
local_base_path = '/tmp/sra_staging_upload'
504+
local_file_path = os.path.join(local_base_path, 'rules', rule_name, f'{rule_name}.zip')
505+
s3.download_s3_file(local_file_path, s3_key, s3.STAGING_BUCKET)
506+
LIVE_RUN_DATA[f"{rule_name}_{acct}_{region}_LambdaCode"] = "Downloaded custom config rule lambda code"
507+
CFN_RESPONSE_DATA["deployment_info"]["action_count"] += 1
508+
509+
LOGGER.info(f"Deploying lambda for custom config rule in {acct} in {region}")
501510
lambda_arn = deploy_lambda_function(acct, rule_name, role_arn, region)
502511
LIVE_RUN_DATA[f"{rule_name}_{acct}_{region}_Lambda"] = "Deployed custom config lambda function"
503512
CFN_RESPONSE_DATA["deployment_info"]["action_count"] += 1

aws_sra_examples/solutions/genai/bedrock_org/lambda/src/sra_s3.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,15 @@ def stage_code_to_s3(self, directory_path, bucket_name, s3_path):
123123
return
124124
self.LOGGER.info(f"Uploaded {local_path} to {bucket_name} {s3_file_path}")
125125

126-
def download_s3_file(self, rule_name, bucket_name):
126+
def download_s3_file(self, local_file_path, s3_key, bucket_name):
127127
"""
128128
Downloads the rule code from the staging S3 bucket.
129129
130-
:param rule_name: Name of the rule
130+
:param local_file_path: Local path to save the downloaded file
131+
:param s3_key: Name of the S3 bucket key
131132
:param bucket_name: Name of the S3 bucket
132133
"""
133-
self.LOGGER.info(f"Downloading {rule_name} rule code from s3...")
134-
s3_key_template = 'rules/{rule_name}/{rule_name}.zip'
135-
local_base_path = '/tmp/sra_staging_upload'
136-
137-
s3_key = s3_key_template.format(rule_name=rule_name)
138-
local_file_path = os.path.join(local_base_path, 'rules', rule_name, f'{rule_name}.zip')
134+
self.LOGGER.info(f"Downloading file from s3...")
139135

140136
# Ensure local directories exist
141137
os.makedirs(os.path.dirname(local_file_path), exist_ok=True)

0 commit comments

Comments
 (0)