y0zg / ansible-role-aws-rds

Ansible Role to create RDS instances

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Ansible role to create and manage AWS RDS instances.

  • Creates unlimited number of RDS
  • Able to create one param group per RDS instance with custom settings
  • Able to create one RDS subnet per RDS
  • Able to gather VPC subnets for RDS subnets based on filters (tags)
  • Idempotent


  • Ansible 2.5+

Role Variables

Additional variables that can be used (either as host_vars/group_vars or via command line args):

Variable Description
aws_rds_profile Boto profile name to be used
aws_rds_default_region Default region to use

Example Playbook

- hosts: localhost
    - aws-rds
      - name: 'MyTestRDSSubnetGroup'
        region: 'eu-central-1'
        profile: 'playground'
        description: 'My test RDS subnet group'
        vpc_name: 'kubernetes-utilities'
          - filter:
            - key: 'tag:vpc-name'
              val: kubernetes-utilities
      - name: 'My Test RDS Subnet Group2'
        region: 'eu-central-1'
        profile: 'playground' (or set var aws_rds_profile)
        name: 'MyTestRDSSubnetGroup2'
        description: 'My test RDS subnet group number 2'
          - key: 'tag:Name'
            val: my_test_vpc2
          - name: subnet-2-name
          - cidr:
          - filter:
            - key: 'tag:Name'
              val: my-subnet-4-name

Filters when searching for subnets

Filters are applied to the search in a logical AND manner. In other words, if you specify two or more filters, only those subnets that pass all the filters will be returned.

  • availabilityZone - The Availability Zone for the subnet. You can also use availability-zone as the filter name.
  • available-ip-address-count - The number of IPv4 addresses in the subnet that are available.
  • cidrBlock - The IPv4 CIDR block of the subnet. The CIDR block you specify must exactly match the subnet's CIDR block for information to be returned for the subnet. You can also use cidr or cidr-block as the filter names.
  • defaultForAz - Indicates whether this is the default subnet for the Availability Zone. You can also use default-for-az as the filter name.
  • ipv6-cidr-block-association.ipv6-cidr-block - An IPv6 CIDR block associated with the subnet.
  • ipv6-cidr-block-association.association-id - An association ID for an IPv6 CIDR block associated with the subnet.
  • ipv6-cidr-block-association.state - The state of an IPv6 CIDR block associated with the subnet.
  • state - The state of the subnet (pending | available).
  • subnet-id - The ID of the subnet.
  • tag: - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value.
  • tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.
  • vpc-id - The ID of the VPC for the subnet. DO NOT USE. This filter is used by default in the role when searching for subnets for an RDS subnet, to ensure that all subnets to be used are included in the VPC that you specified.

Creating an RDS instances

You must already know which RDS subnet to use when creating an RDS instance.

      region: 'eu-central-1'
      profile: 'playground'
      instance_name: 'myTestRds'
      db_engine: 'MySQL'
      instance_type: 'db.t2.micro'
      username: 'SpongeBobSquarePants'
      password: '<something_best_kept_secret'
      size: 10
      subnet: 'MyTestRDSSubnetGroup'
      zone: 'eu-central-1c'
    name: 'myRDSParamGroup'
      myFirstParam: 1
      mySecondParam: 'hello'
    engine: 'mySQL5.6'


Apache 2.0


Ansible Role to create RDS instances

License:Apache License 2.0


Language:YAML 92.5%Language:Python 5.0%Language:Makefile 2.5%