Welcome, Guest! Registration

loc2log

Thursday, 2024-04-25
Main » 2016 » September » 15 » Get security group group_id for rds vpc_security_groups
8:15 PM
Get security group group_id for rds vpc_security_groups

If you are creating an unique security group for an RDS with ansible in AWS (Elastic Cloud 2). You may have to identify the group_id.

One possible way is to capture the id right after group creation. The group_id will be captured even if there is no new group created. The capture is accomplished by adding register: my_result_var to the end of the action. Of course you can put whatever name you need instead of my_result_var.

For example:
- name: Create RDS security group
  ec2_group:
  description: Allow PostgreSQL
  vpc_id: "{{ my_vpc_id }}"
    ...
    - proto: tcp
    to port: 5432
    cidr_ip:
    state: present
  register: rds_sg_result

- name: Create RDS instance
  rds:
  command: create
  ...
  subnet: "{{ my_subnet }}"
  vpc_security_groups: "{{ rds_sg_result.group_id }}"

Views: 1094 | Added by: ep | Tags: aws, ansible, ec2 | Rating: 0.0/0
Total comments: 0
Only registered users can add comments.
[ Registration | Login ]