# THE SOFTWARE. ## import json import boto3 import click from aurora_echo.echo_const import ECHO_NEW_STAGE, ECHO_PROMOTE_COMMAND, ECHO_PROMOTE_STAGE, ECHO_RETIRE_STAGE from aurora_echo.echo_util import EchoUtil, log_prefix_factory, validate_input_param from aurora_echo.entry import root rds = boto3.client('rds') route53 = boto3.client('route53') log_prefix = log_prefix_factory(ECHO_PROMOTE_COMMAND) def find_record_set(hosted_zone_id: str, record_set_name: str): response = route53.list_resource_record_sets(HostedZoneId=hosted_zone_id) record_sets_list = response['ResourceRecordSets'] for record_set in record_sets_list: if record_set['Name'] == record_set_name: return record_set def update_dns(hosted_zone_id: str, record_set: dict, cluster_endpoint: str, ttl: str, interactive: bool): # print out the record we're replacing currently_set_endpoint = 'nothing'
import json from datetime import datetime, timezone import boto3 import click from aurora_echo.echo_const import ECHO_NEW_STAGE, ECHO_NEW_COMMAND from aurora_echo.echo_util import EchoUtil, log_prefix_factory, validate_input_param from aurora_echo.entry import root rds = boto3.client('rds') today_string = '{0:%Y-%m-%d}'.format(datetime.now(timezone.utc)) log_prefix = log_prefix_factory(ECHO_NEW_COMMAND) def find_snapshot(cluster_name: str): response = rds.describe_db_cluster_snapshots(DBClusterIdentifier=cluster_name) snapshot_list = response['DBClusterSnapshots'] # sort/filter by newest and available available_snapshots = [snap for snap in snapshot_list if snap['Status'] == 'available' and snap.get('SnapshotCreateTime')] sorted_snapshot_list = sorted(available_snapshots, key=lambda snap: snap['SnapshotCreateTime'], reverse=True) if sorted_snapshot_list: chosen_cluster_snapshot = sorted_snapshot_list[0] click.echo('{} Located cluster snapshot {}'.format(log_prefix(), chosen_cluster_snapshot['DBClusterSnapshotIdentifier'])) return chosen_cluster_snapshot['DBClusterSnapshotIdentifier']
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ## import json import boto3 import click from aurora_echo.echo_const import ECHO_RETIRE_COMMAND, ECHO_RETIRE_STAGE from aurora_echo.echo_util import EchoUtil, log_prefix_factory, validate_input_param from aurora_echo.entry import root rds = boto3.client('rds') log_prefix = log_prefix_factory(ECHO_RETIRE_COMMAND) def delete_instance(instance: dict, interactive: bool): instance_identifier = instance['DBInstanceIdentifier'] instance_params = { 'DBInstanceIdentifier': instance_identifier, 'SkipFinalSnapshot': True, } cluster_identifier = instance['DBClusterIdentifier'] cluster_params = { 'DBClusterIdentifier': cluster_identifier, 'SkipFinalSnapshot': True, }
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ## import boto3 import click from aurora_echo.echo_const import ECHO_NEW_STAGE, ECHO_MODIFY_COMMAND, ECHO_MODIFY_STAGE from aurora_echo.echo_util import EchoUtil, log_prefix_factory, validate_input_param from aurora_echo.entry import root rds = boto3.client('rds') log_prefix = log_prefix_factory(ECHO_MODIFY_COMMAND) def is_cluster_available(cluster_identifier: str): """ Look up the cluster and make sure it's not currently being created, as we will not be able to modify it yet return if cluster is available for modification """ response = rds.describe_db_clusters(DBClusterIdentifier=cluster_identifier) cluster_map = response['DBClusters'][ 0] # we got the cluster from the instance, so assume it exists return cluster_map['Status'] == 'available'
import json from datetime import datetime, timezone import boto3 import click from aurora_echo.echo_const import ECHO_CLONE_STAGE, ECHO_CLONE_COMMAND from aurora_echo.echo_util import EchoUtil, log_prefix_factory, validate_input_param from aurora_echo.entry import root rds = boto3.client('rds') today_string = '{0:%Y-%m-%d}'.format(datetime.now(timezone.utc)) log_prefix = log_prefix_factory(ECHO_CLONE_COMMAND) def collect_clone_params(source_cluster_name: str, new_cluster_name: str, db_subnet_group_name: str, vpc_security_group_id: list, tags: list): """ Convert parameters into a dict of known values appropriate to be used in an RDS API call. Optional inputs we do not use and therefore do not support yet Port=123, OptionGroupName='string', KmsKeyId='string', EnableIAMDatabaseAuthentication='string', RestoreToTime=datetime(2015, 1, 1),