From 0bc9a39b6069ab8a1df7b29798e93045167dcffe Mon Sep 17 00:00:00 2001 From: awstools Date: Thu, 26 Oct 2023 18:27:15 +0000 Subject: [PATCH] feat(client-ec2): Launching GetSecurityGroupsForVpc API. This API gets security groups that can be associated by the AWS account making the request with network interfaces in the specified VPC. --- clients/client-ec2/README.md | 8 + clients/client-ec2/src/EC2.ts | 23 ++ clients/client-ec2/src/EC2Client.ts | 6 + .../GetSecurityGroupsForVpcCommand.ts | 173 ++++++++++++++ ...sitGatewayRouteTableAssociationsCommand.ts | 6 +- ...sitGatewayRouteTablePropagationsCommand.ts | 6 +- .../RevokeSecurityGroupIngressCommand.ts | 3 +- clients/client-ec2/src/commands/index.ts | 1 + clients/client-ec2/src/models/models_5.ts | 222 ++++++++++-------- clients/client-ec2/src/models/models_6.ts | 177 ++++++++------ clients/client-ec2/src/models/models_7.ts | 81 ++++++- .../GetSecurityGroupsForVpcPaginator.ts | 50 ++++ clients/client-ec2/src/pagination/index.ts | 1 + clients/client-ec2/src/protocols/Aws_ec2.ts | 164 ++++++++++++- codegen/sdk-codegen/aws-models/ec2.json | 160 +++++++++++++ 15 files changed, 886 insertions(+), 195 deletions(-) create mode 100644 clients/client-ec2/src/commands/GetSecurityGroupsForVpcCommand.ts create mode 100644 clients/client-ec2/src/pagination/GetSecurityGroupsForVpcPaginator.ts diff --git a/clients/client-ec2/README.md b/clients/client-ec2/README.md index 8c9fb98190d8..72eac2d23cce 100644 --- a/clients/client-ec2/README.md +++ b/clients/client-ec2/README.md @@ -3788,6 +3788,14 @@ GetReservedInstancesExchangeQuote [Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ec2/classes/getreservedinstancesexchangequotecommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ec2/interfaces/getreservedinstancesexchangequotecommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ec2/interfaces/getreservedinstancesexchangequotecommandoutput.html) + +
+ +GetSecurityGroupsForVpc + + +[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ec2/classes/getsecuritygroupsforvpccommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ec2/interfaces/getsecuritygroupsforvpccommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-ec2/interfaces/getsecuritygroupsforvpccommandoutput.html) +
diff --git a/clients/client-ec2/src/EC2.ts b/clients/client-ec2/src/EC2.ts index 6bc86abde95c..ec0451d8ad45 100644 --- a/clients/client-ec2/src/EC2.ts +++ b/clients/client-ec2/src/EC2.ts @@ -2175,6 +2175,11 @@ import { GetReservedInstancesExchangeQuoteCommandInput, GetReservedInstancesExchangeQuoteCommandOutput, } from "./commands/GetReservedInstancesExchangeQuoteCommand"; +import { + GetSecurityGroupsForVpcCommand, + GetSecurityGroupsForVpcCommandInput, + GetSecurityGroupsForVpcCommandOutput, +} from "./commands/GetSecurityGroupsForVpcCommand"; import { GetSerialConsoleAccessStatusCommand, GetSerialConsoleAccessStatusCommandInput, @@ -3377,6 +3382,7 @@ const commands = { GetNetworkInsightsAccessScopeContentCommand, GetPasswordDataCommand, GetReservedInstancesExchangeQuoteCommand, + GetSecurityGroupsForVpcCommand, GetSerialConsoleAccessStatusCommand, GetSpotPlacementScoresCommand, GetSubnetCidrReservationsCommand, @@ -10844,6 +10850,23 @@ export interface EC2 { cb: (err: any, data?: GetReservedInstancesExchangeQuoteCommandOutput) => void ): void; + /** + * @see {@link GetSecurityGroupsForVpcCommand} + */ + getSecurityGroupsForVpc( + args: GetSecurityGroupsForVpcCommandInput, + options?: __HttpHandlerOptions + ): Promise; + getSecurityGroupsForVpc( + args: GetSecurityGroupsForVpcCommandInput, + cb: (err: any, data?: GetSecurityGroupsForVpcCommandOutput) => void + ): void; + getSecurityGroupsForVpc( + args: GetSecurityGroupsForVpcCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: GetSecurityGroupsForVpcCommandOutput) => void + ): void; + /** * @see {@link GetSerialConsoleAccessStatusCommand} */ diff --git a/clients/client-ec2/src/EC2Client.ts b/clients/client-ec2/src/EC2Client.ts index 1edc6509b6ce..6eb7338d1e5f 100644 --- a/clients/client-ec2/src/EC2Client.ts +++ b/clients/client-ec2/src/EC2Client.ts @@ -1554,6 +1554,10 @@ import { GetReservedInstancesExchangeQuoteCommandInput, GetReservedInstancesExchangeQuoteCommandOutput, } from "./commands/GetReservedInstancesExchangeQuoteCommand"; +import { + GetSecurityGroupsForVpcCommandInput, + GetSecurityGroupsForVpcCommandOutput, +} from "./commands/GetSecurityGroupsForVpcCommand"; import { GetSerialConsoleAccessStatusCommandInput, GetSerialConsoleAccessStatusCommandOutput, @@ -2534,6 +2538,7 @@ export type ServiceInputTypes = | GetNetworkInsightsAccessScopeContentCommandInput | GetPasswordDataCommandInput | GetReservedInstancesExchangeQuoteCommandInput + | GetSecurityGroupsForVpcCommandInput | GetSerialConsoleAccessStatusCommandInput | GetSpotPlacementScoresCommandInput | GetSubnetCidrReservationsCommandInput @@ -3138,6 +3143,7 @@ export type ServiceOutputTypes = | GetNetworkInsightsAccessScopeContentCommandOutput | GetPasswordDataCommandOutput | GetReservedInstancesExchangeQuoteCommandOutput + | GetSecurityGroupsForVpcCommandOutput | GetSerialConsoleAccessStatusCommandOutput | GetSpotPlacementScoresCommandOutput | GetSubnetCidrReservationsCommandOutput diff --git a/clients/client-ec2/src/commands/GetSecurityGroupsForVpcCommand.ts b/clients/client-ec2/src/commands/GetSecurityGroupsForVpcCommand.ts new file mode 100644 index 000000000000..8098bd160481 --- /dev/null +++ b/clients/client-ec2/src/commands/GetSecurityGroupsForVpcCommand.ts @@ -0,0 +1,173 @@ +// smithy-typescript generated code +import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; +import { getSerdePlugin } from "@smithy/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; +import { Command as $Command } from "@smithy/smithy-client"; +import { + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + MiddlewareStack, + SerdeContext as __SerdeContext, + SMITHY_CONTEXT_KEY, +} from "@smithy/types"; + +import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client"; +import { GetSecurityGroupsForVpcRequest, GetSecurityGroupsForVpcResult } from "../models/models_5"; +import { de_GetSecurityGroupsForVpcCommand, se_GetSecurityGroupsForVpcCommand } from "../protocols/Aws_ec2"; + +/** + * @public + */ +export { __MetadataBearer, $Command }; +/** + * @public + * + * The input for {@link GetSecurityGroupsForVpcCommand}. + */ +export interface GetSecurityGroupsForVpcCommandInput extends GetSecurityGroupsForVpcRequest {} +/** + * @public + * + * The output of {@link GetSecurityGroupsForVpcCommand}. + */ +export interface GetSecurityGroupsForVpcCommandOutput extends GetSecurityGroupsForVpcResult, __MetadataBearer {} + +/** + * @public + *

Gets security groups that can be associated by the Amazon Web Services account making the request with network interfaces in the specified VPC.

+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { EC2Client, GetSecurityGroupsForVpcCommand } from "@aws-sdk/client-ec2"; // ES Modules import + * // const { EC2Client, GetSecurityGroupsForVpcCommand } = require("@aws-sdk/client-ec2"); // CommonJS import + * const client = new EC2Client(config); + * const input = { // GetSecurityGroupsForVpcRequest + * VpcId: "STRING_VALUE", // required + * NextToken: "STRING_VALUE", + * MaxResults: Number("int"), + * Filters: [ // FilterList + * { // Filter + * Name: "STRING_VALUE", + * Values: [ // ValueStringList + * "STRING_VALUE", + * ], + * }, + * ], + * DryRun: true || false, + * }; + * const command = new GetSecurityGroupsForVpcCommand(input); + * const response = await client.send(command); + * // { // GetSecurityGroupsForVpcResult + * // NextToken: "STRING_VALUE", + * // SecurityGroupForVpcs: [ // SecurityGroupForVpcList + * // { // SecurityGroupForVpc + * // Description: "STRING_VALUE", + * // GroupName: "STRING_VALUE", + * // OwnerId: "STRING_VALUE", + * // GroupId: "STRING_VALUE", + * // Tags: [ // TagList + * // { // Tag + * // Key: "STRING_VALUE", + * // Value: "STRING_VALUE", + * // }, + * // ], + * // PrimaryVpcId: "STRING_VALUE", + * // }, + * // ], + * // }; + * + * ``` + * + * @param GetSecurityGroupsForVpcCommandInput - {@link GetSecurityGroupsForVpcCommandInput} + * @returns {@link GetSecurityGroupsForVpcCommandOutput} + * @see {@link GetSecurityGroupsForVpcCommandInput} for command's `input` shape. + * @see {@link GetSecurityGroupsForVpcCommandOutput} for command's `response` shape. + * @see {@link EC2ClientResolvedConfig | config} for EC2Client's `config` shape. + * + * @throws {@link EC2ServiceException} + *

Base exception class for all service exceptions from EC2 service.

+ * + */ +export class GetSecurityGroupsForVpcCommand extends $Command< + GetSecurityGroupsForVpcCommandInput, + GetSecurityGroupsForVpcCommandOutput, + EC2ClientResolvedConfig +> { + // Start section: command_properties + // End section: command_properties + + public static getEndpointParameterInstructions(): EndpointParameterInstructions { + return { + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, + }; + } + + /** + * @public + */ + constructor(readonly input: GetSecurityGroupsForVpcCommandInput) { + // Start section: command_constructor + super(); + // End section: command_constructor + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: EC2ClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + this.middlewareStack.use( + getEndpointPlugin(configuration, GetSecurityGroupsForVpcCommand.getEndpointParameterInstructions()) + ); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "EC2Client"; + const commandName = "GetSecurityGroupsForVpcCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: (_: any) => _, + outputFilterSensitiveLog: (_: any) => _, + [SMITHY_CONTEXT_KEY]: { + service: "AmazonEC2", + operation: "GetSecurityGroupsForVpc", + }, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + /** + * @internal + */ + private serialize(input: GetSecurityGroupsForVpcCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return se_GetSecurityGroupsForVpcCommand(input, context); + } + + /** + * @internal + */ + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + return de_GetSecurityGroupsForVpcCommand(output, context); + } + + // Start section: command_body_extra + // End section: command_body_extra +} diff --git a/clients/client-ec2/src/commands/GetTransitGatewayRouteTableAssociationsCommand.ts b/clients/client-ec2/src/commands/GetTransitGatewayRouteTableAssociationsCommand.ts index c003d4819e97..d1f523becfef 100644 --- a/clients/client-ec2/src/commands/GetTransitGatewayRouteTableAssociationsCommand.ts +++ b/clients/client-ec2/src/commands/GetTransitGatewayRouteTableAssociationsCommand.ts @@ -15,10 +15,8 @@ import { } from "@smithy/types"; import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client"; -import { - GetTransitGatewayRouteTableAssociationsRequest, - GetTransitGatewayRouteTableAssociationsResult, -} from "../models/models_5"; +import { GetTransitGatewayRouteTableAssociationsRequest } from "../models/models_5"; +import { GetTransitGatewayRouteTableAssociationsResult } from "../models/models_6"; import { de_GetTransitGatewayRouteTableAssociationsCommand, se_GetTransitGatewayRouteTableAssociationsCommand, diff --git a/clients/client-ec2/src/commands/GetTransitGatewayRouteTablePropagationsCommand.ts b/clients/client-ec2/src/commands/GetTransitGatewayRouteTablePropagationsCommand.ts index 25e77927c988..2e68a7e852d3 100644 --- a/clients/client-ec2/src/commands/GetTransitGatewayRouteTablePropagationsCommand.ts +++ b/clients/client-ec2/src/commands/GetTransitGatewayRouteTablePropagationsCommand.ts @@ -15,8 +15,10 @@ import { } from "@smithy/types"; import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client"; -import { GetTransitGatewayRouteTablePropagationsRequest } from "../models/models_5"; -import { GetTransitGatewayRouteTablePropagationsResult } from "../models/models_6"; +import { + GetTransitGatewayRouteTablePropagationsRequest, + GetTransitGatewayRouteTablePropagationsResult, +} from "../models/models_6"; import { de_GetTransitGatewayRouteTablePropagationsCommand, se_GetTransitGatewayRouteTablePropagationsCommand, diff --git a/clients/client-ec2/src/commands/RevokeSecurityGroupIngressCommand.ts b/clients/client-ec2/src/commands/RevokeSecurityGroupIngressCommand.ts index 2123fa915c4d..8c919ec7ddbf 100644 --- a/clients/client-ec2/src/commands/RevokeSecurityGroupIngressCommand.ts +++ b/clients/client-ec2/src/commands/RevokeSecurityGroupIngressCommand.ts @@ -15,7 +15,8 @@ import { } from "@smithy/types"; import { EC2ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EC2Client"; -import { RevokeSecurityGroupIngressRequest, RevokeSecurityGroupIngressResult } from "../models/models_6"; +import { RevokeSecurityGroupIngressRequest } from "../models/models_6"; +import { RevokeSecurityGroupIngressResult } from "../models/models_7"; import { de_RevokeSecurityGroupIngressCommand, se_RevokeSecurityGroupIngressCommand } from "../protocols/Aws_ec2"; /** diff --git a/clients/client-ec2/src/commands/index.ts b/clients/client-ec2/src/commands/index.ts index 8d2806610bbd..1eda39e460cc 100644 --- a/clients/client-ec2/src/commands/index.ts +++ b/clients/client-ec2/src/commands/index.ts @@ -444,6 +444,7 @@ export * from "./GetNetworkInsightsAccessScopeAnalysisFindingsCommand"; export * from "./GetNetworkInsightsAccessScopeContentCommand"; export * from "./GetPasswordDataCommand"; export * from "./GetReservedInstancesExchangeQuoteCommand"; +export * from "./GetSecurityGroupsForVpcCommand"; export * from "./GetSerialConsoleAccessStatusCommand"; export * from "./GetSpotPlacementScoresCommand"; export * from "./GetSubnetCidrReservationsCommand"; diff --git a/clients/client-ec2/src/models/models_5.ts b/clients/client-ec2/src/models/models_5.ts index 62a878439868..1c9330764cdc 100644 --- a/clients/client-ec2/src/models/models_5.ts +++ b/clients/client-ec2/src/models/models_5.ts @@ -19,7 +19,6 @@ import { TagSpecification, TargetConfigurationRequest, TransitGatewayAssociation, - TransitGatewayAssociationState, TransitGatewayAttachmentResourceType, TransitGatewayMulticastDomainAssociations, TransitGatewayPolicyTableAssociation, @@ -7569,6 +7568,126 @@ export interface GetReservedInstancesExchangeQuoteResult { ValidationFailureReason?: string; } +/** + * @public + */ +export interface GetSecurityGroupsForVpcRequest { + /** + * @public + *

The VPC ID where the security group can be used.

+ */ + VpcId: string | undefined; + + /** + * @public + *

The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.

+ */ + NextToken?: string; + + /** + * @public + *

The maximum number of items to return for this request. + * To get the next page of items, make another request with the token returned in the output. + * For more information, see Pagination.

+ */ + MaxResults?: number; + + /** + * @public + *

The filters. If using multiple filters, the results include security groups which match all filters.

+ *
    + *
  • + *

    + * group-id: The security group ID.

    + *
  • + *
  • + *

    + * description: The security group's description.

    + *
  • + *
  • + *

    + * group-name: The security group name.

    + *
  • + *
  • + *

    + * owner-id: The security group owner ID.

    + *
  • + *
  • + *

    + * primary-vpc-id: The VPC ID in which the security group was created.

    + *
  • + *
+ */ + Filters?: Filter[]; + + /** + * @public + *

Checks whether you have the required permissions for the action, 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.

+ */ + DryRun?: boolean; +} + +/** + * @public + *

A security group that can be used by interfaces in the VPC.

+ */ +export interface SecurityGroupForVpc { + /** + * @public + *

The security group's description.

+ */ + Description?: string; + + /** + * @public + *

The security group name.

+ */ + GroupName?: string; + + /** + * @public + *

The security group owner ID.

+ */ + OwnerId?: string; + + /** + * @public + *

The security group ID.

+ */ + GroupId?: string; + + /** + * @public + *

The security group tags.

+ */ + Tags?: Tag[]; + + /** + * @public + *

The VPC ID in which the security group was created.

+ */ + PrimaryVpcId?: string; +} + +/** + * @public + */ +export interface GetSecurityGroupsForVpcResult { + /** + * @public + *

The token to include in another request to get the next page of items. This value is null when there are no more items to return.

+ */ + NextToken?: string; + + /** + * @public + *

The security group that can be used by interfaces in the VPC.

+ */ + SecurityGroupForVpcs?: SecurityGroupForVpc[]; +} + /** * @public */ @@ -8364,107 +8483,6 @@ export interface GetTransitGatewayRouteTableAssociationsRequest { DryRun?: boolean; } -/** - * @public - *

Describes an association between a route table and a resource attachment.

- */ -export interface TransitGatewayRouteTableAssociation { - /** - * @public - *

The ID of the attachment.

- */ - TransitGatewayAttachmentId?: string; - - /** - * @public - *

The ID of the resource.

- */ - ResourceId?: string; - - /** - * @public - *

The resource type. Note that the tgw-peering resource type has been deprecated.

- */ - ResourceType?: TransitGatewayAttachmentResourceType; - - /** - * @public - *

The state of the association.

- */ - State?: TransitGatewayAssociationState; -} - -/** - * @public - */ -export interface GetTransitGatewayRouteTableAssociationsResult { - /** - * @public - *

Information about the associations.

- */ - Associations?: TransitGatewayRouteTableAssociation[]; - - /** - * @public - *

The token to use to retrieve the next page of results. This value is null when there are no more results to return.

- */ - NextToken?: string; -} - -/** - * @public - */ -export interface GetTransitGatewayRouteTablePropagationsRequest { - /** - * @public - *

The ID of the transit gateway route table.

- */ - TransitGatewayRouteTableId: string | undefined; - - /** - * @public - *

One or more filters. The possible values are:

- *
    - *
  • - *

    - * resource-id - The ID of the resource.

    - *
  • - *
  • - *

    - * resource-type - The resource type. Valid values are vpc - * | vpn | direct-connect-gateway | peering - * | connect.

    - *
  • - *
  • - *

    - * transit-gateway-attachment-id - The ID of the attachment.

    - *
  • - *
- */ - Filters?: Filter[]; - - /** - * @public - *

The maximum number of results to return with a single call. - * To retrieve the remaining results, make another call with the returned nextToken value.

- */ - MaxResults?: number; - - /** - * @public - *

The token for the next page of results.

- */ - NextToken?: string; - - /** - * @public - *

Checks whether you have the required permissions for the action, 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.

- */ - DryRun?: boolean; -} - /** * @internal */ diff --git a/clients/client-ec2/src/models/models_6.ts b/clients/client-ec2/src/models/models_6.ts index 9cae3ff21a34..7260f8ddf653 100644 --- a/clients/client-ec2/src/models/models_6.ts +++ b/clients/client-ec2/src/models/models_6.ts @@ -28,6 +28,7 @@ import { RouteTableAssociationState, Tag, TagSpecification, + TransitGatewayAssociationState, TransitGatewayAttachmentResourceType, TransitGatewayMulticastDomainAssociations, TransitGatewayPeeringAttachment, @@ -39,7 +40,6 @@ import { VerifiedAccessTrustProviderFilterSensitiveLog, } from "./models_0"; import { - AmdSevSnpSpecification, AttributeValue, BlockDeviceMapping, CapacityReservationPreference, @@ -113,6 +113,7 @@ import { BootModeValues, ConversionTask, ConversionTaskFilterSensitiveLog, + Filter, FpgaImageAttribute, FpgaImageAttributeName, ImdsSupportValues, @@ -162,6 +163,107 @@ import { VolumeModification, } from "./models_5"; +/** + * @public + *

Describes an association between a route table and a resource attachment.

+ */ +export interface TransitGatewayRouteTableAssociation { + /** + * @public + *

The ID of the attachment.

+ */ + TransitGatewayAttachmentId?: string; + + /** + * @public + *

The ID of the resource.

+ */ + ResourceId?: string; + + /** + * @public + *

The resource type. Note that the tgw-peering resource type has been deprecated.

+ */ + ResourceType?: TransitGatewayAttachmentResourceType; + + /** + * @public + *

The state of the association.

+ */ + State?: TransitGatewayAssociationState; +} + +/** + * @public + */ +export interface GetTransitGatewayRouteTableAssociationsResult { + /** + * @public + *

Information about the associations.

+ */ + Associations?: TransitGatewayRouteTableAssociation[]; + + /** + * @public + *

The token to use to retrieve the next page of results. This value is null when there are no more results to return.

+ */ + NextToken?: string; +} + +/** + * @public + */ +export interface GetTransitGatewayRouteTablePropagationsRequest { + /** + * @public + *

The ID of the transit gateway route table.

+ */ + TransitGatewayRouteTableId: string | undefined; + + /** + * @public + *

One or more filters. The possible values are:

+ *
    + *
  • + *

    + * resource-id - The ID of the resource.

    + *
  • + *
  • + *

    + * resource-type - The resource type. Valid values are vpc + * | vpn | direct-connect-gateway | peering + * | connect.

    + *
  • + *
  • + *

    + * transit-gateway-attachment-id - The ID of the attachment.

    + *
  • + *
+ */ + Filters?: Filter[]; + + /** + * @public + *

The maximum number of results to return with a single call. + * To retrieve the remaining results, make another call with the returned nextToken value.

+ */ + MaxResults?: number; + + /** + * @public + *

The token for the next page of results.

+ */ + NextToken?: string; + + /** + * @public + *

Checks whether you have the required permissions for the action, 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.

+ */ + DryRun?: boolean; +} + /** * @public *

Describes a route table propagation.

@@ -9150,79 +9252,6 @@ export interface RevokeSecurityGroupIngressRequest { SecurityGroupRuleIds?: string[]; } -/** - * @public - */ -export interface RevokeSecurityGroupIngressResult { - /** - * @public - *

Returns true if the request succeeds; otherwise, returns an error.

- */ - Return?: boolean; - - /** - * @public - *

The inbound rules that were unknown to the service. In some cases, - * unknownIpPermissionSet might be in a different format from the request - * parameter.

- */ - UnknownIpPermissions?: IpPermission[]; -} - -/** - * @public - *

The CPU options for the instance. Both the core count and threads per core must be - * specified in the request.

- */ -export interface CpuOptionsRequest { - /** - * @public - *

The number of CPU cores for the instance.

- */ - CoreCount?: number; - - /** - * @public - *

The number of threads per CPU core. To disable multithreading for the instance, - * specify a value of 1. Otherwise, specify the default value of - * 2.

- */ - ThreadsPerCore?: number; - - /** - * @public - *

Indicates whether to enable the instance for AMD SEV-SNP. AMD SEV-SNP is supported - * with M6a, R6a, and C6a instance types only. For more information, see - * AMD SEV-SNP.

- */ - AmdSevSnp?: AmdSevSnpSpecification; -} - -/** - * @public - *

- * Describes an elastic inference accelerator. - *

- */ -export interface ElasticInferenceAccelerator { - /** - * @public - *

- * The type of elastic inference accelerator. The possible values are eia1.medium, eia1.large, eia1.xlarge, eia2.medium, eia2.large, and eia2.xlarge. - *

- */ - Type: string | undefined; - - /** - * @public - *

- * The number of elastic inference accelerators to attach to the instance. - *

- *

Default: 1

- */ - Count?: number; -} - /** * @internal */ diff --git a/clients/client-ec2/src/models/models_7.ts b/clients/client-ec2/src/models/models_7.ts index e97d927fa5e4..550f9ce26ab9 100644 --- a/clients/client-ec2/src/models/models_7.ts +++ b/clients/client-ec2/src/models/models_7.ts @@ -11,6 +11,7 @@ import { TransitGatewayAttachmentResourceType, } from "./models_0"; import { + AmdSevSnpSpecification, BlockDeviceMapping, CreditSpecificationRequest, ElasticGpuSpecification, @@ -37,12 +38,80 @@ import { NetworkInsightsAnalysis, RunInstancesMonitoringEnabled, } from "./models_4"; -import { - CapacityReservationSpecification, - CpuOptionsRequest, - ElasticInferenceAccelerator, - InstanceMonitoring, -} from "./models_6"; +import { CapacityReservationSpecification, InstanceMonitoring } from "./models_6"; + +/** + * @public + */ +export interface RevokeSecurityGroupIngressResult { + /** + * @public + *

Returns true if the request succeeds; otherwise, returns an error.

+ */ + Return?: boolean; + + /** + * @public + *

The inbound rules that were unknown to the service. In some cases, + * unknownIpPermissionSet might be in a different format from the request + * parameter.

+ */ + UnknownIpPermissions?: IpPermission[]; +} + +/** + * @public + *

The CPU options for the instance. Both the core count and threads per core must be + * specified in the request.

+ */ +export interface CpuOptionsRequest { + /** + * @public + *

The number of CPU cores for the instance.

+ */ + CoreCount?: number; + + /** + * @public + *

The number of threads per CPU core. To disable multithreading for the instance, + * specify a value of 1. Otherwise, specify the default value of + * 2.

+ */ + ThreadsPerCore?: number; + + /** + * @public + *

Indicates whether to enable the instance for AMD SEV-SNP. AMD SEV-SNP is supported + * with M6a, R6a, and C6a instance types only. For more information, see + * AMD SEV-SNP.

+ */ + AmdSevSnp?: AmdSevSnpSpecification; +} + +/** + * @public + *

+ * Describes an elastic inference accelerator. + *

+ */ +export interface ElasticInferenceAccelerator { + /** + * @public + *

+ * The type of elastic inference accelerator. The possible values are eia1.medium, eia1.large, eia1.xlarge, eia2.medium, eia2.large, and eia2.xlarge. + *

+ */ + Type: string | undefined; + + /** + * @public + *

+ * The number of elastic inference accelerators to attach to the instance. + *

+ *

Default: 1

+ */ + Count?: number; +} /** * @public diff --git a/clients/client-ec2/src/pagination/GetSecurityGroupsForVpcPaginator.ts b/clients/client-ec2/src/pagination/GetSecurityGroupsForVpcPaginator.ts new file mode 100644 index 000000000000..c98331e6f72e --- /dev/null +++ b/clients/client-ec2/src/pagination/GetSecurityGroupsForVpcPaginator.ts @@ -0,0 +1,50 @@ +// smithy-typescript generated code +import { Paginator } from "@smithy/types"; + +import { + GetSecurityGroupsForVpcCommand, + GetSecurityGroupsForVpcCommandInput, + GetSecurityGroupsForVpcCommandOutput, +} from "../commands/GetSecurityGroupsForVpcCommand"; +import { EC2Client } from "../EC2Client"; +import { EC2PaginationConfiguration } from "./Interfaces"; + +/** + * @internal + */ +const makePagedClientRequest = async ( + client: EC2Client, + input: GetSecurityGroupsForVpcCommandInput, + ...args: any +): Promise => { + // @ts-ignore + return await client.send(new GetSecurityGroupsForVpcCommand(input), ...args); +}; +/** + * @public + */ +export async function* paginateGetSecurityGroupsForVpc( + config: EC2PaginationConfiguration, + input: GetSecurityGroupsForVpcCommandInput, + ...additionalArguments: any +): Paginator { + // ToDo: replace with actual type instead of typeof input.NextToken + let token: typeof input.NextToken | undefined = config.startingToken || undefined; + let hasNext = true; + let page: GetSecurityGroupsForVpcCommandOutput; + while (hasNext) { + input.NextToken = token; + input["MaxResults"] = config.pageSize; + if (config.client instanceof EC2Client) { + page = await makePagedClientRequest(config.client, input, ...additionalArguments); + } else { + throw new Error("Invalid client, expected EC2 | EC2Client"); + } + yield page; + const prevToken = token; + token = page.NextToken; + hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); + } + // @ts-ignore + return undefined; +} diff --git a/clients/client-ec2/src/pagination/index.ts b/clients/client-ec2/src/pagination/index.ts index aa853e3c1f9e..0fa2b9b473be 100644 --- a/clients/client-ec2/src/pagination/index.ts +++ b/clients/client-ec2/src/pagination/index.ts @@ -133,6 +133,7 @@ export * from "./GetIpamResourceCidrsPaginator"; export * from "./GetManagedPrefixListAssociationsPaginator"; export * from "./GetManagedPrefixListEntriesPaginator"; export * from "./GetNetworkInsightsAccessScopeAnalysisFindingsPaginator"; +export * from "./GetSecurityGroupsForVpcPaginator"; export * from "./GetSpotPlacementScoresPaginator"; export * from "./GetTransitGatewayAttachmentPropagationsPaginator"; export * from "./GetTransitGatewayMulticastDomainAssociationsPaginator"; diff --git a/clients/client-ec2/src/protocols/Aws_ec2.ts b/clients/client-ec2/src/protocols/Aws_ec2.ts index 3cec9e99556f..81e2456c3c1a 100644 --- a/clients/client-ec2/src/protocols/Aws_ec2.ts +++ b/clients/client-ec2/src/protocols/Aws_ec2.ts @@ -1528,6 +1528,10 @@ import { GetReservedInstancesExchangeQuoteCommandInput, GetReservedInstancesExchangeQuoteCommandOutput, } from "../commands/GetReservedInstancesExchangeQuoteCommand"; +import { + GetSecurityGroupsForVpcCommandInput, + GetSecurityGroupsForVpcCommandOutput, +} from "../commands/GetSecurityGroupsForVpcCommand"; import { GetSerialConsoleAccessStatusCommandInput, GetSerialConsoleAccessStatusCommandOutput, @@ -3515,6 +3519,8 @@ import { GetPasswordDataResult, GetReservedInstancesExchangeQuoteRequest, GetReservedInstancesExchangeQuoteResult, + GetSecurityGroupsForVpcRequest, + GetSecurityGroupsForVpcResult, GetSerialConsoleAccessStatusRequest, GetSerialConsoleAccessStatusResult, GetSpotPlacementScoresRequest, @@ -3532,8 +3538,6 @@ import { GetTransitGatewayPrefixListReferencesRequest, GetTransitGatewayPrefixListReferencesResult, GetTransitGatewayRouteTableAssociationsRequest, - GetTransitGatewayRouteTableAssociationsResult, - GetTransitGatewayRouteTablePropagationsRequest, InstanceEventWindowDisassociationRequest, InstanceFamilyCreditSpecification, InstanceRequirementsWithMetadataRequest, @@ -3553,6 +3557,7 @@ import { Purchase, ReservationValue, ReservedInstanceReservationValue, + SecurityGroupForVpc, ServiceDetail, SpotPlacementScore, TargetConfiguration, @@ -3563,7 +3568,6 @@ import { TransitGatewayPolicyRuleMetaData, TransitGatewayPolicyTableEntry, TransitGatewayPropagation, - TransitGatewayRouteTableAssociation, VerifiedAccessInstanceLoggingConfiguration, VerifiedAccessLogCloudWatchLogsDestination, VerifiedAccessLogDeliveryStatus, @@ -3585,13 +3589,13 @@ import { CapacityReservationSpecification, CidrAuthorizationContext, ClientData, - CpuOptionsRequest, CreateVolumePermissionModifications, DiskImage, DiskImageDetail, DnsServersOptionsModifyStructure, EbsInstanceBlockDeviceSpecification, - ElasticInferenceAccelerator, + GetTransitGatewayRouteTableAssociationsResult, + GetTransitGatewayRouteTablePropagationsRequest, GetTransitGatewayRouteTablePropagationsResult, GetVerifiedAccessEndpointPolicyRequest, GetVerifiedAccessEndpointPolicyResult, @@ -3850,7 +3854,6 @@ import { RevokeSecurityGroupEgressRequest, RevokeSecurityGroupEgressResult, RevokeSecurityGroupIngressRequest, - RevokeSecurityGroupIngressResult, SecurityGroupRuleRequest, SecurityGroupRuleUpdate, SnapshotDiskContainer, @@ -3860,6 +3863,7 @@ import { TrafficMirrorSessionField, TransitGatewayMulticastRegisteredGroupMembers, TransitGatewayMulticastRegisteredGroupSources, + TransitGatewayRouteTableAssociation, TransitGatewayRouteTablePropagation, UnsuccessfulInstanceCreditSpecificationItem, UnsuccessfulInstanceCreditSpecificationItemError, @@ -3873,6 +3877,8 @@ import { VpnConnectionDeviceType, } from "../models/models_6"; import { + CpuOptionsRequest, + ElasticInferenceAccelerator, EnclaveOptionsRequest, HibernationOptionsRequest, InstanceMaintenanceOptionsRequest, @@ -3882,6 +3888,7 @@ import { LaunchTemplateSpecification, LicenseConfigurationRequest, PrivateDnsNameOptionsRequest, + RevokeSecurityGroupIngressResult, RunInstancesRequest, RunScheduledInstancesRequest, RunScheduledInstancesResult, @@ -11499,6 +11506,23 @@ export const se_GetReservedInstancesExchangeQuoteCommand = async ( return buildHttpRpcRequest(context, headers, "/", undefined, body); }; +/** + * serializeAws_ec2GetSecurityGroupsForVpcCommand + */ +export const se_GetSecurityGroupsForVpcCommand = async ( + input: GetSecurityGroupsForVpcCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const headers: __HeaderBag = SHARED_HEADERS; + let body: any; + body = buildFormUrlencodedString({ + ...se_GetSecurityGroupsForVpcRequest(input, context), + Action: "GetSecurityGroupsForVpc", + Version: "2016-11-15", + }); + return buildHttpRpcRequest(context, headers, "/", undefined, body); +}; + /** * serializeAws_ec2GetSerialConsoleAccessStatusCommand */ @@ -31812,6 +31836,46 @@ const de_GetReservedInstancesExchangeQuoteCommandError = async ( }); }; +/** + * deserializeAws_ec2GetSecurityGroupsForVpcCommand + */ +export const de_GetSecurityGroupsForVpcCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode >= 300) { + return de_GetSecurityGroupsForVpcCommandError(output, context); + } + const data: any = await parseBody(output.body, context); + let contents: any = {}; + contents = de_GetSecurityGroupsForVpcResult(data, context); + const response: GetSecurityGroupsForVpcCommandOutput = { + $metadata: deserializeMetadata(output), + ...contents, + }; + return response; +}; + +/** + * deserializeAws_ec2GetSecurityGroupsForVpcCommandError + */ +const de_GetSecurityGroupsForVpcCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseErrorBody(output.body, context), + }; + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const parsedBody = parsedOutput.body; + return throwDefaultError({ + output, + parsedBody: parsedBody.Errors.Error, + errorCode, + }); +}; + /** * deserializeAws_ec2GetSerialConsoleAccessStatusCommand */ @@ -53231,6 +53295,36 @@ const se_GetReservedInstancesExchangeQuoteRequest = ( return entries; }; +/** + * serializeAws_ec2GetSecurityGroupsForVpcRequest + */ +const se_GetSecurityGroupsForVpcRequest = (input: GetSecurityGroupsForVpcRequest, context: __SerdeContext): any => { + const entries: any = {}; + if (input.VpcId != null) { + entries["VpcId"] = input.VpcId; + } + if (input.NextToken != null) { + entries["NextToken"] = input.NextToken; + } + if (input.MaxResults != null) { + entries["MaxResults"] = input.MaxResults; + } + if (input.Filters != null) { + const memberEntries = se_FilterList(input.Filters, context); + if (input.Filters?.length === 0) { + entries.Filter = []; + } + Object.entries(memberEntries).forEach(([key, value]) => { + const loc = `Filter.${key.substring(key.indexOf(".") + 1)}`; + entries[loc] = value; + }); + } + if (input.DryRun != null) { + entries["DryRun"] = input.DryRun; + } + return entries; +}; + /** * serializeAws_ec2GetSerialConsoleAccessStatusRequest */ @@ -77862,6 +77956,25 @@ const de_GetReservedInstancesExchangeQuoteResult = ( return contents; }; +/** + * deserializeAws_ec2GetSecurityGroupsForVpcResult + */ +const de_GetSecurityGroupsForVpcResult = (output: any, context: __SerdeContext): GetSecurityGroupsForVpcResult => { + const contents: any = {}; + if (output["nextToken"] !== undefined) { + contents.NextToken = __expectString(output["nextToken"]); + } + if (output.securityGroupForVpcSet === "") { + contents.SecurityGroupForVpcs = []; + } else if (output["securityGroupForVpcSet"] !== undefined && output["securityGroupForVpcSet"]["item"] !== undefined) { + contents.SecurityGroupForVpcs = de_SecurityGroupForVpcList( + __getArrayIfSingleItem(output["securityGroupForVpcSet"]["item"]), + context + ); + } + return contents; +}; + /** * deserializeAws_ec2GetSerialConsoleAccessStatusResult */ @@ -88401,6 +88514,45 @@ const de_SecurityGroup = (output: any, context: __SerdeContext): SecurityGroup = return contents; }; +/** + * deserializeAws_ec2SecurityGroupForVpc + */ +const de_SecurityGroupForVpc = (output: any, context: __SerdeContext): SecurityGroupForVpc => { + const contents: any = {}; + if (output["description"] !== undefined) { + contents.Description = __expectString(output["description"]); + } + if (output["groupName"] !== undefined) { + contents.GroupName = __expectString(output["groupName"]); + } + if (output["ownerId"] !== undefined) { + contents.OwnerId = __expectString(output["ownerId"]); + } + if (output["groupId"] !== undefined) { + contents.GroupId = __expectString(output["groupId"]); + } + if (output.tagSet === "") { + contents.Tags = []; + } else if (output["tagSet"] !== undefined && output["tagSet"]["item"] !== undefined) { + contents.Tags = de_TagList(__getArrayIfSingleItem(output["tagSet"]["item"]), context); + } + if (output["primaryVpcId"] !== undefined) { + contents.PrimaryVpcId = __expectString(output["primaryVpcId"]); + } + return contents; +}; + +/** + * deserializeAws_ec2SecurityGroupForVpcList + */ +const de_SecurityGroupForVpcList = (output: any, context: __SerdeContext): SecurityGroupForVpc[] => { + return (output || []) + .filter((e: any) => e != null) + .map((entry: any) => { + return de_SecurityGroupForVpc(entry, context); + }); +}; + /** * deserializeAws_ec2SecurityGroupIdentifier */ diff --git a/codegen/sdk-codegen/aws-models/ec2.json b/codegen/sdk-codegen/aws-models/ec2.json index 52d05d200496..be5834694468 100644 --- a/codegen/sdk-codegen/aws-models/ec2.json +++ b/codegen/sdk-codegen/aws-models/ec2.json @@ -3427,6 +3427,9 @@ { "target": "com.amazonaws.ec2#GetReservedInstancesExchangeQuote" }, + { + "target": "com.amazonaws.ec2#GetSecurityGroupsForVpc" + }, { "target": "com.amazonaws.ec2#GetSerialConsoleAccessStatus" }, @@ -50917,6 +50920,98 @@ "smithy.api#output": {} } }, + "com.amazonaws.ec2#GetSecurityGroupsForVpc": { + "type": "operation", + "input": { + "target": "com.amazonaws.ec2#GetSecurityGroupsForVpcRequest" + }, + "output": { + "target": "com.amazonaws.ec2#GetSecurityGroupsForVpcResult" + }, + "traits": { + "smithy.api#documentation": "

Gets security groups that can be associated by the Amazon Web Services account making the request with network interfaces in the specified VPC.

", + "smithy.api#paginated": { + "inputToken": "NextToken", + "outputToken": "NextToken", + "items": "SecurityGroupForVpcs", + "pageSize": "MaxResults" + } + } + }, + "com.amazonaws.ec2#GetSecurityGroupsForVpcRequest": { + "type": "structure", + "members": { + "VpcId": { + "target": "com.amazonaws.ec2#VpcId", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "

The VPC ID where the security group can be used.

", + "smithy.api#required": {} + } + }, + "NextToken": { + "target": "com.amazonaws.ec2#String", + "traits": { + "smithy.api#documentation": "

The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.

" + } + }, + "MaxResults": { + "target": "com.amazonaws.ec2#GetSecurityGroupsForVpcRequestMaxResults", + "traits": { + "smithy.api#documentation": "

The maximum number of items to return for this request.\n\tTo get the next page of items, make another request with the token returned in the output.\n\tFor more information, see Pagination.

" + } + }, + "Filters": { + "target": "com.amazonaws.ec2#FilterList", + "traits": { + "smithy.api#documentation": "

The filters. If using multiple filters, the results include security groups which match all filters.

\n
    \n
  • \n

    \n group-id: The security group ID.

    \n
  • \n
  • \n

    \n description: The security group's description.

    \n
  • \n
  • \n

    \n group-name: The security group name.

    \n
  • \n
  • \n

    \n owner-id: The security group owner ID.

    \n
  • \n
  • \n

    \n primary-vpc-id: The VPC ID in which the security group was created.

    \n
  • \n
", + "smithy.api#xmlName": "Filter" + } + }, + "DryRun": { + "target": "com.amazonaws.ec2#Boolean", + "traits": { + "smithy.api#documentation": "

Checks whether you have the required permissions for the action, without actually making the request, \n and provides an error response. If you have the required permissions, the error response is DryRunOperation. \n Otherwise, it is UnauthorizedOperation.

" + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.ec2#GetSecurityGroupsForVpcRequestMaxResults": { + "type": "integer", + "traits": { + "smithy.api#range": { + "min": 5, + "max": 1000 + } + } + }, + "com.amazonaws.ec2#GetSecurityGroupsForVpcResult": { + "type": "structure", + "members": { + "NextToken": { + "target": "com.amazonaws.ec2#String", + "traits": { + "aws.protocols#ec2QueryName": "NextToken", + "smithy.api#documentation": "

The token to include in another request to get the next page of items. This value is null when there are no more items to return.

", + "smithy.api#xmlName": "nextToken" + } + }, + "SecurityGroupForVpcs": { + "target": "com.amazonaws.ec2#SecurityGroupForVpcList", + "traits": { + "aws.protocols#ec2QueryName": "SecurityGroupForVpcSet", + "smithy.api#documentation": "

The security group that can be used by interfaces in the VPC.

", + "smithy.api#xmlName": "securityGroupForVpcSet" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, "com.amazonaws.ec2#GetSerialConsoleAccessStatus": { "type": "operation", "input": { @@ -88892,6 +88987,71 @@ "smithy.api#documentation": "

Describes a security group.

" } }, + "com.amazonaws.ec2#SecurityGroupForVpc": { + "type": "structure", + "members": { + "Description": { + "target": "com.amazonaws.ec2#String", + "traits": { + "aws.protocols#ec2QueryName": "Description", + "smithy.api#documentation": "

The security group's description.

", + "smithy.api#xmlName": "description" + } + }, + "GroupName": { + "target": "com.amazonaws.ec2#String", + "traits": { + "aws.protocols#ec2QueryName": "GroupName", + "smithy.api#documentation": "

The security group name.

", + "smithy.api#xmlName": "groupName" + } + }, + "OwnerId": { + "target": "com.amazonaws.ec2#String", + "traits": { + "aws.protocols#ec2QueryName": "OwnerId", + "smithy.api#documentation": "

The security group owner ID.

", + "smithy.api#xmlName": "ownerId" + } + }, + "GroupId": { + "target": "com.amazonaws.ec2#String", + "traits": { + "aws.protocols#ec2QueryName": "GroupId", + "smithy.api#documentation": "

The security group ID.

", + "smithy.api#xmlName": "groupId" + } + }, + "Tags": { + "target": "com.amazonaws.ec2#TagList", + "traits": { + "aws.protocols#ec2QueryName": "TagSet", + "smithy.api#documentation": "

The security group tags.

", + "smithy.api#xmlName": "tagSet" + } + }, + "PrimaryVpcId": { + "target": "com.amazonaws.ec2#String", + "traits": { + "aws.protocols#ec2QueryName": "PrimaryVpcId", + "smithy.api#documentation": "

The VPC ID in which the security group was created.

", + "smithy.api#xmlName": "primaryVpcId" + } + } + }, + "traits": { + "smithy.api#documentation": "

A security group that can be used by interfaces in the VPC.

" + } + }, + "com.amazonaws.ec2#SecurityGroupForVpcList": { + "type": "list", + "member": { + "target": "com.amazonaws.ec2#SecurityGroupForVpc", + "traits": { + "smithy.api#xmlName": "item" + } + } + }, "com.amazonaws.ec2#SecurityGroupId": { "type": "string" },