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

Leaving the Region Value out of amazon-cloudwatch-agent.json #24

Closed
txynidakis opened this issue May 22, 2020 · 3 comments
Closed

Leaving the Region Value out of amazon-cloudwatch-agent.json #24

txynidakis opened this issue May 22, 2020 · 3 comments
Assignees
Labels

Comments

@txynidakis
Copy link

txynidakis commented May 22, 2020

Hi This is my Scenario

We have a golden AMI pipeline in Region A where the CW-A role is used and then copy the AMI to Region B. We bake in the CW-A install to save on launch time.

If we set cwa_aws_region in the playbook in in Region A. Then when we launch the copied AMI in Region B, amazon-cloudwatch-agent.json configs still show the region from Region A.

From the documents https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html, IF, the region is left out, then by DEFAULT the agent will send data to log region in which the EC2 was launch from.

For the moment I've got around the problem by creating a custom file and referenced

  • cwa_conf_json_file_content: "{{ lookup('file', 'files/CloudWatch.json') | from_json }}"

I've tried to have a play

# Remove Region settings from agent configuration file if we need to send data to the region the EC2 was created in
- name: Remove the region reference if None were specified
  lineinfile:
    path: "{{ cwa_agent_config_file }}/amazon-cloudwatch-agent.json"
    state: absent
    regexp: '*region*'
  when: >
    cwa_aws_region | lower == "none"

but couldn't get it working, (haven't spent that much time on it though) and it's probably not an ideal solution.

Can you recommend a way forward to remove the region value from the json file

Kind regards
Tony

@txynidakis txynidakis changed the title Leaving the Region Value amazon-cloudwatch-agent.json Leaving the Region Value out of amazon-cloudwatch-agent.json May 22, 2020
@christiangda
Copy link
Owner

Hi @txynidakis ,

Thank you for your very good explanation and details.

As soon as I can, I'll check your case in order to see how can I handle your case.

@christiangda christiangda self-assigned this May 26, 2020
christiangda added a commit that referenced this issue May 30, 2020
* Improved and updated molecule
* updated travis-ci to use python 3.8
christiangda added a commit that referenced this issue May 30, 2020
christiangda added a commit that referenced this issue May 30, 2020
* Improved and updated molecule
* updated travis-ci to use python 3.8
This was referenced May 30, 2020
christiangda added a commit that referenced this issue May 30, 2020
* Improved and updated molecule
* updated travis-ci to use python 3.8
christiangda added a commit that referenced this issue May 30, 2020
* resolve issue #24
* Improved and updated molecule
* updated travis-ci to use python 3.8
@christiangda
Copy link
Owner

Hi @txynidakis ,

Following your recommendation, I created a patch to support leave the cwa_aws_region empty by default, I tested it, and it is working. Right now I'm releasing the new version

@christiangda christiangda mentioned this issue May 30, 2020
christiangda added a commit that referenced this issue May 30, 2020
* resolve issue #24
* Improved and updated molecule
* updated travis-ci to use python 3.8
@christiangda
Copy link
Owner

resolved in PR#28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants