# dict object has no attribute

**URL:** <https://forum.ansible.com/t/dict-object-has-no-attribute/35350>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [June 15, 2021, 12:52pm UTC](https://forum.ansible.com/t/dict-object-has-no-attribute/35350 "2021-06-15T12:52:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [June 15, 2021, 12:52pm UTC](https://forum.ansible.com/t/dict-object-has-no-attribute/35350/1 "2021-06-15T12:52:15Z")

</div>

Hi All,

I am trying to re-create the AWS Core infrastructure using ansible in another region. I am getting the following error

The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘vpc\_endpoints’\n\nThe error appears to be in ‘/home/ec2-user/environment/aws-rxgt-b2b-platform/ansible/rxgt-ps-rxgtb2b-playbook.yaml’: line 646, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: create rxgt-ps-b2b-app-vpc-endpoints changeset\n ^ here\n"}

I tried to debug this by creating a debug statement before this task and it prints out everything. But running this task gives the above error message.

Could someone please help me identify the problem?

Thanks  
Kishore

---

<div class="post-metadata">

**Author:** ![Prasanna\_Kumar](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Prasanna\_Kumar](https://forum.ansible.com/u/Prasanna_Kumar)\
**Post date:** [June 15, 2021, 12:58pm UTC](https://forum.ansible.com/t/dict-object-has-no-attribute/35350/2 "2021-06-15T12:58:57Z")

</div>

Can you provide snapshot of what your task looks like?

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [June 15, 2021, 1:11pm UTC](https://forum.ansible.com/t/dict-object-has-no-attribute/35350/3 "2021-06-15T13:11:15Z")

</div>

Below is the task

- name: create rxgt-ps-b2b-app-vpc-endpoints changeset  
cloudformation\_execute\_changeset:  
stack\_name: “rxgt-ps-b2b-app-vpc-endpoints”  
state: present  
region: “{{ stack\_output\_result.net\_stack\_output\_result.account\_config.1 }}”  
aws\_access\_key: “{{ stack\_output\_result.net\_stack\_output\_result.account\_config.0.sts\_creds.access\_key }}”  
aws\_secret\_key: “{{ stack\_output\_result.net\_stack\_output\_result.account\_config.0.sts\_creds.secret\_key }}”  
security\_token: “{{ stack\_output\_result.net\_stack\_output\_result.account\_config.0.sts\_creds.session\_token }}”  
create\_changeset: true  
execute\_changeset: “{{ with\_stack\_deploy }}”  
changeset\_name: “{{ cf\_changeset\_name }}”  
template\_body: “{{ lookup(‘template’, ‘rxgt-ps-b2b-app-vpc-endpoints.yaml.j2’) }}”  
template\_parameters:  
VPC: “{{ stack\_output\_result.net\_stack\_output\_result.ansible\_facts.cloudformation[‘rxgt-ps-b2b-app-vpc’].stack\_outputs[‘VPC’] }}”  
RouteTables: “{{ (stack\_output\_result.ansible\_facts.cloudformation[‘rxgt-ps-b2b-app-networks’].stack\_outputs[‘PublicRouteTable’], stack\_output\_result.ansible\_facts.cloudformation[‘rxgt-ps-b2b-app-networks’].stack\_outputs[‘PrivatePreprodPrivateRouteTable’], stack\_output\_result.ansible\_facts.cloudformation[‘rxgt-ps-b2b-app-networks’].stack\_outputs[‘PrivateProdPrivateRouteTable’]) | join(‘,’) }}”  
PublicSubnets: “{{ stack\_output\_result.net\_stack\_output\_result.ansible\_facts.cloudformation[‘rxgt-ps-b2b-app-vpc’].stack\_outputs[‘PublicSubnets’] }}”  
SecurityGroupIds: “{{ stack\_output\_result.net\_stack\_output\_result.account\_config.0.account\_config.vpcs[stack\_output\_result.net\_stack\_output\_result.account\_config.1].app.vpc\_endpoints.security\_group\_ids|join(‘,’) }}”  
termination\_protection: no  
tags: “{{ global\_tags | combine(stack\_output\_result.net\_stack\_output\_result.account\_config.0.account\_config.stacks[‘rxgt-ps-b2b-app-vpc-endpoints’].override\_tags, recursive=True) }}”  
loop: “{{ b2b\_app\_networks\_stack\_outputs.results }}”  
loop\_control:  
loop\_var: stack\_output\_result  
label: “{{ stack\_output\_result.net\_stack\_output\_result.account\_config.1 }}”  
register: stack\_changeset\_results  
tags:
- rxgt-ps-b2b-vpc-stack-deploy
- rxgt-ps-b2b-securitygroups

---

<div class="post-metadata">

**Author:** ![Prasanna\_Kumar](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Prasanna\_Kumar](https://forum.ansible.com/u/Prasanna_Kumar)\
**Post date:** [June 15, 2021, 2:12pm UTC](https://forum.ansible.com/t/dict-object-has-no-attribute/35350/4 "2021-06-15T14:12:14Z")

</div>

From your mail , I can see vpc\_endpoints is referenced from stack\_output\_result.

SecurityGroupIds: “{{ **stack\_output\_result**.net\_stack\_output\_result.account\_config.0.account\_config.vpcs[stack\_output\_result.net\_stack\_output\_result.account\_config.1].app. **vpc\_endpoints**.security\_group\_ids|join(‘,’) }}”

And the error you have pinged in the first mail is…

The task includes an option with an undefined variable. **The error was: ‘dict object’ has no attribute ‘vpc\_endpoints’** \n\nThe error appears to be in ‘/home/ec2-user/environment/aws-rxgt-b2b-platform/ansible/rxgt-ps-rxgtb2b-playbook.yaml’: line 646, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: create rxgt-ps-b2b-app-vpc-endpoints changeset\n ^ here\n"}

So, I would suggest you to add a Debug task prior to this one and print the variable stack\_output\_result and go through it to find whether the dict stack\_output\_result is having vpc\_endpoints or not.

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [June 15, 2021, 2:27pm UTC](https://forum.ansible.com/t/dict-object-has-no-attribute/35350/5 "2021-06-15T14:27:42Z")

</div>

Hi,

Thanks for coming back. Yes, I added the debug task before this task and it is printing correctly.

Now I managed to fix this issue by supplying the endpoint SG on the config file which has the endpoints which is what it is expecting.

Thanks again.
