# unicode object has no attribute

**URL:** <https://forum.ansible.com/t/unicode-object-has-no-attribute/24416>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [May 8, 2017, 3:36am UTC](https://forum.ansible.com/t/unicode-object-has-no-attribute/24416 "2017-05-08T03:36:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Rhodes](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@Steven\_Rhodes](https://forum.ansible.com/u/Steven_Rhodes)\
**Post date:** [May 8, 2017, 3:36am UTC](https://forum.ansible.com/t/unicode-object-has-no-attribute/24416/1 "2017-05-08T03:36:27Z")

</div>

I am trying to understand the error message “ERROR! ‘unicode object’ has no attribute ‘subnets’”

As shown as an example at [https://docs.ansible.com/ansible/ec2\_vpc\_subnet\_facts\_module.html](https://docs.ansible.com/ansible/ec2_vpc_subnet_facts_module.html)

My Code:

— # EC2 VPC

- hosts: localhost

vars:  
aws\_access\_key: “{{ aws.aws\_access\_key }}”  
aws\_secret\_key: “{{ aws.aws\_secret\_key }}”  
cidr\_block: 10.250.0.0/24  
vpc\_name: Testing  
region: us-west-2  
vpc\_id: vpc-b8599ade

connection: local  
gather\_facts: no  
vars\_files:

- group\_vars/account.yml

tasks:

- name: Get Subnet Facts  
ec2\_vpc\_subnet\_facts:  
aws\_access\_key: “{{ aws\_access\_key }}”  
aws\_secret\_key: “{{ aws\_secret\_key }}”  
region: “{{ region }}”  
filters:  
vpc-id: “{{ vpc\_id }}”  
register: subnet\_facts

- set\_fact:  
subnet\_ids: “{{ subnet\_facts|map(attribute=‘subnets.0.id’)|list }}”

The results:

steven@playbooks$ ansible-playbook myplay.yml

PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Get Subnet Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [set\_fact] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: “ERROR! ‘unicode object’ has no attribute ‘subnets’”}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=1 changed=0 unreachable=0 failed=1
