[ec2] Use user_data if specified (#54494)

* Use user_data if specified

* changelog
This commit is contained in:
Sloane Hertel 2019-04-09 15:52:49 -04:00 committed by GitHub
parent d53c3cd4f2
commit ba8b5ec0d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- ec2 - Only use user_data if the user has specified a value.
This prevents setting the instance's user data to b'None'.

View file

@ -1070,8 +1070,9 @@ def create_instances(module, ec2, vpc, override_count=None):
'placement': zone,
'instance_type': instance_type,
'kernel_id': kernel,
'ramdisk_id': ramdisk,
'user_data': to_bytes(user_data, errors='surrogate_or_strict')}
'ramdisk_id': ramdisk}
if user_data is not None:
params['user_data'] = to_bytes(user_data, errors='surrogate_or_strict')
if ebs_optimized:
params['ebs_optimized'] = ebs_optimized