instance_metadata_defaults
Creates, updates, deletes, gets or lists an instance_metadata_defaults resource.
Overview
| Name | instance_metadata_defaults |
| Type | Resource |
| Id | aws.ec2.instance_metadata_defaults |
Fields
The following fields are returned by SELECT queries:
- get_instance_metadata_defaults
| Name | Datatype | Description |
|---|---|---|
http_endpoint | string | Indicates whether the IMDS endpoint for an instance is enabled or disabled. When disabled, the instance metadata can't be accessed. |
http_put_response_hop_limit | integer | The maximum number of hops that the metadata token can travel. |
http_tokens | string | Indicates 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_enforced | string | Indicates 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_tags | string | Indicates 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_by | string | The 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_message | string | The customized exception message that is specified in the declarative policy. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_instance_metadata_defaults | select | region | DryRun | 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. |
modify_instance_metadata_defaults | update | region | HttpTokens, HttpPutResponseHopLimit, HttpEndpoint, InstanceMetadataTags, DryRun, HttpTokensEnforced | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
DryRun | boolean | Checks 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. |
HttpEndpoint | string | Enables or disables the IMDS endpoint on an instance. When disabled, the instance metadata can't be accessed. |
HttpPutResponseHopLimit | integer | The 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 |
HttpTokens | string | Indicates 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. |
HttpTokensEnforced | string | Specifies 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. |
InstanceMetadataTags | string | Enables 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
- get_instance_metadata_defaults
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
- modify_instance_metadata_defaults
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;