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

fix for 1127 Rsyslog IMDSv2 #1161

Merged
merged 3 commits into from
Jun 20, 2023

Conversation

rjjaegeraws
Copy link
Contributor

@rjjaegeraws rjjaegeraws commented Jun 16, 2023

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

The updated userdata for the rsyslog servers will now show:

(note the use of TOKEN)

#!/bin/bash
echo "[v8-stable]
name=Adiscon CentOS-6 - local packages for \$basearch
baseurl=http://rpms.adiscon.com/v8-stable/epel-6/\$basearch
enabled=0
gpgcheck=0
gpgkey=http://rpms.adiscon.com/RPM-GPG-KEY-Adiscon
protect=1" >> /etc/yum.repos.d/rsyslog.repo
yum update -y
yum install -y rsyslog --enablerepo=v8-stable --setopt=v8-stable.priority=1
chkconfig rsyslog on
aws s3 cp s3://asea-management-phase0-configcacentral1-1g9ucir5s5ry0/rsyslog/rsyslog.conf /etc/rsyslog.conf
service rsyslog restart
wget https://s3.ca-central-1.amazonaws.com/amazoncloudwatch-agent-ca-central-1/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
rpm -U ./amazon-cloudwatch-agent.rpm
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
instanceid=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-id)
echo "{\"logs\": {\"logs_collected\": {\"files\": {\"collect_list\": [{\"file_path\": \"/var/log/messages\",\"log_group_name\": \"/ASEA/rsyslog/var/log/messages\",\"log_stream_name\": \"$instanceid\"}]}}}}" >> /opt/aws/amazon-cloudwatch-agent/bin/config.json
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -s -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json

@rjjaegeraws rjjaegeraws linked an issue Jun 16, 2023 that may be closed by this pull request
@rjjaegeraws rjjaegeraws changed the title fix for 1127 Rsyslog imd sv2 fix for 1127 Rsyslog IMDSv2 Jun 16, 2023
Copy link
Collaborator

@archikierstead archikierstead left a comment

Choose a reason for hiding this comment

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

LGTM

@archikierstead archikierstead merged commit 4e72dec into aws-samples:main Jun 20, 2023
@rjjaegeraws rjjaegeraws deleted the rsyslog-IMDSv2 branch June 20, 2023 15:13
archikierstead added a commit that referenced this pull request Jun 22, 2023
* fix for 1127 Rsyslog IMDSv2 (#1161)

* update rsyslog script for IMDSv2

* update script

* update rsyslog to IMDSv2

* Bump aws-cdk-lib in /reference-artifacts/Add-ons/opensiem (#1162)

Bumps [aws-cdk-lib](https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib) from 2.40.0 to 2.80.0.
- [Release notes](https://github.com/aws/aws-cdk/releases)
- [Changelog](https://github.com/aws/aws-cdk/blob/main/CHANGELOG.v2.md)
- [Commits](https://github.com/aws/aws-cdk/commits/v2.80.0/packages/aws-cdk-lib)

---
updated-dependencies:
- dependency-name: aws-cdk-lib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Removing sms endpoint in config.example.json and updating artifacts for certs-samples (#1163)

* added prep to secrets container (#1164)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Ryan Jaeger <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rycerrat-aws <[email protected]>
Co-authored-by: hickeydh-aws <[email protected]>
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.

[BUG][OTHER] configure EC2 to use IMDSv2
2 participants