Skip to content

Instantly share code, notes, and snippets.

@tomwwright
Last active March 28, 2018 10:18
Show Gist options
  • Save tomwwright/34565d293e7a680531250f47d88d8177 to your computer and use it in GitHub Desktop.
Save tomwwright/34565d293e7a680531250f47d88d8177 to your computer and use it in GitHub Desktop.
ansibled : aurora : tasks : subnet group and default parameter group
# tasks/aurora/setup.parameter-group.yml
# ---
# use the AWS CLI to create a (default) parameter group for Aurora clusters
# list existing cluster parameter groups using the AWS CLI
- name: check for DB cluster parameter group
command: >
aws rds describe-db-cluster-parameter-groups
--no-paginate
--region {{ aws_region }}
changed_when: false
register: db_cluster_parameter_group_query
# search through existing parameter groups to see if our's already exists (idempotence!)
- name: parse DB cluster parameter group query
set_fact:
db_cluster_parameter_group: "{{ db_cluster_parameter_group_query.stdout | from_json | json_query(query)}}"
vars:
query: DBClusterParameterGroups[?DBClusterParameterGroupName=='default-cluster-aurora-5-7'] | [0]
# create the cluster paramter group with the AWS CLI if it doesn't already exist
- name: create DB cluster parameter group
command: >
aws rds create-db-cluster-parameter-group
--db-cluster-parameter-group-name default-cluster-aurora-5-7
--db-parameter-group-family aurora-mysql5.7
--description "Default Aurora MySQL 5.7 cluster parameter group created by Ansible"
--region {{ aws_region }}
when: db_cluster_parameter_group == ''
# tasks/aurora/setup.subnet-group.yml
# ---
# use an Ansible module to configure the subnet group for our cluster
- name: configure DB subnet group
rds_subnet_group:
name: "{{ aurora_cluster_name }}-subnets"
description: "Subnets used by {{ aurora_cluster_name }} Aurora cluster"
subnets: "{{ aurora_cluster_subnet_ids }}"
state: present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment