Skip to content

EC2Client

Index > EC2 > 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

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.

Usage example
client = boto3.client("ec2")

try:
    do_something(client)
except (
    client.ClientError,
) as e:
    print(e)
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

Method definition
def accept_address_transfer(
    self,
    *,
    Address: str,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
) -> AcceptAddressTransferResultTypeDef:  # (2)
    ...
  1. See TagSpecificationTypeDef
  2. See AcceptAddressTransferResultTypeDef
Usage example with kwargs
kwargs: AcceptAddressTransferRequestRequestTypeDef = {  # (1)
    "Address": ...,
}

parent.accept_address_transfer(**kwargs)
  1. See AcceptAddressTransferRequestRequestTypeDef

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

Method definition
def accept_reserved_instances_exchange_quote(
    self,
    *,
    ReservedInstanceIds: Sequence[str],
    DryRun: bool = ...,
    TargetConfigurations: Sequence[TargetConfigurationRequestTypeDef] = ...,  # (1)
) -> AcceptReservedInstancesExchangeQuoteResultTypeDef:  # (2)
    ...
  1. See TargetConfigurationRequestTypeDef
  2. See AcceptReservedInstancesExchangeQuoteResultTypeDef
Usage example with kwargs
kwargs: AcceptReservedInstancesExchangeQuoteRequestRequestTypeDef = {  # (1)
    "ReservedInstanceIds": ...,
}

parent.accept_reserved_instances_exchange_quote(**kwargs)
  1. See AcceptReservedInstancesExchangeQuoteRequestRequestTypeDef

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

Method definition
def accept_transit_gateway_multicast_domain_associations(
    self,
    *,
    TransitGatewayMulticastDomainId: str = ...,
    TransitGatewayAttachmentId: str = ...,
    SubnetIds: Sequence[str] = ...,
    DryRun: bool = ...,
) -> AcceptTransitGatewayMulticastDomainAssociationsResultTypeDef:  # (1)
    ...
  1. See AcceptTransitGatewayMulticastDomainAssociationsResultTypeDef
Usage example with kwargs
kwargs: AcceptTransitGatewayMulticastDomainAssociationsRequestRequestTypeDef = {  # (1)
    "TransitGatewayMulticastDomainId": ...,
}

parent.accept_transit_gateway_multicast_domain_associations(**kwargs)
  1. See AcceptTransitGatewayMulticastDomainAssociationsRequestRequestTypeDef

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

Method definition
def accept_transit_gateway_peering_attachment(
    self,
    *,
    TransitGatewayAttachmentId: str,
    DryRun: bool = ...,
) -> AcceptTransitGatewayPeeringAttachmentResultTypeDef:  # (1)
    ...
  1. See AcceptTransitGatewayPeeringAttachmentResultTypeDef
Usage example with kwargs
kwargs: AcceptTransitGatewayPeeringAttachmentRequestRequestTypeDef = {  # (1)
    "TransitGatewayAttachmentId": ...,
}

parent.accept_transit_gateway_peering_attachment(**kwargs)
  1. See AcceptTransitGatewayPeeringAttachmentRequestRequestTypeDef

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

Method definition
def accept_transit_gateway_vpc_attachment(
    self,
    *,
    TransitGatewayAttachmentId: str,
    DryRun: bool = ...,
) -> AcceptTransitGatewayVpcAttachmentResultTypeDef:  # (1)
    ...
  1. See AcceptTransitGatewayVpcAttachmentResultTypeDef
Usage example with kwargs
kwargs: AcceptTransitGatewayVpcAttachmentRequestRequestTypeDef = {  # (1)
    "TransitGatewayAttachmentId": ...,
}

parent.accept_transit_gateway_vpc_attachment(**kwargs)
  1. See AcceptTransitGatewayVpcAttachmentRequestRequestTypeDef

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

Method definition
def accept_vpc_endpoint_connections(
    self,
    *,
    ServiceId: str,
    VpcEndpointIds: Sequence[str],
    DryRun: bool = ...,
) -> AcceptVpcEndpointConnectionsResultTypeDef:  # (1)
    ...
  1. See AcceptVpcEndpointConnectionsResultTypeDef
Usage example with kwargs
kwargs: AcceptVpcEndpointConnectionsRequestRequestTypeDef = {  # (1)
    "ServiceId": ...,
    "VpcEndpointIds": ...,
}

