Enum HttpTokens

java.lang.Object
java.lang.Enum<HttpTokens>
software.amazon.awscdk.services.ec2.HttpTokens
All Implemented Interfaces:
Serializable, Comparable<HttpTokens>, java.lang.constant.Constable

@Generated(value="jsii-pacmak/1.121.0 (build d7af9b9)", date="2025-12-18T18:20:09.191Z") @Stability(Stable) public enum HttpTokens extends Enum<HttpTokens>
The state of token usage for your instance metadata requests.

Example:

 Vpc vpc;
 InstanceType instanceType;
 IMachineImage machineImage;
 // Example 1: Enforce IMDSv2 with comprehensive options
 // Example 1: Enforce IMDSv2 with comprehensive options
 Instance.Builder.create(this, "Instance")
         .vpc(vpc)
         .instanceType(instanceType)
         .machineImage(machineImage)
         .httpEndpoint(true)
         .httpProtocolIpv6(false)
         .httpPutResponseHopLimit(2)
         .httpTokens(HttpTokens.REQUIRED)
         .instanceMetadataTags(true)
         .build();
 // Example 2: Enforce IMDSv2 with minimal configuration
 // Example 2: Enforce IMDSv2 with minimal configuration
 Instance.Builder.create(this, "SecureInstance")
         .vpc(vpc)
         .instanceType(instanceType)
         .machineImage(machineImage)
         .httpTokens(HttpTokens.REQUIRED)
         .build();
 

See Also:
  • Enum Constant Details

    • OPTIONAL

      @Stability(Stable) public static final HttpTokens OPTIONAL
      If the state is optional, you can choose to retrieve instance metadata with or without a signed token header on your request.
    • REQUIRED

      @Stability(Stable) public static final HttpTokens REQUIRED
      If the state is required, you must send a signed token header with any instance metadata retrieval requests.

      In this state, retrieving the IAM role credentials always returns the version 2.0 credentials; the version 1.0 credentials are not available.

  • Method Details

    • values

      public static HttpTokens[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static HttpTokens valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null