Skip to content

Commit

Permalink
feat(client-ec2): Added support for using NitroTPM and UEFI Secure Bo…
Browse files Browse the repository at this point in the history
…ot on EC2 instances.
  • Loading branch information
awstools committed May 10, 2022
1 parent 930c904 commit 2ad1bbf
Show file tree
Hide file tree
Showing 13 changed files with 814 additions and 325 deletions.
46 changes: 46 additions & 0 deletions clients/client-ec2/src/EC2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,11 @@ import {
GetInstanceTypesFromInstanceRequirementsCommandInput,
GetInstanceTypesFromInstanceRequirementsCommandOutput,
} from "./commands/GetInstanceTypesFromInstanceRequirementsCommand";
import {
GetInstanceUefiDataCommand,
GetInstanceUefiDataCommandInput,
GetInstanceUefiDataCommandOutput,
} from "./commands/GetInstanceUefiDataCommand";
import {
GetIpamAddressHistoryCommand,
GetIpamAddressHistoryCommandInput,
Expand Down Expand Up @@ -16044,6 +16049,47 @@ export class EC2 extends EC2Client {
}
}

/**
* <p>A binary representation of the UEFI variable store. Only non-volatile variables are
* stored. This is a base64 encoded and zlib compressed binary value that must be properly
* encoded.</p>
* <p>When you use <a href="https://docs.aws.amazon.com/cli/latest/reference/ec2/register-image.html">register-image</a>
* to create an AMI, you can create an exact copy of your variable store by passing the UEFI data in the <code>UefiData</code>
* parameter. You can modify the UEFI data by using the <a href="https://github.com/awslabs/python-uefivars">python-uefivars tool</a>
* on GitHub. You can use the tool to convert the UEFI data into a human-readable format (JSON), which you can
* inspect and modify, and then convert back into the binary format to use with register-image.</p>
* <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/uefi-secure-boot.html">UEFI Secure Boot</a> in the
* <i>Amazon EC2 User Guide</i>.</p>
*/
public getInstanceUefiData(
args: GetInstanceUefiDataCommandInput,
options?: __HttpHandlerOptions
): Promise<GetInstanceUefiDataCommandOutput>;
public getInstanceUefiData(
args: GetInstanceUefiDataCommandInput,
cb: (err: any, data?: GetInstanceUefiDataCommandOutput) => void
): void;
public getInstanceUefiData(
args: GetInstanceUefiDataCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetInstanceUefiDataCommandOutput) => void
): void;
public getInstanceUefiData(
args: GetInstanceUefiDataCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetInstanceUefiDataCommandOutput) => void),
cb?: (err: any, data?: GetInstanceUefiDataCommandOutput) => void
): Promise<GetInstanceUefiDataCommandOutput> | void {
const command = new GetInstanceUefiDataCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Retrieve historical information about a CIDR within an IPAM scope. For more information, see <a href="/vpc/latest/ipam/view-history-cidr-ipam.html">View the history of IP addresses</a> in the <i>Amazon VPC IPAM User Guide</i>.</p>
*/
Expand Down
6 changes: 6 additions & 0 deletions clients/client-ec2/src/EC2Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,10 @@ import {
GetInstanceTypesFromInstanceRequirementsCommandInput,
GetInstanceTypesFromInstanceRequirementsCommandOutput,
} from "./commands/GetInstanceTypesFromInstanceRequirementsCommand";
import {
GetInstanceUefiDataCommandInput,
GetInstanceUefiDataCommandOutput,
} from "./commands/GetInstanceUefiDataCommand";
import {
GetIpamAddressHistoryCommandInput,
GetIpamAddressHistoryCommandOutput,
Expand Down Expand Up @@ -2165,6 +2169,7 @@ export type ServiceInputTypes =
| GetGroupsForCapacityReservationCommandInput
| GetHostReservationPurchasePreviewCommandInput
| GetInstanceTypesFromInstanceRequirementsCommandInput
| GetInstanceUefiDataCommandInput
| GetIpamAddressHistoryCommandInput
| GetIpamPoolAllocationsCommandInput
| GetIpamPoolCidrsCommandInput
Expand Down Expand Up @@ -2689,6 +2694,7 @@ export type ServiceOutputTypes =
| GetGroupsForCapacityReservationCommandOutput
| GetHostReservationPurchasePreviewCommandOutput
| GetInstanceTypesFromInstanceRequirementsCommandOutput
| GetInstanceUefiDataCommandOutput
| GetIpamAddressHistoryCommandOutput
| GetIpamPoolAllocationsCommandOutput
| GetIpamPoolCidrsCommandOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
} from "@aws-sdk/types";

import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client";
import { GetFlowLogsIntegrationTemplateRequest } from "../models/models_4";
import { GetFlowLogsIntegrationTemplateResult } from "../models/models_5";
import { GetFlowLogsIntegrationTemplateRequest, GetFlowLogsIntegrationTemplateResult } from "../models/models_5";
import {
deserializeAws_ec2GetFlowLogsIntegrationTemplateCommand,
serializeAws_ec2GetFlowLogsIntegrationTemplateCommand,
Expand Down
105 changes: 105 additions & 0 deletions clients/client-ec2/src/commands/GetInstanceUefiDataCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client";
import { GetInstanceUefiDataRequest, GetInstanceUefiDataResult } from "../models/models_5";
import {
deserializeAws_ec2GetInstanceUefiDataCommand,
serializeAws_ec2GetInstanceUefiDataCommand,
} from "../protocols/Aws_ec2";

export interface GetInstanceUefiDataCommandInput extends GetInstanceUefiDataRequest {}
export interface GetInstanceUefiDataCommandOutput extends GetInstanceUefiDataResult, __MetadataBearer {}

/**
* <p>A binary representation of the UEFI variable store. Only non-volatile variables are
* stored. This is a base64 encoded and zlib compressed binary value that must be properly
* encoded.</p>
* <p>When you use <a href="https://docs.aws.amazon.com/cli/latest/reference/ec2/register-image.html">register-image</a>
* to create an AMI, you can create an exact copy of your variable store by passing the UEFI data in the <code>UefiData</code>
* parameter. You can modify the UEFI data by using the <a href="https://github.com/awslabs/python-uefivars">python-uefivars tool</a>
* on GitHub. You can use the tool to convert the UEFI data into a human-readable format (JSON), which you can
* inspect and modify, and then convert back into the binary format to use with register-image.</p>
* <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/uefi-secure-boot.html">UEFI Secure Boot</a> in the
* <i>Amazon EC2 User Guide</i>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { EC2Client, GetInstanceUefiDataCommand } from "@aws-sdk/client-ec2"; // ES Modules import
* // const { EC2Client, GetInstanceUefiDataCommand } = require("@aws-sdk/client-ec2"); // CommonJS import
* const client = new EC2Client(config);
* const command = new GetInstanceUefiDataCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link GetInstanceUefiDataCommandInput} for command's `input` shape.
* @see {@link GetInstanceUefiDataCommandOutput} for command's `response` shape.
* @see {@link EC2ClientResolvedConfig | config} for EC2Client's `config` shape.
*
*/
export class GetInstanceUefiDataCommand extends $Command<
GetInstanceUefiDataCommandInput,
GetInstanceUefiDataCommandOutput,
EC2ClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: GetInstanceUefiDataCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: EC2ClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<GetInstanceUefiDataCommandInput, GetInstanceUefiDataCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "EC2Client";
const commandName = "GetInstanceUefiDataCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetInstanceUefiDataRequest.filterSensitiveLog,
outputFilterSensitiveLog: GetInstanceUefiDataResult.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: GetInstanceUefiDataCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_ec2GetInstanceUefiDataCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetInstanceUefiDataCommandOutput> {
return deserializeAws_ec2GetInstanceUefiDataCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
3 changes: 2 additions & 1 deletion clients/client-ec2/src/commands/RequestSpotFleetCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
} from "@aws-sdk/types";

import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client";
import { RequestSpotFleetRequest, RequestSpotFleetResponse } from "../models/models_5";
import { RequestSpotFleetRequest } from "../models/models_5";
import { RequestSpotFleetResponse } from "../models/models_6";
import {
deserializeAws_ec2RequestSpotFleetCommand,
serializeAws_ec2RequestSpotFleetCommand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
} from "@aws-sdk/types";

import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client";
import { RequestSpotInstancesRequest } from "../models/models_5";
import { RequestSpotInstancesResult } from "../models/models_6";
import { RequestSpotInstancesRequest, RequestSpotInstancesResult } from "../models/models_6";
import {
deserializeAws_ec2RequestSpotInstancesCommand,
serializeAws_ec2RequestSpotInstancesCommand,
Expand Down
1 change: 1 addition & 0 deletions clients/client-ec2/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export * from "./GetFlowLogsIntegrationTemplateCommand";
export * from "./GetGroupsForCapacityReservationCommand";
export * from "./GetHostReservationPurchasePreviewCommand";
export * from "./GetInstanceTypesFromInstanceRequirementsCommand";
export * from "./GetInstanceUefiDataCommand";
export * from "./GetIpamAddressHistoryCommand";
export * from "./GetIpamPoolAllocationsCommand";
export * from "./GetIpamPoolCidrsCommand";
Expand Down
66 changes: 35 additions & 31 deletions clients/client-ec2/src/models/models_3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3901,7 +3901,9 @@ export type ImageAttributeName =
| "launchPermission"
| "productCodes"
| "ramdisk"
| "sriovNetSupport";
| "sriovNetSupport"
| "tpmSupport"
| "uefiData";

/**
* <p>Contains the parameters for DescribeImageAttribute.</p>
Expand Down Expand Up @@ -4022,6 +4024,20 @@ export interface ImageAttribute {
*/
BootMode?: AttributeValue;

/**
* <p>If the image is configured for NitroTPM support, the value is <code>v2.0</code>.</p>
*/
TpmSupport?: AttributeValue;

/**
* <p>Base64 representation of the non-volatile UEFI variable store. To retrieve the UEFI data,
* use the <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetInstanceUefiData">GetInstanceUefiData</a> command. You can inspect and modify the UEFI data by using the
* <a href="https://github.com/awslabs/python-uefivars">python-uefivars tool</a> on
* GitHub. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/uefi-secure-boot.html">UEFI Secure Boot</a> in the
* <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
*/
UefiData?: AttributeValue;

/**
* <p>The date and time, in <a href="http://www.iso.org/iso/iso8601">ISO 8601 date-time
* format</a>, when the AMI was last used to launch an EC2 instance. When the AMI is used,
Expand Down Expand Up @@ -4369,6 +4385,10 @@ export namespace StateReason {
});
}

export enum TpmSupportValues {
v2_0 = "v2.0",
}

export type VirtualizationType = "hvm" | "paravirtual";

/**
Expand Down Expand Up @@ -4522,6 +4542,13 @@ export interface Image {
*/
BootMode?: BootModeValues | string;

/**
* <p>If the image is configured for NitroTPM support, the value is <code>v2.0</code>.
* For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nitrotpm.html">NitroTPM</a> in the
* <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
*/
TpmSupport?: TpmSupportValues | string;

/**
* <p>The date and time to deprecate the AMI, in UTC, in the following format:
* <i>YYYY</i>-<i>MM</i>-<i>DD</i>T<i>HH</i>:<i>MM</i>:<i>SS</i>Z.
Expand Down Expand Up @@ -6983,6 +7010,13 @@ export interface Instance {
*/
Ipv6Address?: string;

/**
* <p>If the instance is configured for NitroTPM support, the value is <code>v2.0</code>.
* For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nitrotpm.html">NitroTPM</a> in the
* <i>Amazon EC2 User Guide</i>.</p>
*/
TpmSupport?: string;

/**
* <p>Provides information on the recovery and maintenance options of your instance.</p>
*/
Expand Down Expand Up @@ -12104,33 +12138,3 @@ export namespace DescribeRegionsRequest {
...obj,
});
}

/**
* <p>Describes a Region.</p>
*/
export interface Region {
/**
* <p>The Region service endpoint.</p>
*/
Endpoint?: string;

/**
* <p>The name of the Region.</p>
*/
RegionName?: string;

/**
* <p>The Region opt-in status. The possible values are <code>opt-in-not-required</code>, <code>opted-in</code>, and
* <code>not-opted-in</code>.</p>
*/
OptInStatus?: string;
}

export namespace Region {
/**
* @internal
*/
export const filterSensitiveLog = (obj: Region): any => ({
...obj,
});
}
Loading

0 comments on commit 2ad1bbf

Please sign in to comment.