Score:0

Is there a procedure required when baking the Amazon CloudWatch agent into an AMI?

sm flag

I've run into a problem getting the CloudWatch agent started on Windows EC2 instances created from AMIs which I have prepared beforehand. The error I get is this:

Service 'Amazon CloudWatch Agent (AmazonCloudWatchAgent)' cannot be
started due to the following error: Cannot start service
AmazonCloudWatchAgent on computer '.'.

The issue is not what is described in this troubleshooting document, as the service start fails almost immediately. It does not fail after waiting for 30 seconds and I've extended the timeout anyways just in case this was the cause.

The kicker is that I can run my provisioning code to install and configure the CloudWatch Agent on an EC2 instance sourced from an Amazon-provided AMI, with 100% success. Amazon bakes the CloudWatch agent into their base images and I can configure and start CloudWatch fine on those. I have also confirmed I can prepare an image up-to-but-excluding sysprep, restart the node, and configure CloudWatch as expected.

I am able to work around the issue by uninstalling CloudWatch, rebooting, then re-installing. This works for now but I'm trying to find a solution that doesn't add complexity to our automation; other teams can and will be using my base image to create their own base images, and having to remove/reboot/install the agent adds to their automation complexity and increases provisioning time on nodes intended to run workloads.

Baking CloudWatch into an AMI should work, since Amazon is able to do so with their base images. But I cannot find any documentation on how to generalize the service. I have confirmed we are facing this issue on Windows Server 2012r2-2019.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.