in awscli/customizations/configservice/subscribe.py [0:0]
def _run_main(self, parsed_args, parsed_globals):
# Setup the necessary all of the necessary clients.
self._setup_clients(parsed_globals)
# Prepare a s3 bucket for use.
s3_bucket_helper = S3BucketHelper(self._s3_client)
bucket, prefix = s3_bucket_helper.prepare_bucket(parsed_args.s3_bucket)
# Prepare a sns topic for use.
sns_topic_helper = SNSTopicHelper(self._sns_client)
sns_topic_arn = sns_topic_helper.prepare_topic(parsed_args.sns_topic)
name = 'default'
# Create a configuration recorder.
self._config_client.put_configuration_recorder(
ConfigurationRecorder={
'name': name,
'roleARN': parsed_args.iam_role
}
)
# Create a delivery channel.
delivery_channel = {
'name': name,
's3BucketName': bucket,
'snsTopicARN': sns_topic_arn
}
if prefix:
delivery_channel['s3KeyPrefix'] = prefix
self._config_client.put_delivery_channel(
DeliveryChannel=delivery_channel)
# Start the configuration recorder.
self._config_client.start_configuration_recorder(
ConfigurationRecorderName=name
)
# Describe the configuration recorders
sys.stdout.write('Subscribe succeeded:\n\n')
sys.stdout.write('Configuration Recorders: ')
response = self._config_client.describe_configuration_recorders()
sys.stdout.write(
json.dumps(response['ConfigurationRecorders'], indent=4))
sys.stdout.write('\n\n')
# Describe the delivery channels
sys.stdout.write('Delivery Channels: ')
response = self._config_client.describe_delivery_channels()
sys.stdout.write(json.dumps(response['DeliveryChannels'], indent=4))
sys.stdout.write('\n')
return 0