diff --git a/changelogs/fragments/55716-ec2_instance_int_volume_size.yml b/changelogs/fragments/55716-ec2_instance_int_volume_size.yml new file mode 100644 index 00000000000..a78c064d9e0 --- /dev/null +++ b/changelogs/fragments/55716-ec2_instance_int_volume_size.yml @@ -0,0 +1,2 @@ +bugfixes: + - ec2_instance - Ensures ``ebs.volume_size`` and ``ebs.iops`` are ``int`` to avoid issues with Jinja2 templating diff --git a/lib/ansible/modules/cloud/amazon/ec2_instance.py b/lib/ansible/modules/cloud/amazon/ec2_instance.py index c186cbbccee..c5822f24f43 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_instance.py +++ b/lib/ansible/modules/cloud/amazon/ec2_instance.py @@ -818,6 +818,11 @@ def manage_tags(match, new_tags, purge_tags, ec2): def build_volume_spec(params): volumes = params.get('volumes') or [] + for volume in volumes: + if 'ebs' in volume: + for int_value in ['volume_size', 'iops']: + if int_value in volume['ebs']: + volume['ebs'][int_value] = int(volume['ebs'][int_value]) return [ec2_utils.snake_dict_to_camel_dict(v, capitalize_first=True) for v in volumes]