You can modify the instance metadata options for existing instances.
You can also create an IAM policy that prevents users from modifying the instance metadata options on existing instances. To control which users can modify the instance metadata options, specify a policy that prevents all users other than users with a specified role to use the ModifyInstanceMetadataOptions API. For the example IAM policy, see Work with instance metadata.
NoteIf a declarative policy was used to configure the instance metadata options, you can't modify them directly within the account. For more information, see Declarative policies in the AWS Organizations User Guide.
Require the use of IMDSv2Use one of the following methods to modify the instance metadata options on an existing instance to require that IMDSv2 is used when requesting instance metadata. When IMDSv2 is required, IMDSv1 cannot be used.
NoteBefore requiring that IMDSv2 is used, ensure that the instance isn't making IMDSv1 calls. The MetadataNoToken
CloudWatch metric tracks IMDSv1 calls. When MetadataNoToken
records zero IMDSv1 usage for an instance, the instance is then ready to require IMDSv2.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Instances.
Select your instance.
Choose Actions, Instance settings, Modify instance metadata options.
In the Modify instance metadata options dialog box, do the following:
For Instance metadata service, select Enable.
For IMDSv2, choose Required.
Choose Save.
Use the modify-instance-metadata-options CLI command and set the http-tokens
parameter to required
. When you specify a value for http-tokens
, you must also set http-endpoint
to enabled
.
aws ec2 modify-instance-metadata-options \
--instance-id i-1234567890abcdef0
\
--http-tokens required \
--http-endpoint enabled
Use the Edit-EC2InstanceMetadataOption Cmdlet and set the HttpTokens
parameter to required
. When you specify a value for HttpTokens
, you must also set HttpEndpoint
to enabled
.
(Edit-EC2InstanceMetadataOption `
-InstanceId i-1234567890abcdef0
`
-HttpTokens required `
-HttpEndpoint enabled).InstanceMetadataOptions
When IMDSv2 is required, IMDSv1 will not work when requesting instance metadata. When IMDSv2 is optional, then both IMDSv2 and IMDSv1 will work. Therefore, to restore IMDSv1, make IMDSv2 optional by using one of the following methods.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Instances.
Select your instance.
Choose Actions, Instance settings, Modify instance metadata options.
In the Modify instance metadata options dialog box, do the following:
For Instance metadata service, make sure that Enable is selected.
For IMDSv2, choose Optional.
Choose Save.
You can use the modify-instance-metadata-options CLI command with http-tokens
set to optional
to restore the use of IMDSv1 when requesting instance metadata.
aws ec2 modify-instance-metadata-options \
--instance-id i-1234567890abcdef0
\
--http-tokens optional \
--http-endpoint enabled
You can use the Edit-EC2InstanceMetadataOption Cmdlet with HttpTokens
set to optional
to restore the use of IMDSv1 when requesting instance metadata.
(Edit-EC2InstanceMetadataOption `
-InstanceId i-1234567890abcdef0
`
-HttpTokens optional `
-HttpEndpoint enabled).InstanceMetadataOptions
For existing instances, you can change the settings of the PUT
response hop limit.
Currently only the AWS CLI and AWS SDKs support changing the PUT response hop limit.
Use the modify-instance-metadata-options CLI command and set the http-put-response-hop-limit
parameter to the required number of hops. In the following example, the hop limit is set to 3
. Note that when specifying a value for http-put-response-hop-limit
, you must also set http-endpoint
to enabled
.
aws ec2 modify-instance-metadata-options \
--instance-id i-1234567890abcdef0
\
--http-put-response-hop-limit 3
\
--http-endpoint enabled
Use the Edit-EC2InstanceMetadataOption Cmdlet and set the HttpPutResponseHopLimit
parameter to the required number of hops. In the following example, the hop limit is set to 3
. Note that when specifying a value for HttpPutResponseHopLimit
, you must also set HttpEndpoint
to enabled
.
(Edit-EC2InstanceMetadataOption `
-InstanceId i-1234567890abcdef0
`
-HttpPutResponseHopLimit 3 `
-HttpEndpoint enabled).InstanceMetadataOptions
The IMDS has two endpoints on an instance: IPv4 (169.254.169.254
) and IPv6 ([fd00:ec2::254]
). When you enable the IMDS, the IPv4 endpoint is automatically enabled. The IPv6 endpoint remains disabled even if you launch an instance into an IPv6-only subnet. To enable the IPv6 endpoint, you need to do so explicitly. When you enable the IPv6 endpoint, the IPv4 endpoint remains enabled.
You can enable the IPv6 endpoint at instance launch or after.
Currently only the AWS CLI and AWS SDKs support enabling the IMDS IPv6 endpoint after instance launch.
Use the modify-instance-metadata-options CLI command and set the http-protocol-ipv6
parameter to enabled
. Note that when specifying a value for http-protocol-ipv6
, you must also set http-endpoint
to enabled
.
aws ec2 modify-instance-metadata-options \
--instance-id i-1234567890abcdef0
\
--http-protocol-ipv6 enabled \
--http-endpoint enabled
Use the Edit-EC2InstanceMetadataOption Cmdlet and set the HttpProtocolIpv6
parameter to enabled
. Note that when specifying a value for HttpProtocolIpv6
, you must also set HttpEndpoint
to enabled
.
(Edit-EC2InstanceMetadataOption `
-InstanceId i-1234567890abcdef0
`
-HttpProtocolIpv6 enabled `
-HttpEndpoint enabled).InstanceMetadataOptions
You can turn on access to instance metadata by enabling the HTTP endpoint of the IMDS on your instance, regardless of which version of the IMDS you are using. You can reverse this change at any time by disabling the HTTP endpoint.
Use one of the following methods to turn on access to instance metadata on an instance.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Instances.
Select your instance.
Choose Actions, Instance settings, Modify instance metadata options.
In the Modify instance metadata options dialog box, do the following:
For Instance metadata service, select Enable.
Choose Save.
Use the modify-instance-metadata-options CLI command and set the http-endpoint
parameter to enabled
.
aws ec2 modify-instance-metadata-options \
--instance-id i-1234567890abcdef0
\
--http-endpoint enabled
Use the Edit-EC2InstanceMetadataOption Cmdlet and set the HttpEndpoint
parameter to enabled
.
(Edit-EC2InstanceMetadataOption `
-InstanceId i-1234567890abcdef0
`
-HttpEndpoint enabled).InstanceMetadataOptions
You can turn off access to instance metadata by disabling the HTTP endpoint of the IMDS on your instance, regardless of which version of the IMDS you are using. You can reverse this change at any time by enabling the HTTP endpoint.
Use one of the following methods to turn off access to instance metadata on an instance.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Instances.
Select your instance.
Choose Actions, Instance settings, Modify instance metadata options.
In the Modify instance metadata options dialog box, do the following:
For Instance metadata service, clear Enable.
Choose Save.
Use the modify-instance-metadata-options CLI command and set the http-endpoint
parameter to disabled
.
aws ec2 modify-instance-metadata-options \
--instance-id i-1234567890abcdef0
\
--http-endpoint disabled
Use the Edit-EC2InstanceMetadataOption Cmdlet and set the HttpEndpoint
parameter to disabled
.
(Edit-EC2InstanceMetadataOption `
-InstanceId i-1234567890abcdef0
`
-HttpEndpoint disabled).InstanceMetadataOptions
You can allow access to tags in the instance metadata on a running or stopped instance. For each instance, you must explicitly allow access. If access is allowed, instance tag keys must comply with specific character restrictions, otherwise you get an error. For more information, see Enable access to tags in instance metadata.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4