parent.accept_vpc_endpoint_connections(**kwargs)
  1. See AcceptVpcEndpointConnectionsRequestRequestTypeDef

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

Method definition
def accept_vpc_peering_connection(
    self,
    *,
    VpcPeeringConnectionId: str,
    DryRun: bool = ...,
) -> AcceptVpcPeeringConnectionResultTypeDef:  # (1)
    ...
  1. See AcceptVpcPeeringConnectionResultTypeDef
Usage example with kwargs
kwargs: AcceptVpcPeeringConnectionRequestRequestTypeDef = {  # (1)
    "VpcPeeringConnectionId": ...,
}

parent.accept_vpc_peering_connection(**kwargs)
  1. See AcceptVpcPeeringConnectionRequestRequestTypeDef

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

Method definition
def advertise_byoip_cidr(
    self,
    *,
    Cidr: str,
    DryRun: bool = ...,
) -> AdvertiseByoipCidrResultTypeDef:  # (1)
    ...
  1. See AdvertiseByoipCidrResultTypeDef
Usage example with kwargs
kwargs: AdvertiseByoipCidrRequestRequestTypeDef = {  # (1)
    "Cidr": ...,
}

parent.advertise_byoip_cidr(**kwargs)
  1. See AdvertiseByoipCidrRequestRequestTypeDef

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

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)
    ...
  1. See DomainTypeType
  2. See TagSpecificationTypeDef
  3. See AllocateAddressResultTypeDef
Usage example with kwargs
kwargs: AllocateAddressRequestRequestTypeDef = {  # (1)
    "Domain": ...,
}

parent.allocate_address(**kwargs)
  1. See AllocateAddressRequestRequestTypeDef

allocate_hosts

Allocates a Dedicated Host to your account.

Type annotations and code completion for boto3.client("ec2").allocate_hosts method. boto3 documentation

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 = ...,
) -> AllocateHostsResultTypeDef:  # (4)
    ...
  1. See AutoPlacementType
  2. See TagSpecificationTypeDef
  3. See HostRecoveryType
  4. See AllocateHostsResultTypeDef
Usage example with kwargs
kwargs: AllocateHostsRequestRequestTypeDef = {  # (1)
    "AvailabilityZone": ...,
    "Quantity": ...,
}

parent.allocate_hosts(**kwargs)
  1. See AllocateHostsRequestRequestTypeDef

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

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)
    ...
  1. See AllocateIpamPoolCidrResultTypeDef
Usage example with kwargs
kwargs: AllocateIpamPoolCidrRequestRequestTypeDef = {  # (1)
    "IpamPoolId": ...,
}

parent.allocate_ipam_pool_cidr(**kwargs)
  1. See AllocateIpamPoolCidrRequestRequestTypeDef

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

Method definition
def apply_security_groups_to_client_vpn_target_network(
    self,
    *,
    ClientVpnEndpointId: str,
    VpcId: str,
    SecurityGroupIds: Sequence[str],
    DryRun: bool = ...,
) -> ApplySecurityGroupsToClientVpnTargetNetworkResultTypeDef:  # (1)
    ...
  1. See ApplySecurityGroupsToClientVpnTargetNetworkResultTypeDef
Usage example with kwargs
kwargs: ApplySecurityGroupsToClientVpnTargetNetworkRequestRequestTypeDef = {  # (1)
    "ClientVpnEndpointId": ...,
    "VpcId": ...,
    "SecurityGroupIds": ...,
}

parent.apply_security_groups_to_client_vpn_target_network(**kwargs)
  1. See ApplySecurityGroupsToClientVpnTargetNetworkRequestRequestTypeDef

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

Method definition
def assign_ipv6_addresses(
    self,
    *,
    NetworkInterfaceId: str,
    Ipv6AddressCount: int = ...,
    Ipv6Addresses: Sequence[str] = ...,
    Ipv6PrefixCount: int = ...,
    Ipv6Prefixes: Sequence[str] = ...,
) -> AssignIpv6AddressesResultTypeDef:  # (1)
    ...
  1. See AssignIpv6AddressesResultTypeDef
Usage example with kwargs
kwargs: AssignIpv6AddressesRequestRequestTypeDef = {  # (1)
    "NetworkInterfaceId": ...,
}

