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

Check if EC2 Metadata service lookup is enabled #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

borisbsu
Copy link

AWS SDK allows to disable EC2 Metadata service lookup.

When it's disabled, we will see such exception stacktrace in the logs:

com.amazonaws.AmazonClientException: EC2 Instance Metadata Service is disabled
	at com.amazonaws.internal.InstanceMetadataServiceResourceFetcher.readResource(InstanceMetadataServiceResourceFetcher.java:65)
	at com.amazonaws.internal.EC2ResourceFetcher.readResource(EC2ResourceFetcher.java:66)
	at com.amazonaws.util.EC2MetadataUtils.getItems(EC2MetadataUtils.java:407)
	at com.amazonaws.util.EC2MetadataUtils.getData(EC2MetadataUtils.java:376)
	at com.amazonaws.util.EC2MetadataUtils.getData(EC2MetadataUtils.java:372)
	at com.amazonaws.util.EC2MetadataUtils.fetchData(EC2MetadataUtils.java:426)
	at com.amazonaws.util.EC2MetadataUtils.fetchData(EC2MetadataUtils.java:420)
	at com.amazonaws.util.EC2MetadataUtils.getInstanceId(EC2MetadataUtils.java:140)
	at com.j256.cloudwatchlogbackappender.CloudWatchAppender$CloudWatchWriter.lookupInstanceName(CloudWatchAppender.java:729)
	at com.j256.cloudwatchlogbackappender.CloudWatchAppender$CloudWatchWriter.createLogsClient(CloudWatchAppender.java:639)
	at com.j256.cloudwatchlogbackappender.CloudWatchAppender$CloudWatchWriter.writeEvents(CloudWatchAppender.java:551)
	at com.j256.cloudwatchlogbackappender.CloudWatchAppender$CloudWatchWriter.run(CloudWatchAppender.java:537)
	at java.base/java.lang.Thread.run(Thread.java:834)

We can add a simple check inside our Appender to verify this case and avoid useless error in logs.

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.

1 participant