Created
October 17, 2018 09:45
-
-
Save TearTheSky/28f90f491a4a28b1dc557a4479f32424 to your computer and use it in GitHub Desktop.
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
#! /usr/bin/env python3 | |
# coding: utf-8 | |
import sys | |
import boto3 | |
import botocore | |
import json | |
from boto3.session import Session | |
from botocore.exceptions import ClientError | |
def one_rds_instance_delete_without_final_snapshot(aws_profile_name, instance_name): | |
try: | |
aws_session = boto3.session.Session(profile_name = aws_profile_name) | |
rds_cli = aws_session.client('rds') | |
response = rds_cli.delete_db_instance( | |
DBInstanceIdentifier = instance_name, | |
SkipFinalSnapshot = False, | |
# FinalDBSnapshotIdentifier='string' | |
) | |
return response | |
except ClientError as e: | |
if e.response['Error']['Code'] == 'DBInstanceNotFound': | |
print("指定したDBインスタンスが存在しません") | |
e.response['Error']['Code'] | |
else: | |
print("Unexpected error: " + str(e.response['Error']['Code'])) | |
if __name__ == "__main__": | |
one_rds_instance_delete_without_final_snapshot(sys.argv[1], sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment