amazon-cloudwatch-agent: onPremise default profile configuration broken
Describe the bug
Commit 6119858864c317ff26f41f576c169148d1250837 changes the config.ModeOnPrem
string from onPremise
to onPrem
, however several programs receive this string as a command-line argument (e.g. config-downloader
) from amazon-cloudwatch-agent-ctl
and fail to recognize the region or credentials as a consequence. For example, config-downloader takes the string onPremise
as its mode
flag, which used to compare equal with config.ModeOnPrem
, but no longer does after this change, which means GetCredentials
no longer sets the credential profile to DEFAULT_PROFILE
.
Steps to reproduce
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -c file:cloudwatch.json -s
where common-config.toml doesn’t contain a credentials
block.
What did you expect to see?
I! SDKRegionWithCredsMap region: us-west-2
or
****** processing amazon-cloudwatch-agent ******
Got Home directory: /root I! Set home dir Linux: /root I! SDKRegionWithCredsMap region: us-west-2 Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_cloudwatch.json.tmp
and so on, which is the output with 1.247354 or with shared credentials explicitly set.
What did you see instead?
Unable to determine aws-region.
or sometimes
****** processing amazon-cloudwatch-agent ******
2022/09/01 19:21:25 E! Please make sure the credentials and region set correctly on your hosts.
depending on the state of existing configuration on the host.
What version did you use?
v1.247355.0. Confirmed that v1.247354.0 works fine.
Environment
Ubuntu 18.04.6 LTS (Bionic Beaver)
Additional context
I recommend either reverting the change, or a patch like this: (note that anything that specifies mode arguments to the programs that consume this string must be adjusted)
diff --git a/packaging/dependencies/amazon-cloudwatch-agent-ctl b/packaging/dependencies/amazon-cloudwatch-agent-ctl
index 5c5fbcf..1e9c722 100755
--- a/packaging/dependencies/amazon-cloudwatch-agent-ctl
+++ b/packaging/dependencies/amazon-cloudwatch-agent-ctl
@@ -514,7 +514,7 @@ main() {
case "${mode}" in
ec2) ;;
- onPremise) ;;
+ onPremise) mode=onPrem ;;
auto) ;;
*)
echo "Invalid mode: ${mode} ${UsageString}" >&2
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 16 (5 by maintainers)
Commits related to this issue
- Automated sync with upstream - last commit 8a17844600e57650a785620363439a26ccaaf1b1 - run #98.1 (#588) — committed to lisguo/amazon-cloudwatch-agent by lisguo 8 months ago
Thanks @ahmgithubahm , it works for me. Save my day
If it helps anyone, here’s a link to the working Windows version: https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/1.247354.0b251981/amazon-cloudwatch-agent.msi
@valof if you are communicating through AWS Support already, that’s the best communication channel to go through.
@stankolubomir and @antoine-sachet It looks like @ymtaye is fixing the issue now. Until then, you should be able to download the previous version with this link: https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/1.247354.0b251981/amazon-cloudwatch-agent.rpm
(amazon_linux / AMD64)
Sorry for the radio silence. We’re discussing this internally on the best approach to mitigate this. @antoine-sachet right now, we don’t explicitly publish how to install older versions of the agent. You should be able to reach out to AWS support in order to get help on downgrading.