Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
# Post to Slack | |
def post_to_slack(channel_id, message_ts, original_message, message_response, response_url): | |
try: | |
slack_data = { | |
"channel":channel_id, | |
"ts":message_ts, | |
"text":original_message, | |
#"attachment_type": "default", | |
"attachments": [ |
This file contains 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
# Stop RDS instances | |
def stop_start_rds(session, inst_name, action, instance_id_or_arn): | |
try: | |
client = session.client('rds', region_name=region) | |
db_instances = client.describe_db_instances(DBInstanceIdentifier=inst_name) | |
# get the instance if it can be found | |
if len(db_instances) != 0: | |
db_instance = db_instances['DBInstances'][0] |
This file contains 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
# Instance tagging function | |
def instance_tagger(action_value, resource_type, instance_id_or_arn, instance_name, user_id): | |
# Slack users | |
# cyoung = @cyoung | |
# user_2 = @user_2 | |
owner_dict = { | |
"cyoung" : "xxxxxxxxx", | |
"user_2" : "zzzzzzzzz" |
This file contains 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
{ | |
"text": message, | |
"channel": slack_owner, | |
"attachments": [ | |
{ | |
"fallback": "Sorry, an error has occured", | |
"callback_id": "instance_reminder", | |
"attachment_type": "default", | |
"actions": [ | |
{ |
This file contains 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
{ | |
"method": "$context.httpMethod", | |
"body" : $input.json('$'), | |
"headers": { | |
#foreach($param in $input.params().header.keySet()) | |
"$param": "$util.escapeJavaScript($input.params().header.get($param))" | |
#if($foreach.hasNext),#end | |
#end | |
} | |
} |
This file contains 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
import boto3 | |
client = boto3.client('lambda') | |
# Invoke Lambda using invocation type: 'Event' | |
response = client.invoke( | |
FunctionName='final_response_lambda', | |
InvocationType='Event', | |
LogType='None', | |
Payload= json.dumps(body), |
This file contains 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
elif action_type == "button" and action_value == "stop": | |
message_response = ":bomb: Stopping *" + str(instance_name) + "*..." | |
message_update = { | |
"channel":channel_id, | |
"ts":message_ts, | |
"text":original_message, | |
#"attachment_type": "default", | |
"attachments": [ | |
{ |
This file contains 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
elif action_type == "select": | |
if action_value == '1': | |
message_response = ":money_with_wings: Reserving *" + str(instance_name) + "* for *" + action_value + "* day..." | |
else: | |
message_response = ":money_with_wings: Reserving *" + str(instance_name) + "* for *" + action_value + "* days..." | |
message_update = { | |
"channel":channel_id, | |
"ts":message_ts, | |
"text":original_message, |
NewerOlder