Repository: ansible/ansible

Issue:
EFS Name is blank when created with ansible efs module
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
efs
##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
$ ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->
Ubuntu 16.04 LTS
##### SUMMARY
<!--- Explain the problem briefly -->
I am using Ansible efs module to create AWS EFS Filesystem. File system gets created but name field is always blank.
##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```
---
- name: install python packages
  pip: name="{{ item }}" state=present
  with_items:
    - Jinja2
    - boto
    - boto3
    - argh

- name: Create EFS fileserver
  efs:
    state: present
    name: "TEST-fileserver-1"
    tags:
      name: "TEST-fileserver-1"
    targets:
      - subnet_id: "REMOVED"
        security_groups: [ "REMOVED" ]
    performance_mode: "general_purpose"
    region: "us-east-1"

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
New EFS file system created
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
New File system gets created but without Name
<!--- Paste verbatim command output between quotes below -->
```
changed: [localhost] => {
    "changed": true, 
    "efs": {
        "creation_time": "2017-04-21 07:55:59+00:00", 
        "creation_token": "TEST-fileserver-1", 
        "file_system_id": "REMOVED", 
        "life_cycle_state": "available", 
        "mount_point": ".REMOVED.efs.us-east-1.amazonaws.com:/", 
        "mount_targets": [
            {
                "file_system_id": "REMOVED", 
                "ip_address": "REMOVED", 
                "life_cycle_state": "available", 
                "mount_target_id": "REMOVED", 
                "network_interface_id": "REMOVED", 
                "owner_id": "REMOVED", 
                "security_groups": [
                    "REMOVED"
                ], 
                "subnet_id": "REMOVED"
            }
        ], 
        "number_of_mount_targets": 1, 
        "owner_id": "REMOVED", 
        "performance_mode": "generalPurpose", 
        "size_in_bytes": {
            "value": 6144
        }, 
        "tags": {
            "name": "TEST-fileserver-1"
        }
    }, 
    "invocation": {
        "module_args": {
            "aws_access_key": null, 
            "aws_secret_key": null, 
            "ec2_url": null, 
            "id": null, 
            "name": "TEST-fileserver-1", 
            "performance_mode": "general_purpose", 
            "profile": null, 
            "region": "us-east-1", 
            "security_token": null, 
            "state": "present", 
            "tags": {
                "name": "TEST-fileserver-1"
            }, 
            "targets": [
                {
                    "security_groups": [
                        "REMOVED"
                    ], 
                    "subnet_id": "REMOVED"
                }
            ], 
            "validate_certs": true, 
            "wait": false, 
            "wait_timeout": 0
        }, 
        "module_name": "efs"
    }
}

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=1    unreachable=0    failed=0   
```

EFS Name is blank when created with ansible efs module
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
efs
##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
$ ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->
Ubuntu 16.04 LTS
##### SUMMARY
<!--- Explain the problem briefly -->
I am using Ansible efs module to create AWS EFS Filesystem. File system gets created but name field is always blank.
##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```
---
- name: install python packages
  pip: name="{{ item }}" state=present
  with_items:
    - Jinja2
    - boto
    - boto3
    - argh

- name: Create EFS fileserver
  efs:
    state: present
    name: "TEST-fileserver-1"
    tags:
      name: "TEST-fileserver-1"
    targets:
      - subnet_id: "REMOVED"
        security_groups: [ "REMOVED" ]
    performance_mode: "general_purpose"
    region: "us-east-1"

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
New EFS file system created
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
New File system gets created but without Name
<!--- Paste verbatim command output between quotes below -->
```
changed: [localhost] => {
    "changed": true, 
    "efs": {
        "creation_time": "2017-04-21 07:55:59+00:00", 
        "creation_token": "TEST-fileserver-1", 
        "file_system_id": "REMOVED", 
        "life_cycle_state": "available", 
        "mount_point": ".REMOVED.efs.us-east-1.amazonaws.com:/", 
        "mount_targets": [
            {
                "file_system_id": "REMOVED", 
                "ip_address": "REMOVED", 
                "life_cycle_state": "available", 
                "mount_target_id": "REMOVED", 
                "network_interface_id": "REMOVED", 
                "owner_id": "REMOVED", 
                "security_groups": [
                    "REMOVED"
                ], 
                "subnet_id": "REMOVED"
            }
        ], 
        "number_of_mount_targets": 1, 
        "owner_id": "REMOVED", 
        "performance_mode": "generalPurpose", 
        "size_in_bytes": {
            "value": 6144
        }, 
        "tags": {
            "name": "TEST-fileserver-1"
        }
    }, 
    "invocation": {
        "module_args": {
            "aws_access_key": null, 
            "aws_secret_key": null, 
            "ec2_url": null, 
            "id": null, 
            "name": "TEST-fileserver-1", 
            "performance_mode": "general_purpose", 
            "profile": null, 
            "region": "us-east-1", 
            "security_token": null, 
            "state": "present", 
            "tags": {
                "name": "TEST-fileserver-1"
            }, 
            "targets": [
                {
                    "security_groups": [
                        "REMOVED"
                    ], 
                    "subnet_id": "REMOVED"
                }
            ], 
            "validate_certs": true, 
            "wait": false, 
            "wait_timeout": 0
        }, 
        "module_name": "efs"
    }
}

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=1    unreachable=0    failed=0   
```



Discussion:
cc @ryansydnor @akazakov
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @ryansydnor @akazakov
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/efs.py b/lib/ansible/modules/cloud/amazon/efs.py
--- a/lib/ansible/modules/cloud/amazon/efs.py
+++ b/lib/ansible/modules/cloud/amazon/efs.py
@@ -243,6 +243,7 @@ def get_file_systems(self, **kwargs):
             **kwargs
         )
         for item in items:
+            item['Name'] = item['CreationToken']
             item['CreationTime'] = str(item['CreationTime'])
             """
             Suffix of network path to be used as NFS device for mount. More detail here:


Test patch: