Repository: ansible-collections/community.aws

Issue:
add support for gp3 volume throughput setting in ec2_lc
### Summary

The ec2_lc module doesn't seem to support the `throughput` parameter for `gp3` volume types. This parameter is supported by `amazon.aws.ec2_vol`.

### Issue Type

Feature Idea

### Component Name

ec2_lc

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
  - name: Create launch configuration
    community.aws.ec2_lc:
      name: lc1
      image_id: ami-xxxx
      instance_type: t4g.nano
      security_groups: "['sg-xxxx']"
      volumes:
      - device_name: /dev/sda1
        volume_size: 100
        volume_type: gp3
        throughput: 250
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/ec2_lc.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_lc.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @garethr @jillr @markuman @s-hertel @tremble @wilvk
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
good one!  
I think ec2_launch_template is also missing this option.

Resolving patch:
diff --git a/plugins/modules/ec2_lc.py b/plugins/modules/ec2_lc.py
--- a/plugins/modules/ec2_lc.py
+++ b/plugins/modules/ec2_lc.py
@@ -107,6 +107,12 @@
         description:
           - The number of IOPS per second to provision for the volume.
           - Required when I(volume_type=io1).
+      throughput:
+        type: int
+        description:
+          - The throughput to provision for a gp3 volume.
+          - Valid Range is a minimum value of 125 and a maximum value of 1000.
+        version_added: 3.1.0
       encrypted:
         type: bool
         default: false
@@ -478,7 +484,7 @@ def create_block_device_meta(module, volume):
     if 'no_device' in volume:
         return_object['NoDevice'] = volume.get('no_device')
 
-    if any(key in volume for key in ['snapshot', 'volume_size', 'volume_type', 'delete_on_termination', 'iops', 'encrypted']):
+    if any(key in volume for key in ['snapshot', 'volume_size', 'volume_type', 'delete_on_termination', 'iops', 'throughput', 'encrypted']):
         return_object['Ebs'] = {}
 
     if 'snapshot' in volume:
@@ -496,6 +502,11 @@ def create_block_device_meta(module, volume):
     if 'iops' in volume:
         return_object['Ebs']['Iops'] = volume.get('iops')
 
+    if 'throughput' in volume:
+        if volume.get('volume_type') != 'gp3':
+            module.fail_json(msg='The throughput parameter is supported only for GP3 volumes.')
+        return_object['Ebs']['Throughput'] = volume.get('throughput')
+
     if 'encrypted' in volume:
         return_object['Ebs']['Encrypted'] = volume.get('encrypted')
 


Test patch:
diff --git a/tests/integration/targets/ec2_lc/tasks/main.yml b/tests/integration/targets/ec2_lc/tasks/main.yml
--- a/tests/integration/targets/ec2_lc/tasks/main.yml
+++ b/tests/integration/targets/ec2_lc/tasks/main.yml
@@ -112,6 +112,58 @@
           - lc_2_create_idem is not changed
           - '"autoscaling:CreateLaunchConfiguration" not in lc_2_create_idem.resource_actions'
 
+    - name: Create launch configuration 3 - test throughput parameter
+      vars:
+        ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}"
+      community.aws.ec2_lc:
+        name: '{{ resource_prefix }}-lc3'
+        image_id: '{{ ec2_ami_id }}'
+        instance_type: '{{ ec2_instance_type }}'
+        volumes:
+          - device_name: /dev/sda1
+            volume_size: 10
+            volume_type: gp3
+            throughput: 250
+            delete_on_termination: true
+      register: lc_3_create
+
+    - name: Gather information about launch configuration 3
+      vars:
+        ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}"
+      community.aws.ec2_lc_info:
+        name: '{{ resource_prefix }}-lc3'
+      register: lc_3_info_result
+
+    - assert:
+        that:
+          - lc_3_create is changed
+          - '"throughput" in lc_3_info_result.launch_configurations[0].block_device_mappings[0].ebs'
+          - lc_3_info_result.launch_configurations[0].block_device_mappings[0].ebs.throughput == 250
+          - lc_3_info_result.launch_configurations[0].block_device_mappings[0].ebs.volume_size == 10
+          - lc_3_info_result.launch_configurations[0].block_device_mappings[0].ebs.volume_type == 'gp3'
+          - lc_3_info_result.launch_configurations[0].instance_type == 't2.micro'
+          - '"autoscaling:CreateLaunchConfiguration" in lc_3_create.resource_actions'
+
+    - name: Create launch configuration 3 - Idempotency
+      vars:
+          ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}"
+      community.aws.ec2_lc:
+        name: '{{ resource_prefix }}-lc3'
+        image_id: '{{ ec2_ami_id }}'
+        instance_type: '{{ ec2_instance_type }}'
+        volumes:
+          - device_name: /dev/sda1
+            volume_size: 10
+            volume_type: gp3
+            throughput: 250
+            delete_on_termination: true
+      register: lc_3_create_idem
+
+    - assert:
+        that:
+          - lc_3_create_idem is not changed
+          - '"autoscaling:CreateLaunchConfiguration" not in lc_3_create_idem.resource_actions'
+
     - name: Search for the Launch Configurations that start with test resource_prefix
       community.aws.ec2_lc_find:
         name_regex: '{{ resource_prefix }}*'
@@ -120,7 +172,7 @@
 
     - assert:
         that:
-          - lc_find_result.results | length == 2
+          - lc_find_result.results | length == 3
           - '"autoscaling:DescribeLaunchConfigurations" in lc_find_result.resource_actions'
 
     - name: Delete launch configuration 1
@@ -187,6 +239,38 @@
           - lc_2_info_result is not changed
           - lc_2_info_result.launch_configurations | length == 0
 
+    - name: Delete launch configuration 3
+      community.aws.ec2_lc:
+        name: '{{ resource_prefix }}-lc3'
+        state: absent
+      register: lc_3_delete
+
+    - assert:
+        that:
+          - lc_3_delete is changed
+          - '"autoscaling:DeleteLaunchConfiguration" in lc_3_delete.resource_actions'
+
+    - name: Delete launch configuration 3 - Idempotency
+      community.aws.ec2_lc:
+        name: '{{ resource_prefix }}-lc3'
+        state: absent
+      register: lc_3_delete_idem
+
+    - assert:
+        that:
+          - lc_3_delete_idem is not changed
+          - '"autoscaling:DeleteLaunchConfiguration" not in lc_3_delete_idem.resource_actions'
+
+    - name: Gather information about launch configuration 3
+      community.aws.ec2_lc_info:
+        name: '{{ resource_prefix }}-lc2'
+      register: lc_3_info_result
+
+    - assert:
+        that:
+          - lc_3_info_result is not changed
+          - lc_3_info_result.launch_configurations | length == 0
+
   always:
 
     - include_tasks: env_cleanup.yml