Class ImdsUtils

java.lang.Object
io.awspring.cloud.autoconfigure.imds.ImdsUtils

public class ImdsUtils extends Object
Utility object for working with EC2 instance metadata service (IDMS). Determines if the service and its data are available and provides utility methods for loading a PropertySource. Instance metadata is generally available - with exceptions - when an application is running within EC2, Elastic Beanstalk, ECS, EKS, etc. The presence of instance metadata can be used as a general indicator of whether an application is running within the AWS cloud or on a local environment, however there are exceptions to the general principal, such as when EC2 instance deliberately disables IMDS. Non-EC2 compute environments such as Lambda or Fargate do not provide the IMDS service. Works with either IMDS v1 or v2.
Since:
3.1.0
Author:
Ken Krueger
  • Constructor Details

    • ImdsUtils

      public ImdsUtils(software.amazon.awssdk.imds.Ec2MetadataClient client)
  • Method Details

    • isRunningOnCloudEnvironment

      public boolean isRunningOnCloudEnvironment()
    • getEc2InstanceMetadata

      public Map<String,String> getEc2InstanceMetadata()
      Load EC2 Instance Metadata into a simple Map structure, suitable for use populating a PropertySource.
      Returns:
      Map of metadata properties. Empty Map if instance metadata is not available.
      See Also: