Skip to content

Commit 89d8e7e

Browse files
author
awstools
committed
feat(client-ec2): Adds httpTokensEnforced property to ModifyInstanceMetadataDefaults API. Set per account or manage organization-wide using declarative policies to prevent IMDSv1-enabled instance launch and block attempts to enable IMDSv1 on existing IMDSv2-only instances.
1 parent 967c712 commit 89d8e7e

File tree

7 files changed

+63
-4
lines changed

7 files changed

+63
-4
lines changed

clients/client-ec2/src/commands/GetInstanceMetadataDefaultsCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface GetInstanceMetadataDefaultsCommandOutput extends GetInstanceMet
5252
* // InstanceMetadataTags: "disabled" || "enabled",
5353
* // ManagedBy: "account" || "declarative-policy",
5454
* // ManagedExceptionMessage: "STRING_VALUE",
55+
* // HttpTokensEnforced: "disabled" || "enabled",
5556
* // },
5657
* // };
5758
*

clients/client-ec2/src/commands/ModifyInstanceMetadataDefaultsCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface ModifyInstanceMetadataDefaultsCommandOutput extends ModifyInsta
5050
* HttpEndpoint: "disabled" || "enabled" || "no-preference",
5151
* InstanceMetadataTags: "disabled" || "enabled" || "no-preference",
5252
* DryRun: true || false,
53+
* HttpTokensEnforced: "disabled" || "enabled" || "no-preference",
5354
* };
5455
* const command = new ModifyInstanceMetadataDefaultsCommand(input);
5556
* const response = await client.send(command);

clients/client-ec2/src/models/enums.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7397,6 +7397,19 @@ export const PartitionLoadFrequency = {
73977397
*/
73987398
export type PartitionLoadFrequency = (typeof PartitionLoadFrequency)[keyof typeof PartitionLoadFrequency];
73997399

7400+
/**
7401+
* @public
7402+
* @enum
7403+
*/
7404+
export const HttpTokensEnforcedState = {
7405+
disabled: "disabled",
7406+
enabled: "enabled",
7407+
} as const;
7408+
/**
7409+
* @public
7410+
*/
7411+
export type HttpTokensEnforcedState = (typeof HttpTokensEnforcedState)[keyof typeof HttpTokensEnforcedState];
7412+
74007413
/**
74017414
* @public
74027415
* @enum
@@ -7707,6 +7720,21 @@ export const MetadataDefaultHttpTokensState = {
77077720
export type MetadataDefaultHttpTokensState =
77087721
(typeof MetadataDefaultHttpTokensState)[keyof typeof MetadataDefaultHttpTokensState];
77097722

7723+
/**
7724+
* @public
7725+
* @enum
7726+
*/
7727+
export const DefaultHttpTokensEnforcedState = {
7728+
disabled: "disabled",
7729+
enabled: "enabled",
7730+
no_preference: "no-preference",
7731+
} as const;
7732+
/**
7733+
* @public
7734+
*/
7735+
export type DefaultHttpTokensEnforcedState =
7736+
(typeof DefaultHttpTokensEnforcedState)[keyof typeof DefaultHttpTokensEnforcedState];
7737+
77107738
/**
77117739
* @public
77127740
* @enum

clients/client-ec2/src/models/models_6.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
BootModeValues,
1111
CapacityReservationPreference,
1212
CurrencyCodeValues,
13+
DefaultHttpTokensEnforcedState,
1314
DefaultInstanceMetadataEndpointState,
1415
DefaultInstanceMetadataTagsState,
1516
DefaultRouteTableAssociationValue,
@@ -27,6 +28,7 @@ import {
2728
HostnameType,
2829
HostRecovery,
2930
HostTenancy,
31+
HttpTokensEnforcedState,
3032
HttpTokensState,
3133
InstanceAttributeName,
3234
InstanceAutoRecoveryState,
@@ -735,6 +737,14 @@ export interface InstanceMetadataDefaultsResponse {
735737
* @public
736738
*/
737739
ManagedExceptionMessage?: string | undefined;
740+
741+
/**
742+
* <p>Indicates whether to enforce the requirement of IMDSv2 on an instance at the time of
743+
* launch. When enforcement is enabled, the instance can't launch unless IMDSv2
744+
* (<code>HttpTokens</code>) is set to <code>required</code>.</p>
745+
* @public
746+
*/
747+
HttpTokensEnforced?: HttpTokensEnforcedState | undefined;
738748
}
739749

740750
/**
@@ -7984,6 +7994,16 @@ export interface ModifyInstanceMetadataDefaultsRequest {
79847994
* @public
79857995
*/
79867996
DryRun?: boolean | undefined;
7997+
7998+
/**
7999+
* <p>Specifies whether to enforce the requirement of IMDSv2 on an instance at the time of
8000+
* launch. When enforcement is enabled, the instance can't launch unless IMDSv2
8001+
* (<code>HttpTokens</code>) is set to <code>required</code>. For more information, see
8002+
* <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-IMDS-new-instances.html#enforce-imdsv2-at-the-account-level">Enforce IMDSv2 at the account level</a> in the
8003+
* <i>Amazon EC2 User Guide</i>.</p>
8004+
* @public
8005+
*/
8006+
HttpTokensEnforced?: DefaultHttpTokensEnforcedState | undefined;
79878007
}
79888008

