To close the lop on this.. this was the solution that worked.
---
- include_vars: "{{CONF_DIR}}/auth/AWS/{{account}}.yml"
- name: if craated new vpc, use it ID
  set_fact: VPC_ID="{{CREATED_VPC_ID}}"
  when: CREATED_VPC_ID is defined
- name: Get list of all of the routetables in the vpc
  ec2_vpc_route_table_facts:
    filters:
      vpc-id: "{{VPC_ID}}"
    aws_access_key: "{{AWS_ACCESS_KEY}}"
    aws_secret_key: "{{AWS_SECRET_KEY}}"
    region: "{{ec2_region}}"
    validate_certs: no
  register: vpc_rtbs
- debug: var=vpc_rtbs
- set_fact:
    route_table_ids: "{{ vpc_rtbs.route_tables|map(attribute='id')|list }}"
#- debug: var=vpc_rtbs
- set_fact:
    rtbs_ids:  "{{vpc_rtbs.route_tables}}"
- debug: var="{{item}}"
  with_items: vpc_rtbs.route_tables
- name: Create VPC Endpoint
  ec2_vpc_endpoint:
    aws_access_key: "{{AWS_ACCESS_KEY}}"
    aws_secret_key: "{{AWS_SECRET_KEY}}"
    state: present
    region: "{{ec2_region}}"
    vpc_id: "{{VPC_ID}}"
    service: "com.amazonaws.{{ec2_region}}.s3"
    route_table_ids: "{{route_table_ids}}"
#  with_items:  "{{vpc_rtbs.route_tables}}"
  register: new_vpc_endpoint


On Thu, Nov 16, 2017 at 2:58 PM SN <[email protected]> wrote:

> Hey gang.   Need some help.   I tried multiple ways, nothing seem to work
> exactly as i need/expect.
> I think my question could be generalized better, but let me try it with my
> exact use case.
> So, for a given VPC, i need to add s3 endpoint to every single route
> table.
> The ec2_vpc_endpoint should accept a list of route_table_ids, but for the
> life of me i can not get them fom ec2_vpc_route_table_facts.
> I tried dumping them into a variable, etc -- nothing seems to work
> In the example below, i do get that list and iterate over it -- which
> creates multiple vpc endpoints.   I need one endpoint, added to multiple
> route tables.
>
>
> Any suggestions of how to specify route_table_ids from the
> ec2_vpc_route_table_facts?
> Help would be greatly appretiated.
>
> ---
>
> - name: if craated new vpc, use it ID
>   set_fact: VPC_ID="{{CREATED_VPC_ID}}"
>   when: CREATED_VPC_ID is defined
> - name: Get list of all of the routetables in the vpc
>   ec2_vpc_route_table_facts:
>     filters:
>       vpc-id: "{{VPC_ID}}"
>     aws_access_key: "{{AWS_ACCESS_KEY}}"
>     aws_secret_key: "{{AWS_SECRET_KEY}}"
>     region: "{{ec2_region}}"
>     validate_certs: no
>   register: vpc_rtbs
>
> #- debug: var=vpc_rtbs
> - set_fact:
>     rtbs_ids:  "{{vpc_rtbs.route_tables}}"
> - debug: var="{{item}}"
>   with_items: vpc_rtbs.route_tables
> - name: Create VPC Endpoint
>   ec2_vpc_endpoint:
>     aws_access_key: "{{AWS_ACCESS_KEY}}"
>     aws_secret_key: "{{AWS_SECRET_KEY}}"
>     state: present
>     region: "{{ec2_region}}"
>     vpc_id: "{{VPC_ID}}"
>     service: "com.amazonaws.{{ec2_region}}.s3"
>     route_table_ids: "{{item.id}}"
>   with_items:  "{{vpc_rtbs.route_tables}}"
>   register: new_vpc_endpoint
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/tb6OeERyQhg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/10fae768-813b-40fd-8d75-228c4280d27a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/10fae768-813b-40fd-8d75-228c4280d27a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Thank you



Sergey Nemirovsky

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAHWUH%2B%2B9wZBeFdDfdrwO_3hyQcKHzS0zDVGiSUaB7nxdHrN0kQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to