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
def ssm_command(instances): | |
ssm.send_command( | |
InstanceIds=instances, | |
DocumentName='AWS-RunShellScript', | |
Parameters= { 'commands': ['sudo systemctl stop service'] } | |
) |
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
def lambda_handler(event, context): | |
for record in event['Records']: | |
parsed_event = (json.loads(record["body"])) | |
msg_receipt_handle = str(record['receiptHandle']) | |
if parsed_event.get("LifecycleTransition") == "autoscaling:EC2_INSTANCE_TERMINATING" and parsed_event.get("LifecycleHookName") == "my-service": | |
auto_scaling_group = get_env_variable('ASG_NAME').split()[0] | |
ec2_instance_id = parsed_event.get("EC2InstanceId") | |
delete_sqs_message(msg_receipt_handle) # delete first to avoid infinite loop on unvalid instance ID | |
ssm_command([ec2_instance_id]) # must be an array |
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
SELECT ROUND( (COUNT(t.*) / subTotal.total_radio * 100),2) AS percentage_of_songs, | |
subTotal.total_radio, | |
ROUND(popularity / 10) * 10 AS popularity, | |
t.radio | |
FROM AudioFeatureArtistTrackRadios t | |
JOIN ( | |
SELECT COUNT(*) AS total_radio, radio | |
FROM AudioFeatureArtistTrackRadios | |
GROUP BY radio | |
) AS subTotal |
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
Song(timestamp:Int, humanDate:Long, year:Int, month:Int, day:Int, hour:Int, minute: Int, artist:String, allArtists: String, title:String) |