parent.assign_ipv6_addresses(**kwargs)
  1. See AssignIpv6AddressesRequestRequestTypeDef

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

Method definition
def assign_private_ip_addresses(
    self,
    *,
    NetworkInterfaceId: str,
    AllowReassignment: bool = ...,
    PrivateIpAddresses: Sequence[str] = ...,
    SecondaryPrivateIpAddressCount: int = ...,
    Ipv4Prefixes: Sequence[str] = ...,
    Ipv4PrefixCount: int = ...,
) -> AssignPrivateIpAddressesResultTypeDef:  # (1)
    ...
  1. See AssignPrivateIpAddressesResultTypeDef
Usage example with kwargs
kwargs: AssignPrivateIpAddressesRequestRequestTypeDef = {  # (1)
    "NetworkInterfaceId": ...,
}

parent.assign_private_ip_addresses(**kwargs)
  1. See AssignPrivateIpAddressesRequestRequestTypeDef

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

Method definition
def assign_private_nat_gateway_address(
    self,
    *,
    NatGatewayId: str,
    PrivateIpAddresses: Sequence[str] = ...,
    PrivateIpAddressCount: int = ...,
    DryRun: bool = ...,
) -> AssignPrivateNatGatewayAddressResultTypeDef:  # (1)
    ...
  1. See AssignPrivateNatGatewayAddressResultTypeDef
Usage example with kwargs
kwargs: AssignPrivateNatGatewayAddressRequestRequestTypeDef = {  # (1)
    "NatGatewayId": ...,
}

parent.assign_private_nat_gateway_address(**kwargs)
  1. See AssignPrivateNatGatewayAddressRequestRequestTypeDef

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

Method definition
def associate_address(
    self,
    *,
    AllocationId: str = ...,
    InstanceId: str = ...,
    PublicIp: str = ...,
    AllowReassociation: bool = ...,
    DryRun: bool = ...,
    NetworkInterfaceId: str = ...,
    PrivateIpAddress: str = ...,
) -> AssociateAddressResultTypeDef:  # (1)
    ...
  1. See AssociateAddressResultTypeDef
Usage example with kwargs
kwargs: AssociateAddressRequestRequestTypeDef = {  # (1)
    "AllocationId": ...,
}

parent.associate_address(**kwargs)
  1. See AssociateAddressRequestRequestTypeDef

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

Method definition
def associate_client_vpn_target_network(
    self,
    *,
    ClientVpnEndpointId: str,
    SubnetId: str,
    ClientToken: str = ...,
    DryRun: bool = ...,
) -> AssociateClientVpnTargetNetworkResultTypeDef:  # (1)
    ...
  1. See AssociateClientVpnTargetNetworkResultTypeDef
Usage example with kwargs
kwargs: AssociateClientVpnTargetNetworkRequestRequestTypeDef = {  # (1)
    "ClientVpnEndpointId": ...,
    "SubnetId": ...,
}

parent.associate_client_vpn_target_network(**kwargs)
  1. See AssociateClientVpnTargetNetworkRequestRequestTypeDef

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

Method definition
def associate_dhcp_options(
    self,
    *,
    DhcpOptionsId: str,
    VpcId: str,
    DryRun: bool = ...,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
Usage example with kwargs
kwargs: AssociateDhcpOptionsRequestRequestTypeDef = {  # (1)
    "DhcpOptionsId": ...,
    "VpcId": ...,
}

parent.associate_dhcp_options(**kwargs)
  1. See AssociateDhcpOptionsRequestRequestTypeDef

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

Method definition
def associate_enclave_certificate_iam_role(
    self,
    *,
    CertificateArn: str,
    RoleArn: str,
    DryRun: bool = ...,
) -> AssociateEnclaveCertificateIamRoleResultTypeDef:  # (1)
    ...
  1. See AssociateEnclaveCertificateIamRoleResultTypeDef
Usage example with kwargs
kwargs: AssociateEnclaveCertificateIamRoleRequestRequestTypeDef = {  # (1)
    "CertificateArn": ...,
    "RoleArn": ...,
}

parent.associate_enclave_certificate_iam_role(**kwargs)
  1. See AssociateEnclaveCertificateIamRoleRequestRequestTypeDef

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

Method definition
def associate_iam_instance_profile(
    self,