EC2Client#
Auto-generated documentation for EC2 type annotations stubs module mypy-boto3-ec2.
EC2Client#
Type annotations and code completion for boto3.client("ec2")
.
boto3 documentation
# EC2Client usage example
from boto3.session import Session
from mypy_boto3_ec2.client import EC2Client
def get_ec2_client() -> EC2Client:
return Session().client("ec2")
Exceptions#
boto3
client exceptions are generated in runtime.
This class provides code completion for boto3.client("ec2").exceptions
structure.
# Exceptions.exceptions usage example
client = boto3.client("ec2")
try:
do_something(client)
except (
client.exceptions.ClientError,
) as e:
print(e)
# Exceptions.exceptions type checking example
from mypy_boto3_ec2.client import Exceptions
def handle_error(exc: Exceptions.ClientError) -> None:
...
Methods#
accept_address_transfer#
Accepts an Elastic IP address transfer.
Type annotations and code completion for boto3.client("ec2").accept_address_transfer
method.
boto3 documentation
# accept_address_transfer method definition
def accept_address_transfer(
self,
*,
Address: str,
TagSpecifications: Sequence[TagSpecificationTypeDef] = ..., # (1)
DryRun: bool = ...,
) -> AcceptAddressTransferResultTypeDef: # (2)
...
# accept_address_transfer method usage example with argument unpacking
kwargs: AcceptAddressTransferRequestRequestTypeDef = { # (1)
"Address": ...,
}
parent.accept_address_transfer(**kwargs)
accept_reserved_instances_exchange_quote#
Accepts the Convertible Reserved Instance exchange quote described in the GetReservedInstancesExchangeQuote call.
Type annotations and code completion for boto3.client("ec2").accept_reserved_instances_exchange_quote
method.
boto3 documentation
# accept_reserved_instances_exchange_quote method definition
def accept_reserved_instances_exchange_quote(
self,
*,
ReservedInstanceIds: Sequence[str],
DryRun: bool = ...,
TargetConfigurations: Sequence[TargetConfigurationRequestTypeDef] = ..., # (1)
) -> AcceptReservedInstancesExchangeQuoteResultTypeDef: # (2)
...
# accept_reserved_instances_exchange_quote method usage example with argument unpacking
kwargs: AcceptReservedInstancesExchangeQuoteRequestRequestTypeDef = { # (1)
"ReservedInstanceIds": ...,
}
parent.accept_reserved_instances_exchange_quote(**kwargs)
accept_transit_gateway_multicast_domain_associations#
Accepts a request to associate subnets with a transit gateway multicast domain.
Type annotations and code completion for boto3.client("ec2").accept_transit_gateway_multicast_domain_associations
method.
boto3 documentation
# accept_transit_gateway_multicast_domain_associations method definition
def accept_transit_gateway_multicast_domain_associations(
self,
*,
TransitGatewayMulticastDomainId: str = ...,
TransitGatewayAttachmentId: str = ...,
SubnetIds: Sequence[str] = ...,
DryRun: bool = ...,
) -> AcceptTransitGatewayMulticastDomainAssociationsResultTypeDef: # (1)
...
# accept_transit_gateway_multicast_domain_associations method usage example with argument unpacking
kwargs: AcceptTransitGatewayMulticastDomainAssociationsRequestRequestTypeDef = { # (1)
"TransitGatewayMulticastDomainId": ...,
}
parent.accept_transit_gateway_multicast_domain_associations(**kwargs)
accept_transit_gateway_peering_attachment#
Accepts a transit gateway peering attachment request.
Type annotations and code completion for boto3.client("ec2").accept_transit_gateway_peering_attachment
method.
boto3 documentation
# accept_transit_gateway_peering_attachment method definition
def accept_transit_gateway_peering_attachment(
self,
*,
TransitGatewayAttachmentId: str,
DryRun: bool = ...,
) -> AcceptTransitGatewayPeeringAttachmentResultTypeDef: # (1)
...
# accept_transit_gateway_peering_attachment method usage example with argument unpacking
kwargs: AcceptTransitGatewayPeeringAttachmentRequestRequestTypeDef = { # (1)
"TransitGatewayAttachmentId": ...,
}
parent.accept_transit_gateway_peering_attachment(**kwargs)
accept_transit_gateway_vpc_attachment#
Accepts a request to attach a VPC to a transit gateway.
Type annotations and code completion for boto3.client("ec2").accept_transit_gateway_vpc_attachment
method.
boto3 documentation
# accept_transit_gateway_vpc_attachment method definition
def accept_transit_gateway_vpc_attachment(
self,
*,
TransitGatewayAttachmentId: str,
DryRun: bool = ...,
) -> AcceptTransitGatewayVpcAttachmentResultTypeDef: # (1)
...
# accept_transit_gateway_vpc_attachment method usage example with argument unpacking
kwargs: AcceptTransitGatewayVpcAttachmentRequestRequestTypeDef = { # (1)
"TransitGatewayAttachmentId": ...,
}
parent.accept_transit_gateway_vpc_attachment(**kwargs)
accept_vpc_endpoint_connections#
Accepts connection requests to your VPC endpoint service.
Type annotations and code completion for boto3.client("ec2").accept_vpc_endpoint_connections
method.
boto3 documentation
# accept_vpc_endpoint_connections method definition
def accept_vpc_endpoint_connections(
self,
*,
ServiceId: str,
VpcEndpointIds: Sequence[str],
DryRun: bool = ...,
) -> AcceptVpcEndpointConnectionsResultTypeDef: # (1)
...
# accept_vpc_endpoint_connections method usage example with argument unpacking
kwargs: AcceptVpcEndpointConnectionsRequestRequestTypeDef = { # (1)
"ServiceId": ...,
"VpcEndpointIds": ...,
}
parent.accept_vpc_endpoint_connections(**kwargs)
accept_vpc_peering_connection#
Accept a VPC peering connection request.
Type annotations and code completion for boto3.client("ec2").accept_vpc_peering_connection
method.
boto3 documentation
# accept_vpc_peering_connection method definition
def accept_vpc_peering_connection(
self,
*,
VpcPeeringConnectionId: str,
DryRun: bool = ...,
) -> AcceptVpcPeeringConnectionResultTypeDef: # (1)
...
# accept_vpc_peering_connection method usage example with argument unpacking
kwargs: AcceptVpcPeeringConnectionRequestRequestTypeDef = { # (1)
"VpcPeeringConnectionId": ...,
}
parent.accept_vpc_peering_connection(**kwargs)
advertise_byoip_cidr#
Advertises an IPv4 or IPv6 address range that is provisioned for use with your Amazon Web Services resources through bring your own IP addresses (BYOIP).
Type annotations and code completion for boto3.client("ec2").advertise_byoip_cidr
method.
boto3 documentation
# advertise_byoip_cidr method definition
def advertise_byoip_cidr(
self,
*,
Cidr: str,
DryRun: bool = ...,
) -> AdvertiseByoipCidrResultTypeDef: # (1)
...
# advertise_byoip_cidr method usage example with argument unpacking
kwargs: AdvertiseByoipCidrRequestRequestTypeDef = { # (1)
"Cidr": ...,
}
parent.advertise_byoip_cidr(**kwargs)
allocate_address#
Allocates an Elastic IP address to your Amazon Web Services account.
Type annotations and code completion for boto3.client("ec2").allocate_address
method.
boto3 documentation
# allocate_address method definition
def allocate_address(
self,
*,
Domain: DomainTypeType = ..., # (1)
Address: str = ...,
PublicIpv4Pool: str = ...,
NetworkBorderGroup: str = ...,
CustomerOwnedIpv4Pool: str = ...,
DryRun: bool = ...,
TagSpecifications: Sequence[TagSpecificationTypeDef] = ..., # (2)
) -> AllocateAddressResultTypeDef: # (3)
...
# allocate_address method usage example with argument unpacking
kwargs: AllocateAddressRequestRequestTypeDef = { # (1)
"Domain": ...,
}
parent.allocate_address(**kwargs)
allocate_hosts#
Allocates a Dedicated Host to your account.
Type annotations and code completion for boto3.client("ec2").allocate_hosts
method.
boto3 documentation
# allocate_hosts method definition
def allocate_hosts(
self,
*,
AvailabilityZone: str,
Quantity: int,
AutoPlacement: AutoPlacementType = ..., # (1)
ClientToken: str = ...,
InstanceType: str = ...,
InstanceFamily: str = ...,
TagSpecifications: Sequence[TagSpecificationTypeDef] = ..., # (2)
HostRecovery: HostRecoveryType = ..., # (3)
OutpostArn: str = ...,
HostMaintenance: HostMaintenanceType = ..., # (4)
) -> AllocateHostsResultTypeDef: # (5)
...
- See AutoPlacementType
- See TagSpecificationTypeDef
- See HostRecoveryType
- See HostMaintenanceType
- See AllocateHostsResultTypeDef
# allocate_hosts method usage example with argument unpacking
kwargs: AllocateHostsRequestRequestTypeDef = { # (1)
"AvailabilityZone": ...,
"Quantity": ...,
}
parent.allocate_hosts(**kwargs)
allocate_ipam_pool_cidr#
Allocate a CIDR from an IPAM pool.
Type annotations and code completion for boto3.client("ec2").allocate_ipam_pool_cidr
method.
boto3 documentation
# allocate_ipam_pool_cidr method definition
def allocate_ipam_pool_cidr(
self,
*,
IpamPoolId: str,
DryRun: bool = ...,
Cidr: str = ...,
NetmaskLength: int = ...,
ClientToken: str = ...,
Description: str = ...,
PreviewNextCidr: bool = ...,
DisallowedCidrs: Sequence[str] = ...,
) -> AllocateIpamPoolCidrResultTypeDef: # (1)
...
# allocate_ipam_pool_cidr method usage example with argument unpacking
kwargs: AllocateIpamPoolCidrRequestRequestTypeDef = { # (1)
"IpamPoolId": ...,
}
parent.allocate_ipam_pool_cidr(**kwargs)
apply_security_groups_to_client_vpn_target_network#
Applies a security group to the association between the target network and the Client VPN endpoint.
Type annotations and code completion for boto3.client("ec2").apply_security_groups_to_client_vpn_target_network
method.
boto3 documentation
# apply_security_groups_to_client_vpn_target_network method definition
def apply_security_groups_to_client_vpn_target_network(
self,
*,
ClientVpnEndpointId: str,
VpcId: str,
SecurityGroupIds: Sequence[str],
DryRun: bool = ...,
) -> ApplySecurityGroupsToClientVpnTargetNetworkResultTypeDef: # (1)
...
# apply_security_groups_to_client_vpn_target_network method usage example with argument unpacking
kwargs: ApplySecurityGroupsToClientVpnTargetNetworkRequestRequestTypeDef = { # (1)
"ClientVpnEndpointId": ...,
"VpcId": ...,
"SecurityGroupIds": ...,
}
parent.apply_security_groups_to_client_vpn_target_network(**kwargs)
assign_ipv6_addresses#
Assigns one or more IPv6 addresses to the specified network interface.
Type annotations and code completion for boto3.client("ec2").assign_ipv6_addresses
method.
boto3 documentation
# assign_ipv6_addresses method definition
def assign_ipv6_addresses(
self,
*,
NetworkInterfaceId: str,
Ipv6AddressCount: int = ...,
Ipv6Addresses: Sequence[str] = ...,
Ipv6PrefixCount: int = ...,
Ipv6Prefixes: Sequence[str] = ...,
) -> AssignIpv6AddressesResultTypeDef: # (1)
...
# assign_ipv6_addresses method usage example with argument unpacking
kwargs: AssignIpv6AddressesRequestRequestTypeDef = { # (1)
"NetworkInterfaceId": ...,
}
parent.assign_ipv6_addresses(**kwargs)
assign_private_ip_addresses#
Assigns one or more secondary private IP addresses to the specified network interface.
Type annotations and code completion for boto3.client("ec2").assign_private_ip_addresses
method.
boto3 documentation
# assign_private_ip_addresses method definition
def assign_private_ip_addresses(
self,
*,
NetworkInterfaceId: str,
AllowReassignment: bool = ...,
PrivateIpAddresses: Sequence[str] = ...,
SecondaryPrivateIpAddressCount: int = ...,
Ipv4Prefixes: Sequence[str] = ...,
Ipv4PrefixCount: int = ...,
) -> AssignPrivateIpAddressesResultTypeDef: # (1)
...
# assign_private_ip_addresses method usage example with argument unpacking
kwargs: AssignPrivateIpAddressesRequestRequestTypeDef = { # (1)
"NetworkInterfaceId": ...,
}
parent.assign_private_ip_addresses(**kwargs)
assign_private_nat_gateway_address#
Assigns one or more private IPv4 addresses to a private NAT gateway.
Type annotations and code completion for boto3.client("ec2").assign_private_nat_gateway_address
method.
boto3 documentation
# assign_private_nat_gateway_address method definition
def assign_private_nat_gateway_address(
self,
*,
NatGatewayId: str,
PrivateIpAddresses: Sequence[str] = ...,
PrivateIpAddressCount: int = ...,
DryRun: bool = ...,
) -> AssignPrivateNatGatewayAddressResultTypeDef: # (1)
...
# assign_private_nat_gateway_address method usage example with argument unpacking
kwargs: AssignPrivateNatGatewayAddressRequestRequestTypeDef = { # (1)
"NatGatewayId": ...,
}
parent.assign_private_nat_gateway_address(**kwargs)
associate_address#
Associates an Elastic IP address, or carrier IP address (for instances that are in subnets in Wavelength Zones) with an instance or a network interface.
Type annotations and code completion for boto3.client("ec2").associate_address
method.
boto3 documentation
# associate_address method definition
def associate_address(
self,
*,
AllocationId: str = ...,
InstanceId: str = ...,
PublicIp: str = ...,
AllowReassociation: bool = ...,
DryRun: bool = ...,
NetworkInterfaceId: str = ...,
PrivateIpAddress: str = ...,
) -> AssociateAddressResultTypeDef: # (1)
...
# associate_address method usage example with argument unpacking
kwargs: AssociateAddressRequestRequestTypeDef = { # (1)
"AllocationId": ...,
}
parent.associate_address(**kwargs)
associate_client_vpn_target_network#
Associates a target network with a Client VPN endpoint.
Type annotations and code completion for boto3.client("ec2").associate_client_vpn_target_network
method.
boto3 documentation
# associate_client_vpn_target_network method definition
def associate_client_vpn_target_network(
self,
*,
ClientVpnEndpointId: str,
SubnetId: str,
ClientToken: str = ...,
DryRun: bool = ...,
) -> AssociateClientVpnTargetNetworkResultTypeDef: # (1)
...
# associate_client_vpn_target_network method usage example with argument unpacking
kwargs: AssociateClientVpnTargetNetworkRequestRequestTypeDef = { # (1)
"ClientVpnEndpointId": ...,
"SubnetId": ...,
}
parent.associate_client_vpn_target_network(**kwargs)
associate_dhcp_options#
Associates a set of DHCP options (that you've previously created) with the specified VPC, or associates no DHCP options with the VPC.
Type annotations and code completion for boto3.client("ec2").associate_dhcp_options
method.
boto3 documentation
# associate_dhcp_options method definition
def associate_dhcp_options(
self,
*,
DhcpOptionsId: str,
VpcId: str,
DryRun: bool = ...,
) -> EmptyResponseMetadataTypeDef: # (1)
...
# associate_dhcp_options method usage example with argument unpacking
kwargs: AssociateDhcpOptionsRequestRequestTypeDef = { # (1)
"DhcpOptionsId": ...,
"VpcId": ...,
}
parent.associate_dhcp_options(**kwargs)
associate_enclave_certificate_iam_role#
Associates an Identity and Access Management (IAM) role with an Certificate Manager (ACM) certificate.
Type annotations and code completion for boto3.client("ec2").associate_enclave_certificate_iam_role
method.
boto3 documentation
# associate_enclave_certificate_iam_role method definition
def associate_enclave_certificate_iam_role(
self,
*,
CertificateArn: str,
RoleArn: str,
DryRun: bool = ...,
) -> AssociateEnclaveCertificateIamRoleResultTypeDef: # (1)
...
# associate_enclave_certificate_iam_role method usage example with argument unpacking
kwargs: AssociateEnclaveCertificateIamRoleRequestRequestTypeDef = { # (1)
"CertificateArn": ...,
"RoleArn": ...,
}
parent.associate_enclave_certificate_iam_role(**kwargs)
associate_iam_instance_profile#
Associates an IAM instance profile with a running or stopped instance.
Type annotations and code completion for boto3.client("ec2").associate_iam_instance_profile
method.
boto3 documentation
# associate_iam_instance_profile method definition
def associate_iam_instance_profile(
self,
*,
IamInstanceProfile: IamInstanceProfileSpecificationTypeDef, # (1)
InstanceId: str,
) -> AssociateIamInstanceProfileResultTypeDef: # (2)
...
# associate_iam_instance_profile method usage example with argument unpacking
kwargs: AssociateIamInstanceProfileRequestRequestTypeDef = { # (1)
"IamInstanceProfile": ...,
"InstanceId": ...,
}
parent.associate_iam_instance_profile(**kwargs)
associate_instance_event_window#
Associates one or more targets with an event window.
Type annotations and code completion for boto3.client("ec2").associate_instance_event_window
method.
boto3 documentation
# associate_instance_event_window method definition
def associate_instance_event_window(
self,
*,
InstanceEventWindowId: str,
AssociationTarget: InstanceEventWindowAssociationRequestTypeDef, # (1)
DryRun: bool = ...,
) -> AssociateInstanceEventWindowResultTypeDef: # (2)
...
# associate_instance_event_window method usage example with argument unpacking
kwargs: AssociateInstanceEventWindowRequestRequestTypeDef = { # (1)
"InstanceEventWindowId": ...,
"AssociationTarget": ...,
}
parent.associate_instance_event_window(**kwargs)
associate_ipam_resource_discovery#
Associates an IPAM resource discovery with an Amazon VPC IPAM.
Type annotations and code completion for boto3.client("ec2").associate_ipam_resource_discovery
method.
boto3 documentation
# associate_ipam_resource_discovery method definition
def associate_ipam_resource_discovery(
self,
*,
IpamId: str,
IpamResourceDiscoveryId: str,
DryRun: bool = ...,
TagSpecifications: Sequence[TagSpecificationTypeDef] = ..., # (1)
ClientToken: str = ...,
) -> AssociateIpamResourceDiscoveryResultTypeDef: # (2)
...
# associate_ipam_resource_discovery method usage example with argument unpacking
kwargs: AssociateIpamResourceDiscoveryRequestRequestTypeDef = { # (1)
"IpamId": ...,
"IpamResourceDiscoveryId": ...,
}
parent.associate_ipam_resource_discovery(**kwargs)
associate_nat_gateway_address#
Associates Elastic IP addresses (EIPs) and private IPv4 addresses with a public NAT gateway.
Type annotations and code completion for boto3.client("ec2").associate_nat_gateway_address
method.
boto3 documentation
# associate_nat_gateway_address method definition
def associate_nat_gateway_address(
self,
*,
NatGatewayId: str,
AllocationIds: Sequence[str],
PrivateIpAddresses: Sequence[str] = ...,
DryRun: bool = ...,
) -> AssociateNatGatewayAddressResultTypeDef: # (1)
...
# associate_nat_gateway_address method usage example with argument unpacking
kwargs: AssociateNatGatewayAddressRequestRequestTypeDef = { # (1)
"NatGatewayId": ...,
"AllocationIds": ...,
}
parent.associate_nat_gateway_address(**kwargs)
associate_route_table#
Associates a subnet in your VPC or an internet gateway or virtual private gateway attached to your VPC with a route table in your VPC.
Type annotations and code completion for boto3.client("ec2").associate_route_table
method.
boto3 documentation
# associate_route_table method definition
def associate_route_table(
self,
*,
RouteTableId: str,
DryRun: bool = ...,
SubnetId: str = ...,
GatewayId: str = ...,
) -> AssociateRouteTableResultTypeDef: # (1)
...
# associate_route_table method usage example with argument unpacking
kwargs: AssociateRouteTableRequestRequestTypeDef = { # (1)
"RouteTableId": ...,
}
parent.associate_route_table(**kwargs)
associate_subnet_cidr_block#
Associates a CIDR block with your subnet.
Type annotations and code completion for boto3.client("ec2").associate_subnet_cidr_block
method.
boto3 documentation
# associate_subnet_cidr_block method definition
def associate_subnet_cidr_block(
self,
*,
Ipv6CidrBlock: str,
SubnetId: str,
) -> AssociateSubnetCidrBlockResultTypeDef: # (1)
...
# associate_subnet_cidr_block method usage example with argument unpacking
kwargs: AssociateSubnetCidrBlockRequestRequestTypeDef = { # (1)
"Ipv6CidrBlock": ...,
"SubnetId": ...,
}
parent.associate_subnet_cidr_block(**kwargs)
associate_transit_gateway_multicast_domain#
Associates the specified subnets and transit gateway attachments with the specified transit gateway multicast domain.
Type annotations and code completion for boto3.client("ec2").associate_transit_gateway_multicast_domain
method.
boto3 documentation
# associate_transit_gateway_multicast_domain method definition
def associate_transit_gateway_multicast_domain(
self,
*,
TransitGatewayMulticastDomainId: str,
TransitGatewayAttachmentId: str,
SubnetIds: Sequence[str],
DryRun: bool = ...,
) -> AssociateTransitGatewayMulticastDomainResultTypeDef: # (1)
...
# associate_transit_gateway_multicast_domain method usage example with argument unpacking
kwargs: AssociateTransitGatewayMulticastDomainRequestRequestTypeDef = { # (1)
"TransitGatewayMulticastDomainId": ...,
"TransitGatewayAttachmentId": ...,
"SubnetIds": ...,
}
parent.associate_transit_gateway_multicast_domain(**kwargs)
associate_transit_gateway_policy_table#
Associates the specified transit gateway attachment with a transit gateway policy table.
Type annotations and code completion for boto3.client("ec2").associate_transit_gateway_policy_table
method.
boto3 documentation
# associate_transit_gateway_policy_table method definition
def associate_transit_gateway_policy_table(
self,
*,
TransitGatewayPolicyTableId: str,
TransitGatewayAttachmentId: str,
DryRun: bool = ...,
) -> AssociateTransitGatewayPolicyTableResultTypeDef: # (1)
...
# associate_transit_gateway_policy_table method usage example with argument unpacking
kwargs: AssociateTransitGatewayPolicyTableRequestRequestTypeDef = { # (1)
"TransitGatewayPolicyTableId": ...,
"TransitGatewayAttachmentId": ...,
}
parent.associate_transit_gateway_policy_table(**kwargs)
associate_transit_gateway_route_table#
Associates the specified attachment with the specified transit gateway route table.
Type annotations and code completion for boto3.client("ec2").associate_transit_gateway_route_table
method.