Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows Start Agent With EC2 Run Command #378

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

sethAmazon
Copy link
Contributor

Description of the issue

There is no test that tests starting the Cloudwatch agent with ssm commands on windows. This could be a problem since on windows it will fail if it logs to standard error on startup.

Description of changes

Add a test for starting the agent on windows with ssm commands.

aws ssm send-command --document-name AmazonCloudWatch-ManageAgent --parameters optionalConfigurationLocation=${local.ssm_parameter_name} --targets Key=tag:Name,Values=cwagent-integ-test-ec2-windows-${var.test_name}-${module.common.testing_id}

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

https://github.com/aws/amazon-cloudwatch-agent/actions/runs/6882426811/job/18721347139
Integration tests

@sethAmazon sethAmazon requested a review from a team as a code owner November 15, 2023 21:30
targets: map[string]map[string]struct{}{"os": {"win-2019": {}}},
},
{
testDir: "../../../test/feature/windows/custom_start/ssm_start",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an exception case where we only need to test starting the agent with ssm commands, I think it is fine to only run on a single os.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a sanity test the agent can start and get metrics.

//runs validator and sets up prometheus java agent
provisioner "remote-exec" {
inline = [
"set AWS_REGION=${var.region}",
"validator.exe --validator-config=${module.validator.instance_validator_config} --preparation-mode=true",
"powershell.exe \"& \"C:ProgramFiles\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1\" -m ec2 -a status\"",
"powershell.exe \"& 'C:ProgramFiles\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1' -m ec2 -a status\"",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not use double quotes here to get status check

provisioner "remote-exec" {
inline = [
"set AWS_REGION=${var.region}",
"aws ssm send-command --document-name AmazonCloudWatch-ManageAgent --parameters optionalConfigurationLocation=${local.ssm_parameter_name} --targets Key=tag:Name,Values=cwagent-integ-test-ec2-windows-${var.test_name}-${module.common.testing_id}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssm command to start the agent with the config file uploaded to ssm parameters

Copy link
Contributor

@okankoAMZ okankoAMZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@sethAmazon sethAmazon merged commit e133db3 into aws:main Nov 17, 2023
2 checks passed
@sethAmazon sethAmazon deleted the start-cwa-win-with-ssm branch November 17, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants