Skip to main content

instance_metadata_defaults

Creates, updates, deletes, gets or lists an instance_metadata_defaults resource.

Overview

Nameinstance_metadata_defaults
TypeResource
Idaws.ec2.instance_metadata_defaults

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
http_endpointstringIndicates whether the IMDS endpoint for an instance is enabled or disabled. When disabled, the instance metadata can't be accessed.
http_put_response_hop_limitintegerThe maximum number of hops that the metadata token can travel.
http_tokensstringIndicates whether IMDSv2 is required. optional – IMDSv2 is optional, which means that you can use either IMDSv2 or IMDSv1. required – IMDSv2 is required, which means that IMDSv1 is disabled, and you must use IMDSv2.
http_tokens_enforcedstringIndicates whether to enforce the requirement of IMDSv2 on an instance at the time of launch. When enforcement is enabled, the instance can't launch unless IMDSv2 (HttpTokens) is set to required.
instance_metadata_tagsstringIndicates whether access to instance tags from the instance metadata is enabled or disabled. For more information, see View tags for your EC2 instances using instance metadata in the Amazon EC2 User Guide.
managed_bystringThe entity that manages the IMDS default settings. Possible values include: account - The IMDS default settings are managed by the account. declarative-policy - The IMDS default settings are managed by a declarative policy and can't be modified by the account.
managed_exception_messagestringThe customized exception message that is specified in the declarative policy.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_instance_metadata_defaultsselectregionDryRunGets the default instance metadata service (IMDS) settings that are set at the account level in the specified Amazon Web Services Region. For more information, see Order of precedence for instance metadata options in the Amazon EC2 User Guide.
modify_instance_metadata_defaultsupdateregionHttpTokens, HttpPutResponseHopLimit, HttpEndpoint, InstanceMetadataTags, DryRun, HttpTokensEnforcedModifies the default instance metadata service (IMDS) settings at the account level in the specified Amazon Web Services Region. To remove a parameter's account-level default setting, specify no-preference. If an account-level setting is cleared with no-preference, then the instance launch considers the other instance metadata settings. For more information, see Order of precedence for instance metadata options in the Amazon EC2 User Guide.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)
DryRunbooleanChecks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
HttpEndpointstringEnables or disables the IMDS endpoint on an instance. When disabled, the instance metadata can't be accessed.
HttpPutResponseHopLimitintegerThe maximum number of hops that the metadata token can travel. To indicate no preference, specify -1. Possible values: Integers from 1 to 64, and -1 to indicate no preference
HttpTokensstringIndicates whether IMDSv2 is required. optional – IMDSv2 is optional, which means that you can use either IMDSv2 or IMDSv1. required – IMDSv2 is required, which means that IMDSv1 is disabled, and you must use IMDSv2.
HttpTokensEnforcedstringSpecifies whether to enforce the requirement of IMDSv2 on an instance at the time of launch. When enforcement is enabled, the instance can't launch unless IMDSv2 (HttpTokens) is set to required. For more information, see Enforce IMDSv2 at the account level in the Amazon EC2 User Guide.
InstanceMetadataTagsstringEnables or disables access to an instance's tags from the instance metadata. For more information, see View tags for your EC2 instances using instance metadata in the Amazon EC2 User Guide.

SELECT examples

Gets the default instance metadata service (IMDS) settings that are set at the account level in the specified Amazon Web Services Region. For more information, see Order of precedence for instance metadata options in the Amazon EC2 User Guide.

SELECT
http_endpoint,
http_put_response_hop_limit,
http_tokens,
http_tokens_enforced,
instance_metadata_tags,
managed_by,
managed_exception_message
FROM aws.ec2.instance_metadata_defaults
WHERE region = '{{ region }}' -- required
AND DryRun = '{{ DryRun }}'
;

UPDATE examples

Modifies the default instance metadata service (IMDS) settings at the account level in the specified Amazon Web Services Region. To remove a parameter's account-level default setting, specify no-preference. If an account-level setting is cleared with no-preference, then the instance launch considers the other instance metadata settings. For more information, see Order of precedence for instance metadata options in the Amazon EC2 User Guide.

UPDATE aws.ec2.instance_metadata_defaults
SET
-- No updatable properties
WHERE
region = '{{ region }}' --required
AND HttpTokens = '{{ HttpTokens}}'
AND HttpPutResponseHopLimit = '{{ HttpPutResponseHopLimit}}'
AND HttpEndpoint = '{{ HttpEndpoint}}'
AND InstanceMetadataTags = '{{ InstanceMetadataTags}}'
AND DryRun = {{ DryRun}}
AND HttpTokensEnforced = '{{ HttpTokensEnforced}}'
RETURNING
return;