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"
with_items: "{{vpc_rtbs.route_tables}}"
register: new_vpc_endpoint