We started using this in 5.4.4 and we are in 5.4.5 right now,
i see the errors in both 5.4.4 and 5.4.5
here is the python code i use to create the Client
import boto3
import botocore.exceptions
import botocore.errorfactory
import time
import datetime
import sys
from pprint import pprint
from operator import itemgetter
from morpheuscypher import Cypher
from tabulate import tabulate
import random
from random import randint
from time import sleep
sleeptime = random.randint(5, 15)
#print(“sleeping for:”, sleeptime, “seconds”)
time.sleep(sleeptime)
#print(“sleeping is over”)
grab current time for role and DB Snapshot names
time_stamp = time.strftime("%Y%m%d-%H%M%S")
input_cloud = morpheus[‘customOptions’][‘RDSCLOUDS’]
#input_role_arn = sys.argv[1]
input_role_arn = Cypher(morpheus=morpheus).get((‘secret/AWS’ + str(input_cloud) + ‘role_arn’))
#pprint(input_role_arn)
def assume_role(role_arn, region):
"""Grabs temporary keys of assumed roles from ARN
Args:
role_arn: ARN of the role you want to assume
region: AWS Region based on Environment selected input_Environemnt
Returns:
temp_key: Temporary key for assumed role
temp_secret: Temporary secret key for assumed role
"""
# set resource and region
client = boto3.client(
'sts',
region_name = region
)
response = client.assume_role(
RoleArn=role_arn,
RoleSessionName='RDSTask' + time_stamp
)
temp_key = response['Credentials']['AccessKeyId']
temp_secret = response['Credentials']['SecretAccessKey']
temp_token = response['Credentials']['SessionToken']
return temp_key, temp_secret, temp_token
def rds_client(temp_key, temp_secret, temp_token, region):
"""Sends Boto3 tasks based on task input
Args:
temp_key: Temporary key from assume_role function
temp_secret: Temporary secret ket from assume_role function
temp_token: Temporary session token from the assume_role function
task: Input task to run corresponding Boto3 task
db_name: Name of RDS to run task against
region: AWS Region based on Environment selected input_Environemnt
Returns:
AWS JSON message
"""
# set resource and region
client = boto3.client(
'rds',
region_name = region,
aws_access_key_id = temp_key,
aws_secret_access_key = temp_secret,
aws_session_token = temp_token
)
return client
def rds_service(task, db_name, client):
# run task based on task input
rds_instances = []
rdsinstances = client.describe_db_instances()
for i in rdsinstances['DBInstances']:
rds_instances.append(i['DBInstanceIdentifier'])
if db_name in rds_instances:
response = "response"
if task == "start":
response = client.start_db_instance(
DBInstanceIdentifier=db_name
)
if task == "stop":
try:
response = client.stop_db_instance(
DBInstanceIdentifier=db_name,
#DBSnapshotIdentifier=db_name+time_stamp