Skip to content

Commit 4d443dd

Browse files
committed
fix(consumer): Some log lines were not logging the provided data.
1 parent 698599f commit 4d443dd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ct_configrecorder_override_consumer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import os
2626

2727

28+
2829
def lambda_handler(event, context):
2930
LOG_LEVEL = os.getenv('LOG_LEVEL')
3031
logging.getLogger().setLevel(LOG_LEVEL)
@@ -80,7 +81,7 @@ def assume_role(account_id, role='AWSControlTowerExecution'):
8081

8182
# Describe configuration recorder
8283
configrecorder = configservice.describe_configuration_recorders()
83-
logging.info(f'Existing Configuration Recorder :', configrecorder)
84+
logging.info(f'Existing Configuration Recorder: {configrecorder}')
8485

8586
# ControlTower created configuration recorder with name "aws-controltower-BaselineConfigRecorder" and we will update just that
8687
try:
@@ -100,6 +101,9 @@ def assume_role(account_id, role='AWSControlTowerExecution'):
100101

101102
# Event = Delete is when stack is deleted, we rollback changed made and leave it as ControlTower Intended
102103
if event == 'Delete':
104+
logging.warn(
105+
"Deleting stack: Reverting Configuration Recorder to default settings"
106+
)
103107
response = configservice.put_configuration_recorder(
104108
ConfigurationRecorder={
105109
'name': 'aws-controltower-BaselineConfigRecorder',
@@ -110,7 +114,9 @@ def assume_role(account_id, role='AWSControlTowerExecution'):
110114
},
111115
'recordingMode': {'recordingFrequency': 'CONTINUOUS'},
112116
})
113-
logging.info(f'Response for put_configuration_recorder :{response} ')
117+
logging.info(
118+
f"Configuration Recorder reset to default. Response: {json.dumps(response, default=str)}"
119+
)
114120

115121
else:
116122
config_recorder = {
@@ -152,7 +158,7 @@ def assume_role(account_id, role='AWSControlTowerExecution'):
152158
logging.info(f'Post Change Configuration recorder : {configrecorder}')
153159

154160
except botocore.exceptions.ClientError as exe:
155-
logging.error('Unable to Update Config Recorder for Account and Region : ', account_id, aws_region)
161+
logging.error(f'Unable to Update Config Recorder for Account {account_id} and Region {aws_region}')
156162
configrecorder = configservice.describe_configuration_recorders()
157163
logging.info(f'Exception : {configrecorder}')
158164
raise exe

0 commit comments

Comments
 (0)