Repository: ansible-collections/community.aws

Issue:
eks_nodegroup module remote_access config not working as documented
### Summary

When I try to create a nodegroup with remote_access config as documented, I got following error:

`Couldn't create Nodegroup devcluster-eu-central-1a.: Parameter validation failed:
    Unknown parameter in remoteAccess: "ec2_ssh_key", must be one of: ec2SshKey, sourceSecurityGroups
    Unknown parameter in remoteAccess: "source_sg", must be one of: ec2SshKey, sourceSecurityGroups
`

However when I use the suggested camelcase, I get an validation error:

`msg: 'Unsupported parameters for (community.aws.eks_nodegroup) module: remote_access.ec2SshKey, 
  remote_access.sourceSecurityGroups. Supported parameters include: ec2_ssh_key, source_sg.'
`

Think there needs to be a translation from unterscore ansible definition to camelcase from boto in this line, similar to "update_config":
https://github.com/ansible-collections/community.aws/blob/main/plugins/modules/eks_nodegroup.py#L518

I will try to debug further and may provide a PR if successful.

### Issue Type

Bug Report

### Component Name

eks_nodegroup

### Ansible Version

```console (paste below)
$ ansible --version

ansible [core 2.14.3]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
```


### Collection Versions

```console (paste below)
$ ansible-galaxy collection list

community.aws                 5.2.0  
```


### AWS SDK versions

```console (paste below)
$ pip show boto boto3 botocore
Name: boto3
Version: 1.26.95
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: botocore, jmespath, s3transfer
Required-by: 
---
Name: botocore
Version: 1.29.95
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer
```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed
CONFIG_FILE() = None
```


### OS / Environment

```console (paste below)
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
```

### Steps to Reproduce

Using the module quiet normal
```yaml (paste below)
- name: Create nodegroup for internal usage
  community.aws.eks_nodegroup:
    name: "{{ eks_cluster_name }}-{{ item.subnet.availability_zone }}"
    cluster_name: "{{ eks_cluster_name }}"
    node_role: "{{ iam_role_eks_nodegroup.arn }}"
    subnets:
      - "{{ item.subnet.id }}"
    scaling_config: "{{ eks_nodegroup.scaling_config }}"
    update_config:
      max_unavailable: 1
    disk_size: "{{ eks_nodegroup.disk_size }}"
    instance_types: "{{ eks_nodegroup.instance_types }}"
    ami_type: "{{ eks_nodegroup.ami_type }}"
    labels:
      env: "internal"
    capacity_type: "{{ eks_nodegroup.capacity_type }}"
    remote_access:
      ec2_ssh_key: "{{ k8s_admin_keypair.key.id }}"
      source_sg:
        - "{{ k8s_ssh_securitygroup.group_id }}"
    wait: true

```


### Expected Results

No error from boto or the module itself and injected ssh key on all workers

### Actual Results

```console (paste below)
Couldn't create Nodegroup devcluster-eu-central-1a.: Parameter validation failed:
    Unknown parameter in remoteAccess: "ec2_ssh_key", must be one of: ec2SshKey, sourceSecurityGroups
    Unknown parameter in remoteAccess: "source_sg", must be one of: ec2SshKey, sourceSecurityGroups
```


### Code of Conduct

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


Discussion:

Resolving patch:
diff --git a/plugins/modules/eks_nodegroup.py b/plugins/modules/eks_nodegroup.py
--- a/plugins/modules/eks_nodegroup.py
+++ b/plugins/modules/eks_nodegroup.py
@@ -514,7 +514,11 @@ def create_or_update_nodegroups(client, module):
     if module.params['release_version'] is not None:
         params['releaseVersion'] = module.params['release_version']
     if module.params['remote_access'] is not None:
-        params['remoteAccess'] = module.params['remote_access']
+        params['remoteAccess'] = dict()
+        if module.params['remote_access']['ec2_ssh_key'] is not None:
+            params['remoteAccess']['ec2SshKey'] = module.params['remote_access']['ec2_ssh_key']
+        if module.params['remote_access']['source_sg'] is not None:
+            params['remoteAccess']['sourceSecurityGroups'] = module.params['remote_access']['source_sg']
     if module.params['capacity_type'] is not None:
         params['capacityType'] = module.params['capacity_type'].upper()
     if module.params['labels'] is not None:


Test patch:
diff --git a/tests/integration/targets/eks_nodegroup/tasks/cleanup.yml b/tests/integration/targets/eks_nodegroup/tasks/cleanup.yml
--- a/tests/integration/targets/eks_nodegroup/tasks/cleanup.yml
+++ b/tests/integration/targets/eks_nodegroup/tasks/cleanup.yml
@@ -37,6 +37,19 @@
   with_items: '{{ eks_security_groups|reverse|list + additional_eks_sg }}'
   ignore_errors: 'yes'
 
+- name: Delete securitygroup for node access
+  amazon.aws.ec2_security_group:
+    name: 'ansible-test-eks_nodegroup'
+    description: "SSH access"
+    vpc_id: '{{ setup_vpc.vpc.id }}'
+    rules: []
+    state: absent
+
+- name: Delete Keypair for Access to Nodegroup nodes
+  amazon.aws.ec2_key:
+    name: "ansible-test-eks_nodegroup"
+    state: absent
+
 - name: remove Route Tables
   ec2_vpc_route_table:
     state: absent
diff --git a/tests/integration/targets/eks_nodegroup/tasks/dependecies.yml b/tests/integration/targets/eks_nodegroup/tasks/dependecies.yml
--- a/tests/integration/targets/eks_nodegroup/tasks/dependecies.yml
+++ b/tests/integration/targets/eks_nodegroup/tasks/dependecies.yml
@@ -106,3 +106,20 @@
     default_version: 1
     instance_type: t3.micro
   register: lt
+
+- name: Create securitygroup for node access
+  amazon.aws.ec2_security_group:
+    name: 'ansible-test-eks_nodegroup'
+    description: "SSH access"
+    vpc_id: '{{ setup_vpc.vpc.id }}'
+    rules:
+      - proto: tcp
+        ports:
+          - 22
+        cidr_ip: 0.0.0.0/0
+  register: securitygroup_eks_nodegroup
+
+- name: Create Keypair for Access to Nodegroup nodes
+  amazon.aws.ec2_key:
+    name: "ansible-test-eks_nodegroup"
+  register: ec2_key_eks_nodegroup
diff --git a/tests/integration/targets/eks_nodegroup/tasks/full_test.yml b/tests/integration/targets/eks_nodegroup/tasks/full_test.yml
--- a/tests/integration/targets/eks_nodegroup/tasks/full_test.yml
+++ b/tests/integration/targets/eks_nodegroup/tasks/full_test.yml
@@ -80,6 +80,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
   check_mode: True
@@ -114,6 +118,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
 
@@ -147,6 +155,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
   check_mode: True
@@ -181,6 +193,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
   check_mode: True
@@ -255,6 +271,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
   check_mode: True
@@ -289,6 +309,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
 
@@ -322,6 +346,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result
   check_mode: True
@@ -356,6 +384,10 @@
     capacity_type: 'SPOT'
     tags:
       'foo': 'bar'
+    remote_access:
+      ec2_ssh_key: "{{ ec2_key_eks_nodegroup.key.name }}"
+      source_sg:
+        - "{{ securitygroup_eks_nodegroup.group_id }}"
     wait: True
   register: eks_nodegroup_result