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

No logs/eip with runner_instance_metadata_options_http_tokens set to required #476

Closed
gerbenoostra opened this issue May 2, 2022 · 2 comments
Labels

Comments

@gerbenoostra
Copy link

The current logging & EIP setup in the user_data call the metadata service without tokens, which fails when tokens are set to be required.

If the variable runner_instance_metadata_options_http_tokens is set to "required", the Instance Metadata Service is set to Version 2 (IDMSv2) instead of v1 (IDMSv1).
With runner_instance_metadata_options_http_endpoint = "disabled", the Instance Medadata Service is disabled.

The current logging.tpl uses the IDMSv1 endpoint to retrieve the region and the instance.

Without IDMS this will fail, thus logging can't be setup.

WIth IDMSv2 (when http_options is set to required, but also allowed for optional) these lines should (probably) change to

TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
region=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region)
sed -i -e "s/region = us-east-1/region = $region/g" /etc/awslogs/awscli.conf

instanceId=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .instanceId)
sed -i -e "s/{instanceId}/$instanceId/g" /etc/awslogs/awslogs.conf

I'll see if I find some time to open a merge request, otherwise, maybe just a note in the variable section would suffice.

@kayman-mk
Copy link
Collaborator

IDMSv2 would be nice. There are many issues shown on SecurityHub.

Also check #445

npalm added a commit that referenced this issue May 20, 2022
@npalm npalm closed this as completed in ea94fd5 May 20, 2022
npalm added a commit that referenced this issue May 20, 2022
semantic-releaser bot pushed a commit that referenced this issue May 20, 2022
### [5.0.1](5.0.0...5.0.1) (2022-05-20)

### Bug Fixes

* Pass token to metadata service requests. ([85f59ff](85f59ff)), closes [#476](#476)
@semantic-releaser
Copy link
Contributor

🎉 This issue has been resolved in version 5.0.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

npalm added a commit that referenced this issue Dec 11, 2022
* fix: Pass token to metadata service requests.

close: #476

* docs: fix generation tf docs

* docs: auto update terraform docs

* feat: allow setting runners.docker.services. #489

* add description to new variable

* Comment out docker service in example. Improve docs

* remove accidentally added file

Co-authored-by: Niek Palm <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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