Created
March 28, 2018 11:24
-
-
Save tomwwright/d6f285afc66ee53427721d949b315f00 to your computer and use it in GitHub Desktop.
ansibled : aurora : tasks : aurora database instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "DBInstanceIdentifier": "{{ aurora_db_name }}", | |
| "DBInstanceClass": "{{ aurora_instance_type }}", | |
| "Engine": "aurora-mysql", | |
| "AvailabilityZone": "{{ aurora_availability_zone }}", | |
| "DBSubnetGroupName": "{{ aurora_cluster_name }}-subnets", | |
| "PreferredMaintenanceWindow": "mon:11:00-mon:11:30", | |
| "MultiAZ": false, | |
| "AutoMinorVersionUpgrade": true, | |
| "LicenseModel": "general-public-license", | |
| "PubliclyAccessible": false, | |
| "Tags": [], | |
| "DBClusterIdentifier": "{{ aurora_cluster_name }}", | |
| "PromotionTier": {{ aurora_promotion_tier | default('1') }} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # look for an existing Aurora DB instance for this host using the AWS CLI | |
| - name: check for Aurora DB instance | |
| command: aws rds describe-db-instances --filters Name=db-instance-id,Values={{ aurora_db_name }} --region {{ aws_region }} | |
| changed_when: false | |
| register: aurora_instance_query | |
| - name: parse Aurora DB instance query | |
| set_fact: | |
| aurora_instance: "{{ aurora_instance_query.stdout | from_json | json_query('DBInstances[0]')}}" | |
| # create the instance if it doesn't exist -- passing config as JSON from a Jinja2 template | |
| - name: create Aurora DB instance | |
| command: aws rds create-db-instance --region {{ aws_region }} --cli-input-json '{{ lookup('template', 'files/create-db-instance.json.j2') | to_json }}' | |
| when: aurora_instance == '' | |
| register: aurora_instance_create | |
| - name: parse Aurora DB instance query | |
| set_fact: | |
| aurora_instance: "{{ aurora_instance_create.stdout | from_json | json_query('DBInstance')}}" | |
| when: aurora_instance == '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment