0

I'm working with a legacy Adobe ColdFusion stack (there are plans to redevelop using something more contemporary), and we have an issue whereby very occasionally, the CPU will spike and we need to restart ColdFusion and IIS on the Windows EC2 host.

I have some CloudWatch Alarms which trigger lambda functions that I found and adapted to send a Slack notifications. If I'm around, or the developers (I'm very much ops, but trying to understand more dev stuff as time goes on), one of us will jump on the server and restart the service, collect the logs, and the devs can use it to try and narrow down why it happens.

What I would like is another alarm which triggers maybe 15 minutes after the first one, to call the AWS-RunRemoteScript document in SSM, which runs a powershell script stored in S3 which simply stops and starts the services in the right order (restart doesn't work - I've found we need to stop CF, stop IIS, and then bring them back up in that order).

I have used that Run Command with RunRemoteScript, and it works a treat. What I'm really struggling with it how to make a lambda function call SSM and have it run that automation for me. I have searched high and low, but the few resources I have found are too complex for my extremely limited grasp of programming.

Please can someone help me out by showing me or pointing me to a resource which can walk me through creating a Lambda script (preferably in Python, since I am actively trying to learn it) to call SSM and within that, the RunCommand for AWS-RunRemoteScript, how to plug in the parameters (script location etc.) and make it work?

  • Are these instances in an auto scaling group? If so, best bet is to terminate them based on a health check. – Rodrigo Murillo Sep 08 '19 at 16:18
  • Thank you so much for your input Rodrigo. Unfortunately though, this kit is very much brownfield, and we just need to nurse it on for another few months until we build much better infrastructure on proper cloud technologies. I don't have a build script or template for this server, and it would be missed if terminated and re-created. – AdminDogg Sep 08 '19 at 18:06
  • Take a look at Step Functions, or, at 15 minutes you could do this with an SQS delay queue (maximum delay is 15 minutes), or, DynamoDB streams with Lambda triggers with TTL expiration to trigger the Lambda. – hephalump Sep 08 '19 at 19:32
  • Got it thanks @AdminDogg But to be clear... it runs on a single server today? – Rodrigo Murillo Sep 09 '19 at 18:10
  • That's right @RodrigoM, single server, bad times if it blows up. :) – AdminDogg Sep 10 '19 at 16:48

0 Answers0