cloudtrail: Fix error on existing trail without S3 prefix (#2939)

pull/18777/head
Yevgeniy Valeyev 8 years ago committed by Matt Clay
parent d50e2c654f
commit e064fd3256

@ -180,6 +180,7 @@ def main():
s3_bucket_name = module.params['s3_bucket_name'] s3_bucket_name = module.params['s3_bucket_name']
# remove trailing slash from the key prefix, really messes up the key structure. # remove trailing slash from the key prefix, really messes up the key structure.
s3_key_prefix = module.params['s3_key_prefix'].rstrip('/') s3_key_prefix = module.params['s3_key_prefix'].rstrip('/')
include_global_events = module.params['include_global_events'] include_global_events = module.params['include_global_events']
#if module.params['state'] == 'present' and 'ec2_elbs' not in module.params: #if module.params['state'] == 'present' and 'ec2_elbs' not in module.params:
@ -194,7 +195,7 @@ def main():
results['view'] = cf_man.view(ct_name) results['view'] = cf_man.view(ct_name)
# only update if the values have changed. # only update if the values have changed.
if results['view']['S3BucketName'] != s3_bucket_name or \ if results['view']['S3BucketName'] != s3_bucket_name or \
results['view']['S3KeyPrefix'] != s3_key_prefix or \ results['view'].get('S3KeyPrefix', '') != s3_key_prefix or \
results['view']['IncludeGlobalServiceEvents'] != include_global_events: results['view']['IncludeGlobalServiceEvents'] != include_global_events:
if not module.check_mode: if not module.check_mode:
results['update'] = cf_man.update(name=ct_name, s3_bucket_name=s3_bucket_name, s3_key_prefix=s3_key_prefix, include_global_service_events=include_global_events) results['update'] = cf_man.update(name=ct_name, s3_bucket_name=s3_bucket_name, s3_key_prefix=s3_key_prefix, include_global_service_events=include_global_events)

Loading…
Cancel
Save