79898009
/**

clients/client-ec2/src/schemas/schemas_0.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,7 @@ const _HRo = "HostReservation";
29362936
const _HS = "HibernationSupported";
29372937
const _HSa = "HaStatus";
29382938
const _HT = "HttpTokens";
2939+
const _HTE = "HttpTokensEnforced";
29392940
const _HTo = "HostnameType";
29402941
const _HZI = "HostedZoneId";
29412942
const _Hi = "Hibernate";
@@ -6705,6 +6706,7 @@ const _hS = "hostSet";
67056706
const _hSa = "haStatus";
67066707
const _hSi = "hibernationSupported";
67076708
const _hT = "httpTokens";
6709+
const _hTE = "httpTokensEnforced";
67086710
const _hTo = "hostnameType";
67096711
const _hZI = "hostedZoneId";
67106712
const _i = "id";
@@ -18213,14 +18215,15 @@ export var InstanceMarketOptionsRequest$: StaticStructureSchema = [3, n0, _IMORn
1821318215
];
1821418216
export var InstanceMetadataDefaultsResponse$: StaticStructureSchema = [3, n0, _IMDR,
1821518217
0,
18216-
[_HT, _HPRHL, _HE, _IMT, _MB, _MEM],
18218+
[_HT, _HPRHL, _HE, _IMT, _MB, _MEM, _HTE],
1821718219
[[0, { [_eQN]: `HttpTokens`
1821818220
, [_xN]: _hT }], [1, { [_eQN]: `HttpPutResponseHopLimit`
1821918221
, [_xN]: _hPRHL }], [0, { [_eQN]: `HttpEndpoint`
1822018222
, [_xN]: _hE }], [0, { [_eQN]: `InstanceMetadataTags`
1822118223
, [_xN]: _iMT }], [0, { [_eQN]: `ManagedBy`
1822218224
, [_xN]: _mB }], [0, { [_eQN]: `ManagedExceptionMessage`
18223-
, [_xN]: _mEM }]]
18225+
, [_xN]: _mEM }], [0, { [_eQN]: `HttpTokensEnforced`
18226+
, [_xN]: _hTE }]]
1822418227
];
1822518228
export var InstanceMetadataOptionsRequest$: StaticStructureSchema = [3, n0, _IMORns,
1822618229
0,
@@ -20101,8 +20104,8 @@ export var ModifyInstanceMaintenanceOptionsResult$: StaticStructureSchema = [3,
2010120104
];
2010220105
export var ModifyInstanceMetadataDefaultsRequest$: StaticStructureSchema = [3, n0, _MIMDR,
2010320106
0,
20104-
[_HT, _HPRHL, _HE, _IMT, _DR],
20105-
[0, 1, 0, 0, 2]
20107+
[_HT, _HPRHL, _HE, _IMT, _DR, _HTE],
20108+
[0, 1, 0, 0, 2, 0]
2010620109
];
2010720110
export var ModifyInstanceMetadataDefaultsResult$: StaticStructureSchema = [3, n0, _MIMDRo,
2010820111
0,

clients/client-ec2/test/index-objects.spec.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ import {
884884
DataQuery$,
885885
DataResponse$,
886886
DeclarativePoliciesReport$,
887+
DefaultHttpTokensEnforcedState,
887888
DefaultInstanceMetadataEndpointState,
888889
DefaultInstanceMetadataTagsState,
889890
DefaultRouteTableAssociationValue,
@@ -2745,6 +2746,7 @@ import {
27452746
HostRecovery,
27462747
HostReservation$,
27472748
HostTenancy,
2749+
HttpTokensEnforcedState,
27482750
HttpTokensState,
27492751
HypervisorType,
27502752
IamInstanceProfile$,
@@ -8515,6 +8517,7 @@ assert(typeof CopyTagsFromSource === "object");
85158517
assert(typeof CpuManufacturer === "object");
85168518
assert(typeof CurrencyCodeValues === "object");
85178519
assert(typeof DatafeedSubscriptionState === "object");
8520+
assert(typeof DefaultHttpTokensEnforcedState === "object");
85188521
assert(typeof DefaultInstanceMetadataEndpointState === "object");
85198522
assert(typeof DefaultInstanceMetadataTagsState === "object");
85208523
assert(typeof DefaultRouteTableAssociationValue === "object");
@@ -8578,6 +8581,7 @@ assert(typeof HostMaintenance === "object");
85788581
assert(typeof HostnameType === "object");
85798582
assert(typeof HostRecovery === "object");
85808583
assert(typeof HostTenancy === "object");
8584+
assert(typeof HttpTokensEnforcedState === "object");
85818585
assert(typeof HttpTokensState === "object");
85828586
assert(typeof HypervisorType === "object");
85838587
assert(typeof IamInstanceProfileAssociationState === "object");

clients/client-ec2/test/index-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,7 @@ export type {
23492349
CpuManufacturer,
23502350
CurrencyCodeValues,
23512351
DatafeedSubscriptionState,
2352+
DefaultHttpTokensEnforcedState,
23522353
DefaultInstanceMetadataEndpointState,
23532354
DefaultInstanceMetadataTagsState,
23542355
DefaultRouteTableAssociationValue,
@@ -2412,6 +2413,7 @@ export type {
24122413
HostnameType,
24132414
HostRecovery,
24142415
HostTenancy,
2416+
HttpTokensEnforcedState,
24152417
HttpTokensState,
24162418
HypervisorType,
24172419
IamInstanceProfileAssociationState,

0 commit comments

Comments
 (0)