Skip to content

Commit f4bf910

Browse files
committed
Added more config rules changes.
1 parent 78b35f0 commit f4bf910

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

python/example_code/config/config_rules.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import time
1414

1515
import boto3
16-
from botocore.exceptions import ClientError
16+
from botocore.exceptions import ClientError, BotoCoreError
1717

1818
logger = logging.getLogger(__name__)
1919

@@ -57,9 +57,9 @@ def put_config_rule(self, rule_name):
5757
}
5858
)
5959
logger.info("Created configuration rule %s.", rule_name)
60-
except ClientError:
60+
except ClientError as error:
6161
logger.exception("Couldn't create configuration rule %s.", rule_name)
62-
raise
62+
raise error
6363

6464
# snippet-end:[python.example_code.config-service.PutConfigRule]
6565

@@ -77,9 +77,9 @@ def describe_config_rule(self, rule_name):
7777
)
7878
rule = response["ConfigRules"]
7979
logger.info("Got data for rule %s.", rule_name)
80-
except ClientError:
80+
except ClientError as error:
8181
logger.exception("Couldn't get data for rule %s.", rule_name)
82-
raise
82+
raise error
8383
else:
8484
return rule
8585

@@ -95,9 +95,9 @@ def delete_config_rule(self, rule_name):
9595
try:
9696
self.config_client.delete_config_rule(ConfigRuleName=rule_name)
9797
logger.info("Deleted rule %s.", rule_name)
98-
except ClientError:
98+
except ClientError as error:
9999
logger.exception("Couldn't delete rule %s.", rule_name)
100-
raise
100+
raise error
101101

102102

103103
# snippet-end:[python.example_code.config-service.DeleteConfigRule]
@@ -129,9 +129,9 @@ def put_configuration_recorder(self, recorder_name, role_arn, resource_types=Non
129129
}
130130
)
131131
logger.info("Created configuration recorder %s.", recorder_name)
132-
except ClientError:
132+
except ClientError as error:
133133
logger.exception("Couldn't create configuration recorder %s.", recorder_name)
134-
raise
134+
raise error
135135

136136
# snippet-end:[python.example_code.config.PutConfigurationRecorder]
137137

@@ -155,9 +155,9 @@ def put_delivery_channel(self, channel_name, bucket_name, bucket_prefix=None):
155155

156156
self.config_client.put_delivery_channel(DeliveryChannel=delivery_channel)
157157
logger.info("Created delivery channel %s.", channel_name)
158-
except ClientError:
158+
except ClientError as error:
159159
logger.exception("Couldn't create delivery channel %s.", channel_name)
160-
raise
160+
raise error
161161

162162
# snippet-end:[python.example_code.config.PutDeliveryChannel]
163163

@@ -173,9 +173,9 @@ def start_configuration_recorder(self, recorder_name):
173173
ConfigurationRecorderName=recorder_name
174174
)
175175
logger.info("Started configuration recorder %s.", recorder_name)
176-
except ClientError:
176+
except ClientError as error:
177177
logger.exception("Couldn't start configuration recorder %s.", recorder_name)
178-
raise
178+
raise error
179179

180180
# snippet-end:[python.example_code.config.StartConfigurationRecorder]
181181

@@ -198,9 +198,9 @@ def describe_configuration_recorders(self, recorder_names=None):
198198
recorders = response.get('ConfigurationRecorders', [])
199199
logger.info("Got data for %d configuration recorder(s).", len(recorders))
200200
return recorders
201-
except ClientError:
201+
except ClientError as error:
202202
logger.exception("Couldn't get configuration recorder data.")
203-
raise
203+
raise error
204204

205205
# snippet-end:[python.example_code.config.DescribeConfigurationRecorders]
206206

@@ -223,9 +223,9 @@ def describe_configuration_recorder_status(self, recorder_names=None):
223223
statuses = response.get('ConfigurationRecordersStatus', [])
224224
logger.info("Got status for %d configuration recorder(s).", len(statuses))
225225
return statuses
226-
except ClientError:
226+
except ClientError as error:
227227
logger.exception("Couldn't get configuration recorder status.")
228-
raise
228+
raise error
229229

230230
# snippet-end:[python.example_code.config.DescribeConfigurationRecorderStatus]
231231

@@ -246,9 +246,9 @@ def list_discovered_resources(self, resource_type, limit=20):
246246
resources = response.get('resourceIdentifiers', [])
247247
logger.info("Found %d resources of type %s.", len(resources), resource_type)
248248
return resources
249-
except ClientError:
249+
except ClientError as error:
250250
logger.exception("Couldn't list discovered resources of type %s.", resource_type)
251-
raise
251+
raise error
252252

253253
# snippet-end:[python.example_code.config.ListDiscoveredResources]
254254

@@ -271,9 +271,9 @@ def get_resource_config_history(self, resource_type, resource_id, limit=10):
271271
config_items = response.get('configurationItems', [])
272272
logger.info("Got %d configuration items for resource %s.", len(config_items), resource_id)
273273
return config_items
274-
except ClientError:
274+
except ClientError as error:
275275
logger.exception("Couldn't get configuration history for resource %s.", resource_id)
276-
raise
276+
raise error
277277

278278
# snippet-end:[python.example_code.config.GetResourceConfigHistory]
279279

@@ -289,9 +289,9 @@ def stop_configuration_recorder(self, recorder_name):
289289
ConfigurationRecorderName=recorder_name
290290
)
291291
logger.info("Stopped configuration recorder %s.", recorder_name)
292-
except ClientError:
292+
except ClientError as error:
293293
logger.exception("Couldn't stop configuration recorder %s.", recorder_name)
294-
raise
294+
raise error
295295

296296
# snippet-end:[python.example_code.config.StopConfigurationRecorder]
297297

@@ -307,9 +307,9 @@ def delete_configuration_recorder(self, recorder_name):
307307
ConfigurationRecorderName=recorder_name
308308
)
309309
logger.info("Deleted configuration recorder %s.", recorder_name)
310-
except ClientError:
310+
except ClientError as error:
311311
logger.exception("Couldn't delete configuration recorder %s.", recorder_name)
312-
raise
312+
raise error
313313

314314
# snippet-end:[python.example_code.config.DeleteConfigurationRecorder]
315315

@@ -325,9 +325,9 @@ def delete_delivery_channel(self, channel_name):
325325
DeliveryChannelName=channel_name
326326
)
327327
logger.info("Deleted delivery channel %s.", channel_name)
328-
except ClientError:
328+
except ClientError as error:
329329
logger.exception("Couldn't delete delivery channel %s.", channel_name)
330-
raise
330+
raise error
331331

332332
# snippet-end:[python.example_code.config.DeleteDeliveryChannel]
333333
# snippet-end:[python.example_code.config.ConfigWrapper]

0 commit comments

Comments
 (0)