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


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 
  

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7dd12fbf-4f1f-4bc9-aeb3-878daf79d265%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to