Skip to content

EC2ServiceResource#

Index > EC2 > EC2ServiceResource

Auto-generated documentation for EC2 type annotations stubs module mypy-boto3-ec2.

EC2ServiceResource#

Type annotations and code completion for boto3.resource("ec2"), included resources and collections. boto3 documentation

# EC2ServiceResource usage example

from mypy_boto3_ec2.service_resource import EC2ServiceResource

def get_ec2_resource() -> EC2ServiceResource:
    return boto3.resource("ec2")

Attributes#

  • meta: EC2ResourceMeta

  • classic_addresses: ServiceResourceClassicAddressesCollection

  • dhcp_options_sets: ServiceResourceDhcpOptionsSetsCollection

  • images: ServiceResourceImagesCollection

  • instances: ServiceResourceInstancesCollection

  • internet_gateways: ServiceResourceInternetGatewaysCollection

  • key_pairs: ServiceResourceKeyPairsCollection

  • network_acls: ServiceResourceNetworkAclsCollection

  • network_interfaces: ServiceResourceNetworkInterfacesCollection

  • placement_groups: ServiceResourcePlacementGroupsCollection

  • route_tables: ServiceResourceRouteTablesCollection

  • security_groups: ServiceResourceSecurityGroupsCollection

  • snapshots: ServiceResourceSnapshotsCollection

  • subnets: ServiceResourceSubnetsCollection

  • volumes: ServiceResourceVolumesCollection

  • vpc_addresses: ServiceResourceVpcAddressesCollection

  • vpc_peering_connections: ServiceResourceVpcPeeringConnectionsCollection

  • vpcs: ServiceResourceVpcsCollection

Collections#

ServiceResourceClassicAddressesCollection#

Provides access to ClassicAddress resource.

Type annotations and code completion for boto3.resource("ec2").classic_addresses collection. boto3 documentation

# ServiceResourceClassicAddressesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceClassicAddressesCollection

def get_collection() -> ServiceResourceClassicAddressesCollection:
    return boto3.resource("ec2").classic_addresses

ServiceResourceDhcpOptionsSetsCollection#

Provides access to DhcpOptions resource.

Type annotations and code completion for boto3.resource("ec2").dhcp_options_sets collection. boto3 documentation

# ServiceResourceDhcpOptionsSetsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceDhcpOptionsSetsCollection

def get_collection() -> ServiceResourceDhcpOptionsSetsCollection:
    return boto3.resource("ec2").dhcp_options_sets

ServiceResourceImagesCollection#

Provides access to Image resource.

Type annotations and code completion for boto3.resource("ec2").images collection. boto3 documentation

# ServiceResourceImagesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceImagesCollection

def get_collection() -> ServiceResourceImagesCollection:
    return boto3.resource("ec2").images

ServiceResourceInstancesCollection#

Provides access to Instance resource.

Type annotations and code completion for boto3.resource("ec2").instances collection. boto3 documentation

# ServiceResourceInstancesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceInstancesCollection

def get_collection() -> ServiceResourceInstancesCollection:
    return boto3.resource("ec2").instances

ServiceResourceInternetGatewaysCollection#

Provides access to InternetGateway resource.

Type annotations and code completion for boto3.resource("ec2").internet_gateways collection. boto3 documentation

# ServiceResourceInternetGatewaysCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceInternetGatewaysCollection

def get_collection() -> ServiceResourceInternetGatewaysCollection:
    return boto3.resource("ec2").internet_gateways

ServiceResourceKeyPairsCollection#

Provides access to KeyPairInfo resource.

Type annotations and code completion for boto3.resource("ec2").key_pairs collection. boto3 documentation

# ServiceResourceKeyPairsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceKeyPairsCollection

def get_collection() -> ServiceResourceKeyPairsCollection:
    return boto3.resource("ec2").key_pairs

ServiceResourceNetworkAclsCollection#

Provides access to NetworkAcl resource.

Type annotations and code completion for boto3.resource("ec2").network_acls collection. boto3 documentation

# ServiceResourceNetworkAclsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceNetworkAclsCollection

def get_collection() -> ServiceResourceNetworkAclsCollection:
    return boto3.resource("ec2").network_acls

ServiceResourceNetworkInterfacesCollection#

Provides access to NetworkInterface resource.

Type annotations and code completion for boto3.resource("ec2").network_interfaces collection. boto3 documentation

# ServiceResourceNetworkInterfacesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceNetworkInterfacesCollection

def get_collection() -> ServiceResourceNetworkInterfacesCollection:
    return boto3.resource("ec2").network_interfaces

ServiceResourcePlacementGroupsCollection#

Provides access to PlacementGroup resource.

Type annotations and code completion for boto3.resource("ec2").placement_groups collection. boto3 documentation

# ServiceResourcePlacementGroupsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourcePlacementGroupsCollection

def get_collection() -> ServiceResourcePlacementGroupsCollection:
    return boto3.resource("ec2").placement_groups

ServiceResourceRouteTablesCollection#

Provides access to RouteTable resource.

Type annotations and code completion for boto3.resource("ec2").route_tables collection. boto3 documentation

# ServiceResourceRouteTablesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceRouteTablesCollection

def get_collection() -> ServiceResourceRouteTablesCollection:
    return boto3.resource("ec2").route_tables

ServiceResourceSecurityGroupsCollection#

Provides access to SecurityGroup resource.

Type annotations and code completion for boto3.resource("ec2").security_groups collection. boto3 documentation

# ServiceResourceSecurityGroupsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceSecurityGroupsCollection

def get_collection() -> ServiceResourceSecurityGroupsCollection:
    return boto3.resource("ec2").security_groups

ServiceResourceSnapshotsCollection#

Provides access to Snapshot resource.

Type annotations and code completion for boto3.resource("ec2").snapshots collection. boto3 documentation

# ServiceResourceSnapshotsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceSnapshotsCollection

def get_collection() -> ServiceResourceSnapshotsCollection:
    return boto3.resource("ec2").snapshots

ServiceResourceSubnetsCollection#

Provides access to Subnet resource.

Type annotations and code completion for boto3.resource("ec2").subnets collection. boto3 documentation

# ServiceResourceSubnetsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceSubnetsCollection

def get_collection() -> ServiceResourceSubnetsCollection:
    return boto3.resource("ec2").subnets

ServiceResourceVolumesCollection#

Provides access to Volume resource.

Type annotations and code completion for boto3.resource("ec2").volumes collection. boto3 documentation

# ServiceResourceVolumesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceVolumesCollection

def get_collection() -> ServiceResourceVolumesCollection:
    return boto3.resource("ec2").volumes

ServiceResourceVpcAddressesCollection#

Provides access to VpcAddress resource.

Type annotations and code completion for boto3.resource("ec2").vpc_addresses collection. boto3 documentation

# ServiceResourceVpcAddressesCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceVpcAddressesCollection

def get_collection() -> ServiceResourceVpcAddressesCollection:
    return boto3.resource("ec2").vpc_addresses

ServiceResourceVpcPeeringConnectionsCollection#

Provides access to VpcPeeringConnection resource.

Type annotations and code completion for boto3.resource("ec2").vpc_peering_connections collection. boto3 documentation

# ServiceResourceVpcPeeringConnectionsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceVpcPeeringConnectionsCollection

def get_collection() -> ServiceResourceVpcPeeringConnectionsCollection:
    return boto3.resource("ec2").vpc_peering_connections

ServiceResourceVpcsCollection#

Provides access to Vpc resource.

Type annotations and code completion for boto3.resource("ec2").vpcs collection. boto3 documentation

# ServiceResourceVpcsCollection usage example

from mypy_boto3_ec2.service_resource import ServiceResourceVpcsCollection

def get_collection() -> ServiceResourceVpcsCollection:
    return boto3.resource("ec2").vpcs

Methods#

EC2ServiceResource.get_available_subresources method#

Returns a list of all the available sub-resources for this resource.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

EC2ServiceResource.create_dhcp_options method#

Creates a custom set of DHCP options.

Type annotations and code completion for boto3.resource("ec2").create_dhcp_options method. boto3 documentation

# create_dhcp_options method definition

def create_dhcp_options(
    self,
    *,
    DhcpConfigurations: Sequence[NewDhcpConfigurationTypeDef],  # (1)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (2)
    DryRun: bool = ...,
) -> _DhcpOptions:
    ...
  1. See NewDhcpConfigurationTypeDef
  2. See TagSpecificationTypeDef
# create_dhcp_options method usage example with argument unpacking

kwargs: CreateDhcpOptionsRequestServiceResourceCreateDhcpOptionsTypeDef = {  # (1)
    "DhcpConfigurations": ...,
}

parent.create_dhcp_options(**kwargs)
  1. See CreateDhcpOptionsRequestServiceResourceCreateDhcpOptionsTypeDef

EC2ServiceResource.create_instances method#

Launches the specified number of instances using an AMI for which you have permissions.

Type annotations and code completion for boto3.resource("ec2").create_instances method. boto3 documentation

# create_instances method definition

def create_instances(
    self,
    *,
    MaxCount: int,
    MinCount: int,
    BlockDeviceMappings: Sequence[BlockDeviceMappingTypeDef] = ...,  # (1)
    ImageId: str = ...,
    InstanceType: InstanceTypeType = ...,  # (2)
    Ipv6AddressCount: int = ...,
    Ipv6Addresses: Sequence[InstanceIpv6AddressTypeDef] = ...,  # (3)
    KernelId: str = ...,
    KeyName: str = ...,
    Monitoring: RunInstancesMonitoringEnabledTypeDef = ...,  # (4)
    Placement: PlacementTypeDef = ...,  # (5)
    RamdiskId: str = ...,
    SecurityGroupIds: Sequence[str] = ...,
    SecurityGroups: Sequence[str] = ...,
    SubnetId: str = ...,
    UserData: str = ...,
    ElasticGpuSpecification: Sequence[ElasticGpuSpecificationTypeDef] = ...,  # (6)
    ElasticInferenceAccelerators: Sequence[ElasticInferenceAcceleratorTypeDef] = ...,  # (7)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (8)
    LaunchTemplate: LaunchTemplateSpecificationTypeDef = ...,  # (9)
    InstanceMarketOptions: InstanceMarketOptionsRequestTypeDef = ...,  # (10)
    CreditSpecification: CreditSpecificationRequestTypeDef = ...,  # (11)
    CpuOptions: CpuOptionsRequestTypeDef = ...,  # (12)
    CapacityReservationSpecification: CapacityReservationSpecificationTypeDef = ...,  # (13)
    HibernationOptions: HibernationOptionsRequestTypeDef = ...,  # (14)
    LicenseSpecifications: Sequence[LicenseConfigurationRequestTypeDef] = ...,  # (15)
    MetadataOptions: InstanceMetadataOptionsRequestTypeDef = ...,  # (16)
    EnclaveOptions: EnclaveOptionsRequestTypeDef = ...,  # (17)
    PrivateDnsNameOptions: PrivateDnsNameOptionsRequestTypeDef = ...,  # (18)
    MaintenanceOptions: InstanceMaintenanceOptionsRequestTypeDef = ...,  # (19)
    DisableApiStop: bool = ...,
    EnablePrimaryIpv6: bool = ...,
    NetworkPerformanceOptions: InstanceNetworkPerformanceOptionsRequestTypeDef = ...,  # (20)
    Operator: OperatorRequestTypeDef = ...,  # (21)
    DryRun: bool = ...,
    DisableApiTermination: bool = ...,
    InstanceInitiatedShutdownBehavior: ShutdownBehaviorType = ...,  # (22)
    PrivateIpAddress: str = ...,
    ClientToken: str = ...,
    AdditionalInfo: str = ...,
    NetworkInterfaces: Sequence[InstanceNetworkInterfaceSpecificationTypeDef] = ...,  # (23)
    IamInstanceProfile: IamInstanceProfileSpecificationTypeDef = ...,  # (24)
    EbsOptimized: bool = ...,
) -> list[_Instance]:
    ...
  1. See BlockDeviceMappingTypeDef
  2. See InstanceTypeType
  3. See InstanceIpv6AddressTypeDef
  4. See RunInstancesMonitoringEnabledTypeDef
  5. See PlacementTypeDef
  6. See ElasticGpuSpecificationTypeDef
  7. See ElasticInferenceAcceleratorTypeDef
  8. See TagSpecificationTypeDef
  9. See LaunchTemplateSpecificationTypeDef
  10. See InstanceMarketOptionsRequestTypeDef
  11. See CreditSpecificationRequestTypeDef
  12. See CpuOptionsRequestTypeDef
  13. See CapacityReservationSpecificationTypeDef
  14. See HibernationOptionsRequestTypeDef
  15. See LicenseConfigurationRequestTypeDef
  16. See InstanceMetadataOptionsRequestTypeDef
  17. See EnclaveOptionsRequestTypeDef
  18. See PrivateDnsNameOptionsRequestTypeDef
  19. See InstanceMaintenanceOptionsRequestTypeDef
  20. See InstanceNetworkPerformanceOptionsRequestTypeDef
  21. See OperatorRequestTypeDef
  22. See ShutdownBehaviorType
  23. See InstanceNetworkInterfaceSpecificationTypeDef
  24. See IamInstanceProfileSpecificationTypeDef
# create_instances method usage example with argument unpacking

kwargs: RunInstancesRequestServiceResourceCreateInstancesTypeDef = {  # (1)
    "MaxCount": ...,
    "MinCount": ...,
}

parent.create_instances(**kwargs)
  1. See RunInstancesRequestServiceResourceCreateInstancesTypeDef

EC2ServiceResource.create_internet_gateway method#

Creates an internet gateway for use with a VPC.

Type annotations and code completion for boto3.resource("ec2").create_internet_gateway method. boto3 documentation

# create_internet_gateway method definition

def create_internet_gateway(
    self,
    *,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
) -> _InternetGateway:
    ...
  1. See TagSpecificationTypeDef
# create_internet_gateway method usage example with argument unpacking

kwargs: CreateInternetGatewayRequestServiceResourceCreateInternetGatewayTypeDef = {  # (1)
    "TagSpecifications": ...,
}

parent.create_internet_gateway(**kwargs)
  1. See CreateInternetGatewayRequestServiceResourceCreateInternetGatewayTypeDef

EC2ServiceResource.create_key_pair method#

Creates an ED25519 or 2048-bit RSA key pair with the specified name and in the specified format.

Type annotations and code completion for boto3.resource("ec2").create_key_pair method. boto3 documentation

# create_key_pair method definition

def create_key_pair(
    self,
    *,
    KeyName: str,
    KeyType: KeyTypeType = ...,  # (1)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (2)
    KeyFormat: KeyFormatType = ...,  # (3)
    DryRun: bool = ...,
) -> _KeyPair:
    ...
  1. See KeyTypeType
  2. See TagSpecificationTypeDef
  3. See KeyFormatType
# create_key_pair method usage example with argument unpacking

kwargs: CreateKeyPairRequestServiceResourceCreateKeyPairTypeDef = {  # (1)
    "KeyName": ...,
}

parent.create_key_pair(**kwargs)
  1. See CreateKeyPairRequestServiceResourceCreateKeyPairTypeDef

EC2ServiceResource.create_network_acl method#

Creates a network ACL in a VPC.

Type annotations and code completion for boto3.resource("ec2").create_network_acl method. boto3 documentation

# create_network_acl method definition

def create_network_acl(
    self,
    *,
    VpcId: str,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    ClientToken: str = ...,
    DryRun: bool = ...,
) -> _NetworkAcl:
    ...
  1. See TagSpecificationTypeDef
# create_network_acl method usage example with argument unpacking

kwargs: CreateNetworkAclRequestServiceResourceCreateNetworkAclTypeDef = {  # (1)
    "VpcId": ...,
}

parent.create_network_acl(**kwargs)
  1. See CreateNetworkAclRequestServiceResourceCreateNetworkAclTypeDef

EC2ServiceResource.create_network_interface method#

Creates a network interface in the specified subnet.

Type annotations and code completion for boto3.resource("ec2").create_network_interface method. boto3 documentation

# create_network_interface method definition

def create_network_interface(
    self,
    *,
    SubnetId: str,
    Ipv4Prefixes: Sequence[Ipv4PrefixSpecificationRequestTypeDef] = ...,  # (1)
    Ipv4PrefixCount: int = ...,
    Ipv6Prefixes: Sequence[Ipv6PrefixSpecificationRequestTypeDef] = ...,  # (2)
    Ipv6PrefixCount: int = ...,
    InterfaceType: NetworkInterfaceCreationTypeType = ...,  # (3)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (4)
    ClientToken: str = ...,
    EnablePrimaryIpv6: bool = ...,
    ConnectionTrackingSpecification: ConnectionTrackingSpecificationRequestTypeDef = ...,  # (5)
    Operator: OperatorRequestTypeDef = ...,  # (6)
    Description: str = ...,
    PrivateIpAddress: str = ...,
    Groups: Sequence[str] = ...,
    PrivateIpAddresses: Sequence[PrivateIpAddressSpecificationTypeDef] = ...,  # (7)
    SecondaryPrivateIpAddressCount: int = ...,
    Ipv6Addresses: Sequence[InstanceIpv6AddressTypeDef] = ...,  # (8)
    Ipv6AddressCount: int = ...,
    DryRun: bool = ...,
) -> _NetworkInterface:
    ...
  1. See Ipv4PrefixSpecificationRequestTypeDef
  2. See Ipv6PrefixSpecificationRequestTypeDef
  3. See NetworkInterfaceCreationTypeType
  4. See TagSpecificationTypeDef
  5. See ConnectionTrackingSpecificationRequestTypeDef
  6. See OperatorRequestTypeDef
  7. See PrivateIpAddressSpecificationTypeDef
  8. See InstanceIpv6AddressTypeDef
# create_network_interface method usage example with argument unpacking

kwargs: CreateNetworkInterfaceRequestServiceResourceCreateNetworkInterfaceTypeDef = {  # (1)
    "SubnetId": ...,
}

parent.create_network_interface(**kwargs)
  1. See CreateNetworkInterfaceRequestServiceResourceCreateNetworkInterfaceTypeDef

EC2ServiceResource.create_placement_group method#

Creates a placement group in which to launch instances.

Type annotations and code completion for boto3.resource("ec2").create_placement_group method. boto3 documentation

# create_placement_group method definition

def create_placement_group(
    self,
    *,
    PartitionCount: int = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    SpreadLevel: SpreadLevelType = ...,  # (2)
    DryRun: bool = ...,
    GroupName: str = ...,
    Strategy: PlacementStrategyType = ...,  # (3)
) -> _PlacementGroup:
    ...
  1. See TagSpecificationTypeDef
  2. See SpreadLevelType
  3. See PlacementStrategyType
# create_placement_group method usage example with argument unpacking

kwargs: CreatePlacementGroupRequestServiceResourceCreatePlacementGroupTypeDef = {  # (1)
    "PartitionCount": ...,
}

parent.create_placement_group(**kwargs)
  1. See CreatePlacementGroupRequestServiceResourceCreatePlacementGroupTypeDef

EC2ServiceResource.create_route_table method#

Creates a route table for the specified VPC.

Type annotations and code completion for boto3.resource("ec2").create_route_table method. boto3 documentation

# create_route_table method definition

def create_route_table(
    self,
    *,
    VpcId: str,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    ClientToken: str = ...,
    DryRun: bool = ...,
) -> _RouteTable:
    ...
  1. See TagSpecificationTypeDef
# create_route_table method usage example with argument unpacking

kwargs: CreateRouteTableRequestServiceResourceCreateRouteTableTypeDef = {  # (1)
    "VpcId": ...,
}

parent.create_route_table(**kwargs)
  1. See CreateRouteTableRequestServiceResourceCreateRouteTableTypeDef

EC2ServiceResource.create_security_group method#

Creates a security group.

Type annotations and code completion for boto3.resource("ec2").create_security_group method. boto3 documentation

# create_security_group method definition

def create_security_group(
    self,
    *,
    Description: str,
    GroupName: str,
    VpcId: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
) -> _SecurityGroup:
    ...
  1. See TagSpecificationTypeDef
# create_security_group method usage example with argument unpacking

kwargs: CreateSecurityGroupRequestServiceResourceCreateSecurityGroupTypeDef = {  # (1)
    "Description": ...,
    "GroupName": ...,
}

parent.create_security_group(**kwargs)
  1. See CreateSecurityGroupRequestServiceResourceCreateSecurityGroupTypeDef

EC2ServiceResource.create_snapshot method#

Creates a snapshot of an EBS volume and stores it in Amazon S3.

Type annotations and code completion for boto3.resource("ec2").create_snapshot method. boto3 documentation

# create_snapshot method definition

def create_snapshot(
    self,
    *,
    VolumeId: str,
    Description: str = ...,
    OutpostArn: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    Location: SnapshotLocationEnumType = ...,  # (2)
    DryRun: bool = ...,
) -> _Snapshot:
    ...
  1. See TagSpecificationTypeDef
  2. See SnapshotLocationEnumType
# create_snapshot method usage example with argument unpacking

kwargs: CreateSnapshotRequestServiceResourceCreateSnapshotTypeDef = {  # (1)
    "VolumeId": ...,
}

parent.create_snapshot(**kwargs)
  1. See CreateSnapshotRequestServiceResourceCreateSnapshotTypeDef

EC2ServiceResource.create_subnet method#

Creates a subnet in the specified VPC.

Type annotations and code completion for boto3.resource("ec2").create_subnet method. boto3 documentation

# create_subnet method definition

def create_subnet(
    self,
    *,
    VpcId: str,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    AvailabilityZone: str = ...,
    AvailabilityZoneId: str = ...,
    CidrBlock: str = ...,
    Ipv6CidrBlock: str = ...,
    OutpostArn: str = ...,
    Ipv6Native: bool = ...,
    Ipv4IpamPoolId: str = ...,
    Ipv4NetmaskLength: int = ...,
    Ipv6IpamPoolId: str = ...,
    Ipv6NetmaskLength: int = ...,
    DryRun: bool = ...,
) -> _Subnet:
    ...
  1. See TagSpecificationTypeDef
# create_subnet method usage example with argument unpacking

kwargs: CreateSubnetRequestServiceResourceCreateSubnetTypeDef = {  # (1)
    "VpcId": ...,
}

parent.create_subnet(**kwargs)
  1. See CreateSubnetRequestServiceResourceCreateSubnetTypeDef

EC2ServiceResource.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Resources: Sequence[str],
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: CreateTagsRequestServiceResourceCreateTagsTypeDef = {  # (1)
    "Resources": ...,
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See CreateTagsRequestServiceResourceCreateTagsTypeDef

EC2ServiceResource.create_volume method#

Creates an EBS volume that can be attached to an instance in the same Availability Zone.

Type annotations and code completion for boto3.resource("ec2").create_volume method. boto3 documentation

# create_volume method definition

def create_volume(
    self,
    *,
    AvailabilityZone: str,
    Encrypted: bool = ...,
    Iops: int = ...,
    KmsKeyId: str = ...,
    OutpostArn: str = ...,
    Size: int = ...,
    SnapshotId: str = ...,
    VolumeType: VolumeTypeType = ...,  # (1)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (2)
    MultiAttachEnabled: bool = ...,
    Throughput: int = ...,
    ClientToken: str = ...,
    Operator: OperatorRequestTypeDef = ...,  # (3)
    DryRun: bool = ...,
) -> _Volume:
    ...
  1. See VolumeTypeType
  2. See TagSpecificationTypeDef
  3. See OperatorRequestTypeDef
# create_volume method usage example with argument unpacking

kwargs: CreateVolumeRequestServiceResourceCreateVolumeTypeDef = {  # (1)
    "AvailabilityZone": ...,
}

parent.create_volume(**kwargs)
  1. See CreateVolumeRequestServiceResourceCreateVolumeTypeDef

EC2ServiceResource.create_vpc method#

Creates a VPC with the specified CIDR blocks.

Type annotations and code completion for boto3.resource("ec2").create_vpc method. boto3 documentation

# create_vpc method definition

def create_vpc(
    self,
    *,
    CidrBlock: str = ...,
    Ipv6Pool: str = ...,
    Ipv6CidrBlock: str = ...,
    Ipv4IpamPoolId: str = ...,
    Ipv4NetmaskLength: int = ...,
    Ipv6IpamPoolId: str = ...,
    Ipv6NetmaskLength: int = ...,
    Ipv6CidrBlockNetworkBorderGroup: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
    InstanceTenancy: TenancyType = ...,  # (2)
    AmazonProvidedIpv6CidrBlock: bool = ...,
) -> _Vpc:
    ...
  1. See TagSpecificationTypeDef
  2. See TenancyType
# create_vpc method usage example with argument unpacking

kwargs: CreateVpcRequestServiceResourceCreateVpcTypeDef = {  # (1)
    "CidrBlock": ...,
}

parent.create_vpc(**kwargs)
  1. See CreateVpcRequestServiceResourceCreateVpcTypeDef

EC2ServiceResource.create_vpc_peering_connection method#

Requests a VPC peering connection between two VPCs: a requester VPC that you own and an accepter VPC with which to create the connection.

Type annotations and code completion for boto3.resource("ec2").create_vpc_peering_connection method. boto3 documentation

# create_vpc_peering_connection method definition

def create_vpc_peering_connection(
    self,
    *,
    VpcId: str,
    PeerRegion: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
    PeerVpcId: str = ...,
    PeerOwnerId: str = ...,
) -> _VpcPeeringConnection:
    ...
  1. See TagSpecificationTypeDef
# create_vpc_peering_connection method usage example with argument unpacking

kwargs: CreateVpcPeeringConnectionRequestServiceResourceCreateVpcPeeringConnectionTypeDef = {  # (1)
    "VpcId": ...,
}

parent.create_vpc_peering_connection(**kwargs)
  1. See CreateVpcPeeringConnectionRequestServiceResourceCreateVpcPeeringConnectionTypeDef

EC2ServiceResource.disassociate_route_table method#

Disassociates a subnet or gateway from a route table.

Type annotations and code completion for boto3.resource("ec2").disassociate_route_table method. boto3 documentation

# disassociate_route_table method definition

def disassociate_route_table(
    self,
    *,
    AssociationId: str,
    DryRun: bool = ...,
) -> None:
    ...
# disassociate_route_table method usage example with argument unpacking

kwargs: DisassociateRouteTableRequestServiceResourceDisassociateRouteTableTypeDef = {  # (1)
    "AssociationId": ...,
}

parent.disassociate_route_table(**kwargs)
  1. See DisassociateRouteTableRequestServiceResourceDisassociateRouteTableTypeDef

EC2ServiceResource.import_key_pair method#

Imports the public key from an RSA or ED25519 key pair that you created using a third-party tool.

Type annotations and code completion for boto3.resource("ec2").import_key_pair method. boto3 documentation

# import_key_pair method definition

def import_key_pair(
    self,
    *,
    KeyName: str,
    PublicKeyMaterial: BlobTypeDef,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
) -> _KeyPairInfo:
    ...
  1. See TagSpecificationTypeDef
# import_key_pair method usage example with argument unpacking

kwargs: ImportKeyPairRequestServiceResourceImportKeyPairTypeDef = {  # (1)
    "KeyName": ...,
    "PublicKeyMaterial": ...,
}

parent.import_key_pair(**kwargs)
  1. See ImportKeyPairRequestServiceResourceImportKeyPairTypeDef

EC2ServiceResource.register_image method#

Registers an AMI.

Type annotations and code completion for boto3.resource("ec2").register_image method. boto3 documentation

# register_image method definition

def register_image(
    self,
    *,
    Name: str,
    ImageLocation: str = ...,
    BillingProducts: Sequence[str] = ...,
    BootMode: BootModeValuesType = ...,  # (1)
    TpmSupport: TpmSupportValuesType = ...,  # (2)
    UefiData: str = ...,
    ImdsSupport: ImdsSupportValuesType = ...,  # (3)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (4)
    DryRun: bool = ...,
    Description: str = ...,
    Architecture: ArchitectureValuesType = ...,  # (5)
    KernelId: str = ...,
    RamdiskId: str = ...,
    RootDeviceName: str = ...,
    BlockDeviceMappings: Sequence[BlockDeviceMappingTypeDef] = ...,  # (6)
    VirtualizationType: str = ...,
    SriovNetSupport: str = ...,
    EnaSupport: bool = ...,
) -> _Image:
    ...
  1. See BootModeValuesType
  2. See TpmSupportValuesType
  3. See ImdsSupportValuesType
  4. See TagSpecificationTypeDef
  5. See ArchitectureValuesType
  6. See BlockDeviceMappingTypeDef
# register_image method usage example with argument unpacking

kwargs: RegisterImageRequestServiceResourceRegisterImageTypeDef = {  # (1)
    "Name": ...,
}

parent.register_image(**kwargs)
  1. See RegisterImageRequestServiceResourceRegisterImageTypeDef

EC2ServiceResource.ClassicAddress method#

Creates a ClassicAddress resource.

Type annotations and code completion for boto3.resource("ec2").ClassicAddress method. boto3 documentation

# ClassicAddress method definition

def ClassicAddress(
    self,
    public_ip: str,
) -> _ClassicAddress:
    ...

EC2ServiceResource.DhcpOptions method#

Creates a DhcpOptions resource.

Type annotations and code completion for boto3.resource("ec2").DhcpOptions method. boto3 documentation

# DhcpOptions method definition

def DhcpOptions(
    self,
    id: str,
) -> _DhcpOptions:
    ...

EC2ServiceResource.Image method#

Creates a Image resource.

Type annotations and code completion for boto3.resource("ec2").Image method. boto3 documentation

# Image method definition

def Image(
    self,
    id: str,
) -> _Image:
    ...

EC2ServiceResource.Instance method#

Creates a Instance resource.

Type annotations and code completion for boto3.resource("ec2").Instance method. boto3 documentation

# Instance method definition

def Instance(
    self,
    id: str,
) -> _Instance:
    ...

EC2ServiceResource.InternetGateway method#

Creates a InternetGateway resource.

Type annotations and code completion for boto3.resource("ec2").InternetGateway method. boto3 documentation

# InternetGateway method definition

def InternetGateway(
    self,
    id: str,
) -> _InternetGateway:
    ...

EC2ServiceResource.KeyPair method#

Creates a KeyPair resource.

Type annotations and code completion for boto3.resource("ec2").KeyPair method. boto3 documentation

# KeyPair method definition

def KeyPair(
    self,
    name: str,
) -> _KeyPair:
    ...

EC2ServiceResource.NetworkAcl method#

Creates a NetworkAcl resource.

Type annotations and code completion for boto3.resource("ec2").NetworkAcl method. boto3 documentation

# NetworkAcl method definition

def NetworkAcl(
    self,
    id: str,
) -> _NetworkAcl:
    ...

EC2ServiceResource.NetworkInterface method#

Creates a NetworkInterface resource.

Type annotations and code completion for boto3.resource("ec2").NetworkInterface method. boto3 documentation

# NetworkInterface method definition

def NetworkInterface(
    self,
    id: str,
) -> _NetworkInterface:
    ...

EC2ServiceResource.NetworkInterfaceAssociation method#

Creates a NetworkInterfaceAssociation resource.

Type annotations and code completion for boto3.resource("ec2").NetworkInterfaceAssociation method. boto3 documentation

# NetworkInterfaceAssociation method definition

def NetworkInterfaceAssociation(
    self,
    id: str,
) -> _NetworkInterfaceAssociation:
    ...

EC2ServiceResource.PlacementGroup method#

Creates a PlacementGroup resource.

Type annotations and code completion for boto3.resource("ec2").PlacementGroup method. boto3 documentation

# PlacementGroup method definition

def PlacementGroup(
    self,
    name: str,
) -> _PlacementGroup:
    ...

EC2ServiceResource.Route method#

Creates a Route resource.

Type annotations and code completion for boto3.resource("ec2").Route method. boto3 documentation

# Route method definition

def Route(
    self,
    route_table_id: str,
    destination_cidr_block: str,
) -> _Route:
    ...

EC2ServiceResource.RouteTable method#

Creates a RouteTable resource.

Type annotations and code completion for boto3.resource("ec2").RouteTable method. boto3 documentation

# RouteTable method definition

def RouteTable(
    self,
    id: str,
) -> _RouteTable:
    ...

EC2ServiceResource.RouteTableAssociation method#

Creates a RouteTableAssociation resource.

Type annotations and code completion for boto3.resource("ec2").RouteTableAssociation method. boto3 documentation

# RouteTableAssociation method definition

def RouteTableAssociation(
    self,
    id: str,
) -> _RouteTableAssociation:
    ...

EC2ServiceResource.SecurityGroup method#

Creates a SecurityGroup resource.

Type annotations and code completion for boto3.resource("ec2").SecurityGroup method. boto3 documentation

# SecurityGroup method definition

def SecurityGroup(
    self,
    id: str,
) -> _SecurityGroup:
    ...

EC2ServiceResource.Snapshot method#

Creates a Snapshot resource.

Type annotations and code completion for boto3.resource("ec2").Snapshot method. boto3 documentation

# Snapshot method definition

def Snapshot(
    self,
    id: str,
) -> _Snapshot:
    ...

EC2ServiceResource.Subnet method#

Creates a Subnet resource.

Type annotations and code completion for boto3.resource("ec2").Subnet method. boto3 documentation

# Subnet method definition

def Subnet(
    self,
    id: str,
) -> _Subnet:
    ...

EC2ServiceResource.Tag method#

Creates a Tag resource.

Type annotations and code completion for boto3.resource("ec2").Tag method. boto3 documentation

# Tag method definition

def Tag(
    self,
    resource_id: str,
    key: str,
    value: str,
) -> _Tag:
    ...

EC2ServiceResource.Volume method#

Creates a Volume resource.

Type annotations and code completion for boto3.resource("ec2").Volume method. boto3 documentation

# Volume method definition

def Volume(
    self,
    id: str,
) -> _Volume:
    ...

EC2ServiceResource.Vpc method#

Creates a Vpc resource.

Type annotations and code completion for boto3.resource("ec2").Vpc method. boto3 documentation

# Vpc method definition

def Vpc(
    self,
    id: str,
) -> _Vpc:
    ...

EC2ServiceResource.VpcPeeringConnection method#

Creates a VpcPeeringConnection resource.

Type annotations and code completion for boto3.resource("ec2").VpcPeeringConnection method. boto3 documentation

# VpcPeeringConnection method definition

def VpcPeeringConnection(
    self,
    id: str,
) -> _VpcPeeringConnection:
    ...

EC2ServiceResource.VpcAddress method#

Creates a VpcAddress resource.

Type annotations and code completion for boto3.resource("ec2").VpcAddress method. boto3 documentation

# VpcAddress method definition

def VpcAddress(
    self,
    allocation_id: str,
) -> _VpcAddress:
    ...

ClassicAddress#

Type annotations and code completion for boto3.resource("ec2").ClassicAddress class. boto3 documentation

# ClassicAddress usage example

from mypy_boto3_ec2.service_resource import ClassicAddress

def get_resource() -> ClassicAddress:
    return boto3.resource("ec2").ClassicAddress(...)

ClassicAddress attributes#

  • public_ip: str
  • allocation_id: str
  • association_id: str
  • domain: DomainTypeType
  • network_interface_id: str
  • network_interface_owner_id: str
  • private_ip_address: str
  • tags: list[TagTypeDef]
  • public_ipv4_pool: str
  • network_border_group: str
  • customer_owned_ip: str
  • customer_owned_ipv4_pool: str
  • carrier_ip: str
  • instance_id: str
  • meta: EC2ResourceMeta

ClassicAddress methods#

ClassicAddress.get_available_subresources method#

Returns a list of all the available sub-resources for this ClassicAddress.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

ClassicAddress.associate method#

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.resource("ec2").associate method. boto3 documentation

# associate method definition

def associate(
    self,
    *,
    AllocationId: str = ...,
    InstanceId: str = ...,
    DryRun: bool = ...,
    NetworkInterfaceId: str = ...,
    PrivateIpAddress: str = ...,
    AllowReassociation: bool = ...,
) -> AssociateAddressResultTypeDef:  # (1)
    ...
  1. See AssociateAddressResultTypeDef
# associate method usage example with argument unpacking

kwargs: AssociateAddressRequestClassicAddressAssociateTypeDef = {  # (1)
    "AllocationId": ...,
}

parent.associate(**kwargs)
  1. See AssociateAddressRequestClassicAddressAssociateTypeDef

ClassicAddress.disassociate method#

Disassociates an Elastic IP address from the instance or network interface it's associated with.

Type annotations and code completion for boto3.resource("ec2").disassociate method. boto3 documentation

# disassociate method definition

def disassociate(
    self,
    *,
    AssociationId: str = ...,
    PublicIp: str = ...,
    DryRun: bool = ...,
) -> None:
    ...
# disassociate method usage example with argument unpacking

kwargs: DisassociateAddressRequestClassicAddressDisassociateTypeDef = {  # (1)
    "AssociationId": ...,
}

parent.disassociate(**kwargs)
  1. See DisassociateAddressRequestClassicAddressDisassociateTypeDef

ClassicAddress.release method#

Releases the specified Elastic IP address.

Type annotations and code completion for boto3.resource("ec2").release method. boto3 documentation

# release method definition

def release(
    self,
    *,
    AllocationId: str = ...,
    PublicIp: str = ...,
    NetworkBorderGroup: str = ...,
    DryRun: bool = ...,
) -> None:
    ...
# release method usage example with argument unpacking

kwargs: ReleaseAddressRequestClassicAddressReleaseTypeDef = {  # (1)
    "AllocationId": ...,
}

parent.release(**kwargs)
  1. See ReleaseAddressRequestClassicAddressReleaseTypeDef

ClassicAddress.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

ClassicAddress.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

DhcpOptions#

Type annotations and code completion for boto3.resource("ec2").DhcpOptions class. boto3 documentation

# DhcpOptions usage example

from mypy_boto3_ec2.service_resource import DhcpOptions

def get_resource() -> DhcpOptions:
    return boto3.resource("ec2").DhcpOptions(...)

DhcpOptions attributes#

DhcpOptions methods#

DhcpOptions.get_available_subresources method#

Returns a list of all the available sub-resources for this DhcpOptions.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

DhcpOptions.associate_with_vpc method#

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.resource("ec2").associate_with_vpc method. boto3 documentation

# associate_with_vpc method definition

def associate_with_vpc(
    self,
    *,
    VpcId: str,
    DryRun: bool = ...,
) -> None:
    ...
# associate_with_vpc method usage example with argument unpacking

kwargs: AssociateDhcpOptionsRequestDhcpOptionsAssociateWithVpcTypeDef = {  # (1)
    "VpcId": ...,
}

parent.associate_with_vpc(**kwargs)
  1. See AssociateDhcpOptionsRequestDhcpOptionsAssociateWithVpcTypeDef

DhcpOptions.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

DhcpOptions.delete method#

Deletes the specified set of DHCP options.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteDhcpOptionsRequestDhcpOptionsDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteDhcpOptionsRequestDhcpOptionsDeleteTypeDef

DhcpOptions.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

DhcpOptions.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Image#

Type annotations and code completion for boto3.resource("ec2").Image class. boto3 documentation

# Image usage example

from mypy_boto3_ec2.service_resource import Image

def get_resource() -> Image:
    return boto3.resource("ec2").Image(...)

Image attributes#

Image methods#

Image.get_available_subresources method#

Returns a list of all the available sub-resources for this Image.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Image.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

Image.deregister method#

Deregisters the specified AMI.

Type annotations and code completion for boto3.resource("ec2").deregister method. boto3 documentation

# deregister method definition

def deregister(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# deregister method usage example with argument unpacking

kwargs: DeregisterImageRequestImageDeregisterTypeDef = {  # (1)
    "DryRun": ...,
}

parent.deregister(**kwargs)
  1. See DeregisterImageRequestImageDeregisterTypeDef

Image.describe_attribute method#

Describes the specified attribute of the specified AMI.

Type annotations and code completion for boto3.resource("ec2").describe_attribute method. boto3 documentation

# describe_attribute method definition

def describe_attribute(
    self,
    *,
    Attribute: ImageAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> ImageAttributeTypeDef:  # (2)
    ...
  1. See ImageAttributeNameType
  2. See ImageAttributeTypeDef
# describe_attribute method usage example with argument unpacking

kwargs: DescribeImageAttributeRequestImageDescribeAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.describe_attribute(**kwargs)
  1. See DescribeImageAttributeRequestImageDescribeAttributeTypeDef

Image.modify_attribute method#

Modifies the specified attribute of the specified AMI.

Type annotations and code completion for boto3.resource("ec2").modify_attribute method. boto3 documentation

# modify_attribute method definition

def modify_attribute(
    self,
    *,
    Attribute: str = ...,
    Description: AttributeValueTypeDef = ...,  # (1)
    LaunchPermission: LaunchPermissionModificationsTypeDef = ...,  # (2)
    OperationType: OperationTypeType = ...,  # (3)
    ProductCodes: Sequence[str] = ...,
    UserGroups: Sequence[str] = ...,
    UserIds: Sequence[str] = ...,
    Value: str = ...,
    OrganizationArns: Sequence[str] = ...,
    OrganizationalUnitArns: Sequence[str] = ...,
    ImdsSupport: AttributeValueTypeDef = ...,  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See AttributeValueTypeDef
  2. See LaunchPermissionModificationsTypeDef
  3. See OperationTypeType
  4. See AttributeValueTypeDef
# modify_attribute method usage example with argument unpacking

kwargs: ModifyImageAttributeRequestImageModifyAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.modify_attribute(**kwargs)
  1. See ModifyImageAttributeRequestImageModifyAttributeTypeDef

Image.reset_attribute method#

Resets an attribute of an AMI to its default value.

Type annotations and code completion for boto3.resource("ec2").reset_attribute method. boto3 documentation

# reset_attribute method definition

def reset_attribute(
    self,
    *,
    Attribute: ResetImageAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See ResetImageAttributeNameType
# reset_attribute method usage example with argument unpacking

kwargs: ResetImageAttributeRequestImageResetAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.reset_attribute(**kwargs)
  1. See ResetImageAttributeRequestImageResetAttributeTypeDef

Image.wait_until_exists method#

Waits until Image is exists.

Type annotations and code completion for boto3.resource("ec2").wait_until_exists method. boto3 documentation

# wait_until_exists method definition

def wait_until_exists(
    self,
) -> None:
    ...

Image.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Image.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Instance#

Type annotations and code completion for boto3.resource("ec2").Instance class. boto3 documentation

# Instance usage example

from mypy_boto3_ec2.service_resource import Instance

def get_resource() -> Instance:
    return boto3.resource("ec2").Instance(...)

Instance attributes#

Instance collections#

Instance.volumes#

Provides access to Volume resource.

Type annotations and code completion for boto3.resource("ec2").Instance(...).volumes collection. boto3 documentation

# InstanceVolumesCollection usage example

from mypy_boto3_ec2.service_resource import InstanceVolumesCollection

def get_collection() -> InstanceVolumesCollection:
    resource = boto3.resource("ec2").Instance(...)
    return resource.volumes

Instance.vpc_addresses#

Provides access to VpcAddress resource.

Type annotations and code completion for boto3.resource("ec2").Instance(...).vpc_addresses collection. boto3 documentation

# InstanceVpcAddressesCollection usage example

from mypy_boto3_ec2.service_resource import InstanceVpcAddressesCollection

def get_collection() -> InstanceVpcAddressesCollection:
    resource = boto3.resource("ec2").Instance(...)
    return resource.vpc_addresses

Instance methods#

Instance.get_available_subresources method#

Returns a list of all the available sub-resources for this Instance.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

This action is deprecated.

Type annotations and code completion for boto3.resource("ec2").attach_classic_link_vpc method. boto3 documentation

# attach_classic_link_vpc method definition

def attach_classic_link_vpc(
    self,
    *,
    VpcId: str,
    Groups: Sequence[str],
    DryRun: bool = ...,
) -> AttachClassicLinkVpcResultTypeDef:  # (1)
    ...
  1. See AttachClassicLinkVpcResultTypeDef
# attach_classic_link_vpc method usage example with argument unpacking

kwargs: AttachClassicLinkVpcRequestInstanceAttachClassicLinkVpcTypeDef = {  # (1)
    "VpcId": ...,
    "Groups": ...,
}

parent.attach_classic_link_vpc(**kwargs)
  1. See AttachClassicLinkVpcRequestInstanceAttachClassicLinkVpcTypeDef

Instance.attach_volume method#

Attaches an EBS volume to a running or stopped instance and exposes it to the instance with the specified device name.

Type annotations and code completion for boto3.resource("ec2").attach_volume method. boto3 documentation

# attach_volume method definition

def attach_volume(
    self,
    *,
    Device: str,
    VolumeId: str,
    DryRun: bool = ...,
) -> VolumeAttachmentResponseTypeDef:  # (1)
    ...
  1. See VolumeAttachmentResponseTypeDef
# attach_volume method usage example with argument unpacking

kwargs: AttachVolumeRequestInstanceAttachVolumeTypeDef = {  # (1)
    "Device": ...,
    "VolumeId": ...,
}

parent.attach_volume(**kwargs)
  1. See AttachVolumeRequestInstanceAttachVolumeTypeDef

Instance.console_output method#

Gets the console output for the specified instance.

Type annotations and code completion for boto3.resource("ec2").console_output method. boto3 documentation

# console_output method definition

def console_output(
    self,
    *,
    Latest: bool = ...,
    DryRun: bool = ...,
) -> GetConsoleOutputResultTypeDef:  # (1)
    ...
  1. See GetConsoleOutputResultTypeDef
# console_output method usage example with argument unpacking

kwargs: GetConsoleOutputRequestInstanceConsoleOutputTypeDef = {  # (1)
    "Latest": ...,
}

parent.console_output(**kwargs)
  1. See GetConsoleOutputRequestInstanceConsoleOutputTypeDef

Instance.create_image method#

Creates an Amazon EBS-backed AMI from an Amazon EBS-backed instance that is either running or stopped.

Type annotations and code completion for boto3.resource("ec2").create_image method. boto3 documentation

# create_image method definition

def create_image(
    self,
    *,
    Name: str,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
    Description: str = ...,
    NoReboot: bool = ...,
    BlockDeviceMappings: Sequence[BlockDeviceMappingTypeDef] = ...,  # (2)
) -> _Image:
    ...
  1. See TagSpecificationTypeDef
  2. See BlockDeviceMappingTypeDef
# create_image method usage example with argument unpacking

kwargs: CreateImageRequestInstanceCreateImageTypeDef = {  # (1)
    "Name": ...,
}

parent.create_image(**kwargs)
  1. See CreateImageRequestInstanceCreateImageTypeDef

Instance.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: InstanceCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See InstanceCreateTagsRequestTypeDef

Instance.describe_attribute method#

Describes the specified attribute of the specified instance.

Type annotations and code completion for boto3.resource("ec2").describe_attribute method. boto3 documentation

# describe_attribute method definition

def describe_attribute(
    self,
    *,
    Attribute: InstanceAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> InstanceAttributeTypeDef:  # (2)
    ...
  1. See InstanceAttributeNameType
  2. See InstanceAttributeTypeDef
# describe_attribute method usage example with argument unpacking

kwargs: DescribeInstanceAttributeRequestInstanceDescribeAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.describe_attribute(**kwargs)
  1. See DescribeInstanceAttributeRequestInstanceDescribeAttributeTypeDef

This action is deprecated.

Type annotations and code completion for boto3.resource("ec2").detach_classic_link_vpc method. boto3 documentation

# detach_classic_link_vpc method definition

def detach_classic_link_vpc(
    self,
    *,
    VpcId: str,
    DryRun: bool = ...,
) -> DetachClassicLinkVpcResultTypeDef:  # (1)
    ...
  1. See DetachClassicLinkVpcResultTypeDef
# detach_classic_link_vpc method usage example with argument unpacking

kwargs: DetachClassicLinkVpcRequestInstanceDetachClassicLinkVpcTypeDef = {  # (1)
    "VpcId": ...,
}

parent.detach_classic_link_vpc(**kwargs)
  1. See DetachClassicLinkVpcRequestInstanceDetachClassicLinkVpcTypeDef

Instance.detach_volume method#

Detaches an EBS volume from an instance.

Type annotations and code completion for boto3.resource("ec2").detach_volume method. boto3 documentation

# detach_volume method definition

def detach_volume(
    self,
    *,
    VolumeId: str,
    Device: str = ...,
    Force: bool = ...,
    DryRun: bool = ...,
) -> VolumeAttachmentResponseTypeDef:  # (1)
    ...
  1. See VolumeAttachmentResponseTypeDef
# detach_volume method usage example with argument unpacking

kwargs: DetachVolumeRequestInstanceDetachVolumeTypeDef = {  # (1)
    "VolumeId": ...,
}

parent.detach_volume(**kwargs)
  1. See DetachVolumeRequestInstanceDetachVolumeTypeDef

Instance.modify_attribute method#

Modifies the specified attribute of the specified instance.

Type annotations and code completion for boto3.resource("ec2").modify_attribute method. boto3 documentation

# modify_attribute method definition

def modify_attribute(
    self,
    *,
    SourceDestCheck: AttributeBooleanValueTypeDef = ...,  # (1)
    DisableApiStop: AttributeBooleanValueTypeDef = ...,  # (1)
    DryRun: bool = ...,
    Attribute: InstanceAttributeNameType = ...,  # (3)
    Value: str = ...,
    BlockDeviceMappings: Sequence[InstanceBlockDeviceMappingSpecificationTypeDef] = ...,  # (4)
    DisableApiTermination: AttributeBooleanValueTypeDef = ...,  # (1)
    InstanceType: AttributeValueTypeDef = ...,  # (6)
    Kernel: AttributeValueTypeDef = ...,  # (6)
    Ramdisk: AttributeValueTypeDef = ...,  # (6)
    UserData: BlobAttributeValueTypeDef = ...,  # (9)
    InstanceInitiatedShutdownBehavior: AttributeValueTypeDef = ...,  # (6)
    Groups: Sequence[str] = ...,
    EbsOptimized: AttributeBooleanValueTypeDef = ...,  # (1)
    SriovNetSupport: AttributeValueTypeDef = ...,  # (6)
    EnaSupport: AttributeBooleanValueTypeDef = ...,  # (1)
) -> None:
    ...
  1. See AttributeBooleanValueTypeDef
  2. See AttributeBooleanValueTypeDef
  3. See InstanceAttributeNameType
  4. See InstanceBlockDeviceMappingSpecificationTypeDef
  5. See AttributeBooleanValueTypeDef
  6. See AttributeValueTypeDef
  7. See AttributeValueTypeDef
  8. See AttributeValueTypeDef
  9. See BlobAttributeValueTypeDef
  10. See AttributeValueTypeDef
  11. See AttributeBooleanValueTypeDef
  12. See AttributeValueTypeDef
  13. See AttributeBooleanValueTypeDef
# modify_attribute method usage example with argument unpacking

kwargs: ModifyInstanceAttributeRequestInstanceModifyAttributeTypeDef = {  # (1)
    "SourceDestCheck": ...,
}

parent.modify_attribute(**kwargs)
  1. See ModifyInstanceAttributeRequestInstanceModifyAttributeTypeDef

Instance.monitor method#

Enables detailed monitoring for a running instance.

Type annotations and code completion for boto3.resource("ec2").monitor method. boto3 documentation

# monitor method definition

def monitor(
    self,
    *,
    DryRun: bool = ...,
) -> MonitorInstancesResultTypeDef:  # (1)
    ...
  1. See MonitorInstancesResultTypeDef
# monitor method usage example with argument unpacking

kwargs: MonitorInstancesRequestInstanceMonitorTypeDef = {  # (1)
    "DryRun": ...,
}

parent.monitor(**kwargs)
  1. See MonitorInstancesRequestInstanceMonitorTypeDef

Instance.password_data method#

Retrieves the encrypted administrator password for a running Windows instance.

Type annotations and code completion for boto3.resource("ec2").password_data method. boto3 documentation

# password_data method definition

def password_data(
    self,
    *,
    DryRun: bool = ...,
) -> GetPasswordDataResultTypeDef:  # (1)
    ...
  1. See GetPasswordDataResultTypeDef
# password_data method usage example with argument unpacking

kwargs: GetPasswordDataRequestInstancePasswordDataTypeDef = {  # (1)
    "DryRun": ...,
}

parent.password_data(**kwargs)
  1. See GetPasswordDataRequestInstancePasswordDataTypeDef

Instance.reboot method#

Requests a reboot of the specified instances.

Type annotations and code completion for boto3.resource("ec2").reboot method. boto3 documentation

# reboot method definition

def reboot(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# reboot method usage example with argument unpacking

kwargs: RebootInstancesRequestInstanceRebootTypeDef = {  # (1)
    "DryRun": ...,
}

parent.reboot(**kwargs)
  1. See RebootInstancesRequestInstanceRebootTypeDef

Instance.report_status method#

Submits feedback about the status of an instance.

Type annotations and code completion for boto3.resource("ec2").report_status method. boto3 documentation

# report_status method definition

def report_status(
    self,
    *,
    Status: ReportStatusTypeType,  # (1)
    ReasonCodes: Sequence[ReportInstanceReasonCodesType],  # (2)
    DryRun: bool = ...,
    StartTime: TimestampTypeDef = ...,
    EndTime: TimestampTypeDef = ...,
    Description: str = ...,
) -> None:
    ...
  1. See ReportStatusTypeType
  2. See ReportInstanceReasonCodesType
# report_status method usage example with argument unpacking

kwargs: ReportInstanceStatusRequestInstanceReportStatusTypeDef = {  # (1)
    "Status": ...,
    "ReasonCodes": ...,
}

parent.report_status(**kwargs)
  1. See ReportInstanceStatusRequestInstanceReportStatusTypeDef

Instance.reset_attribute method#

Resets an attribute of an instance to its default value.

Type annotations and code completion for boto3.resource("ec2").reset_attribute method. boto3 documentation

# reset_attribute method definition

def reset_attribute(
    self,
    *,
    Attribute: InstanceAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See InstanceAttributeNameType
# reset_attribute method usage example with argument unpacking

kwargs: ResetInstanceAttributeRequestInstanceResetAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.reset_attribute(**kwargs)
  1. See ResetInstanceAttributeRequestInstanceResetAttributeTypeDef

Instance.reset_kernel method#

Resets an attribute of an instance to its default value.

Type annotations and code completion for boto3.resource("ec2").reset_kernel method. boto3 documentation

# reset_kernel method definition

def reset_kernel(
    self,
    *,
    Attribute: InstanceAttributeNameType = 'kernel',  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See InstanceAttributeNameType
# reset_kernel method usage example with argument unpacking

kwargs: ResetInstanceAttributeRequestInstanceResetKernelTypeDef = {  # (1)
    "Attribute": ...,
}

parent.reset_kernel(**kwargs)
  1. See ResetInstanceAttributeRequestInstanceResetKernelTypeDef

Instance.reset_ramdisk method#

Resets an attribute of an instance to its default value.

Type annotations and code completion for boto3.resource("ec2").reset_ramdisk method. boto3 documentation

# reset_ramdisk method definition

def reset_ramdisk(
    self,
    *,
    Attribute: InstanceAttributeNameType = 'ramdisk',  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See InstanceAttributeNameType
# reset_ramdisk method usage example with argument unpacking

kwargs: ResetInstanceAttributeRequestInstanceResetRamdiskTypeDef = {  # (1)
    "Attribute": ...,
}

parent.reset_ramdisk(**kwargs)
  1. See ResetInstanceAttributeRequestInstanceResetRamdiskTypeDef

Instance.reset_source_dest_check method#

Resets an attribute of an instance to its default value.

Type annotations and code completion for boto3.resource("ec2").reset_source_dest_check method. boto3 documentation

# reset_source_dest_check method definition

def reset_source_dest_check(
    self,
    *,
    Attribute: InstanceAttributeNameType = 'sourceDestCheck',  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See InstanceAttributeNameType
# reset_source_dest_check method usage example with argument unpacking

kwargs: ResetInstanceAttributeRequestInstanceResetSourceDestCheckTypeDef = {  # (1)
    "Attribute": ...,
}

parent.reset_source_dest_check(**kwargs)
  1. See ResetInstanceAttributeRequestInstanceResetSourceDestCheckTypeDef

Instance.start method#

Starts an Amazon EBS-backed instance that you've previously stopped.

Type annotations and code completion for boto3.resource("ec2").start method. boto3 documentation

# start method definition

def start(
    self,
    *,
    AdditionalInfo: str = ...,
    DryRun: bool = ...,
) -> StartInstancesResultTypeDef:  # (1)
    ...
  1. See StartInstancesResultTypeDef
# start method usage example with argument unpacking

kwargs: StartInstancesRequestInstanceStartTypeDef = {  # (1)
    "AdditionalInfo": ...,
}

parent.start(**kwargs)
  1. See StartInstancesRequestInstanceStartTypeDef

Instance.stop method#

Stops an Amazon EBS-backed instance.

Type annotations and code completion for boto3.resource("ec2").stop method. boto3 documentation

# stop method definition

def stop(
    self,
    *,
    Hibernate: bool = ...,
    DryRun: bool = ...,
    Force: bool = ...,
) -> StopInstancesResultTypeDef:  # (1)
    ...
  1. See StopInstancesResultTypeDef
# stop method usage example with argument unpacking

kwargs: StopInstancesRequestInstanceStopTypeDef = {  # (1)
    "Hibernate": ...,
}

parent.stop(**kwargs)
  1. See StopInstancesRequestInstanceStopTypeDef

Instance.terminate method#

Shuts down the specified instances.

Type annotations and code completion for boto3.resource("ec2").terminate method. boto3 documentation

# terminate method definition

def terminate(
    self,
    *,
    DryRun: bool = ...,
) -> TerminateInstancesResultTypeDef:  # (1)
    ...
  1. See TerminateInstancesResultTypeDef
# terminate method usage example with argument unpacking

kwargs: TerminateInstancesRequestInstanceTerminateTypeDef = {  # (1)
    "DryRun": ...,
}

parent.terminate(**kwargs)
  1. See TerminateInstancesRequestInstanceTerminateTypeDef

Instance.unmonitor method#

Disables detailed monitoring for a running instance.

Type annotations and code completion for boto3.resource("ec2").unmonitor method. boto3 documentation

# unmonitor method definition

def unmonitor(
    self,
    *,
    DryRun: bool = ...,
) -> UnmonitorInstancesResultTypeDef:  # (1)
    ...
  1. See UnmonitorInstancesResultTypeDef
# unmonitor method usage example with argument unpacking

kwargs: UnmonitorInstancesRequestInstanceUnmonitorTypeDef = {  # (1)
    "DryRun": ...,
}

parent.unmonitor(**kwargs)
  1. See UnmonitorInstancesRequestInstanceUnmonitorTypeDef

Instance.wait_until_exists method#

Waits until Instance is exists.

Type annotations and code completion for boto3.resource("ec2").wait_until_exists method. boto3 documentation

# wait_until_exists method definition

def wait_until_exists(
    self,
) -> None:
    ...

Instance.wait_until_running method#

Waits until Instance is running.

Type annotations and code completion for boto3.resource("ec2").wait_until_running method. boto3 documentation

# wait_until_running method definition

def wait_until_running(
    self,
) -> None:
    ...

Instance.wait_until_stopped method#

Waits until Instance is stopped.

Type annotations and code completion for boto3.resource("ec2").wait_until_stopped method. boto3 documentation

# wait_until_stopped method definition

def wait_until_stopped(
    self,
) -> None:
    ...

Instance.wait_until_terminated method#

Waits until Instance is terminated.

Type annotations and code completion for boto3.resource("ec2").wait_until_terminated method. boto3 documentation

# wait_until_terminated method definition

def wait_until_terminated(
    self,
) -> None:
    ...

Instance.delete_tags method#

Deletes the specified set of tags from the specified set of resources.

Type annotations and code completion for boto3.resource("ec2").delete_tags method. boto3 documentation

# delete_tags method definition

def delete_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef] = ...,  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# delete_tags method usage example with argument unpacking

kwargs: InstanceDeleteTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.delete_tags(**kwargs)
  1. See InstanceDeleteTagsRequestTypeDef

Instance.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Instance.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

InternetGateway#

Type annotations and code completion for boto3.resource("ec2").InternetGateway class. boto3 documentation

# InternetGateway usage example

from mypy_boto3_ec2.service_resource import InternetGateway

def get_resource() -> InternetGateway:
    return boto3.resource("ec2").InternetGateway(...)

InternetGateway attributes#

InternetGateway methods#

InternetGateway.get_available_subresources method#

Returns a list of all the available sub-resources for this InternetGateway.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

InternetGateway.attach_to_vpc method#

Attaches an internet gateway or a virtual private gateway to a VPC, enabling connectivity between the internet and the VPC.

Type annotations and code completion for boto3.resource("ec2").attach_to_vpc method. boto3 documentation

# attach_to_vpc method definition

def attach_to_vpc(
    self,
    *,
    VpcId: str,
    DryRun: bool = ...,
) -> None:
    ...
# attach_to_vpc method usage example with argument unpacking

kwargs: AttachInternetGatewayRequestInternetGatewayAttachToVpcTypeDef = {  # (1)
    "VpcId": ...,
}

parent.attach_to_vpc(**kwargs)
  1. See AttachInternetGatewayRequestInternetGatewayAttachToVpcTypeDef

InternetGateway.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

InternetGateway.delete method#

Deletes the specified internet gateway.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteInternetGatewayRequestInternetGatewayDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteInternetGatewayRequestInternetGatewayDeleteTypeDef

InternetGateway.detach_from_vpc method#

Detaches an internet gateway from a VPC, disabling connectivity between the internet and the VPC.

Type annotations and code completion for boto3.resource("ec2").detach_from_vpc method. boto3 documentation

# detach_from_vpc method definition

def detach_from_vpc(
    self,
    *,
    VpcId: str,
    DryRun: bool = ...,
) -> None:
    ...
# detach_from_vpc method usage example with argument unpacking

kwargs: DetachInternetGatewayRequestInternetGatewayDetachFromVpcTypeDef = {  # (1)
    "VpcId": ...,
}

parent.detach_from_vpc(**kwargs)
  1. See DetachInternetGatewayRequestInternetGatewayDetachFromVpcTypeDef

InternetGateway.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

InternetGateway.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

KeyPair#

Type annotations and code completion for boto3.resource("ec2").KeyPair class. boto3 documentation

# KeyPair usage example

from mypy_boto3_ec2.service_resource import KeyPair

def get_resource() -> KeyPair:
    return boto3.resource("ec2").KeyPair(...)

KeyPair attributes#

  • name: str
  • key_pair_id: str
  • tags: list[TagTypeDef]
  • key_name: str
  • key_fingerprint: str
  • key_material: str
  • meta: EC2ResourceMeta

KeyPair methods#

KeyPair.get_available_subresources method#

Returns a list of all the available sub-resources for this KeyPair.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

KeyPair.delete method#

Deletes the specified key pair, by removing the public key from Amazon EC2.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    KeyPairId: str = ...,
    DryRun: bool = ...,
) -> DeleteKeyPairResultTypeDef:  # (1)
    ...
  1. See DeleteKeyPairResultTypeDef
# delete method usage example with argument unpacking

kwargs: DeleteKeyPairRequestKeyPairDeleteTypeDef = {  # (1)
    "KeyPairId": ...,
}

parent.delete(**kwargs)
  1. See DeleteKeyPairRequestKeyPairDeleteTypeDef

KeyPairInfo#

Type annotations and code completion for boto3.resource("ec2").KeyPairInfo class. boto3 documentation

# KeyPairInfo usage example

from mypy_boto3_ec2.service_resource import KeyPairInfo

def get_resource() -> KeyPairInfo:
    return boto3.resource("ec2").KeyPairInfo(...)

KeyPairInfo attributes#

  • name: str
  • key_pair_id: str
  • key_type: KeyTypeType
  • tags: list[TagTypeDef]
  • public_key: str
  • create_time: datetime
  • key_name: str
  • key_fingerprint: str
  • meta: EC2ResourceMeta

KeyPairInfo methods#

KeyPairInfo.get_available_subresources method#

Returns a list of all the available sub-resources for this KeyPairInfo.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

KeyPairInfo.delete method#

Deletes the specified key pair, by removing the public key from Amazon EC2.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    KeyPairId: str = ...,
    DryRun: bool = ...,
) -> DeleteKeyPairResultTypeDef:  # (1)
    ...
  1. See DeleteKeyPairResultTypeDef
# delete method usage example with argument unpacking

kwargs: DeleteKeyPairRequestKeyPairInfoDeleteTypeDef = {  # (1)
    "KeyPairId": ...,
}

parent.delete(**kwargs)
  1. See DeleteKeyPairRequestKeyPairInfoDeleteTypeDef

KeyPairInfo.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

KeyPairInfo.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

NetworkAcl#

Type annotations and code completion for boto3.resource("ec2").NetworkAcl class. boto3 documentation

# NetworkAcl usage example

from mypy_boto3_ec2.service_resource import NetworkAcl

def get_resource() -> NetworkAcl:
    return boto3.resource("ec2").NetworkAcl(...)

NetworkAcl attributes#

NetworkAcl methods#

NetworkAcl.get_available_subresources method#

Returns a list of all the available sub-resources for this NetworkAcl.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

NetworkAcl.create_entry method#

Creates an entry (a rule) in a network ACL with the specified rule number.

Type annotations and code completion for boto3.resource("ec2").create_entry method. boto3 documentation

# create_entry method definition

def create_entry(
    self,
    *,
    RuleNumber: int,
    Protocol: str,
    RuleAction: RuleActionType,  # (1)
    Egress: bool,
    DryRun: bool = ...,
    CidrBlock: str = ...,
    Ipv6CidrBlock: str = ...,
    IcmpTypeCode: IcmpTypeCodeTypeDef = ...,  # (2)
    PortRange: PortRangeTypeDef = ...,  # (3)
) -> None:
    ...
  1. See RuleActionType
  2. See IcmpTypeCodeTypeDef
  3. See PortRangeTypeDef
# create_entry method usage example with argument unpacking

kwargs: CreateNetworkAclEntryRequestNetworkAclCreateEntryTypeDef = {  # (1)
    "RuleNumber": ...,
    "Protocol": ...,
    "RuleAction": ...,
    "Egress": ...,
}

parent.create_entry(**kwargs)
  1. See CreateNetworkAclEntryRequestNetworkAclCreateEntryTypeDef

NetworkAcl.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

NetworkAcl.delete method#

Deletes the specified network ACL.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteNetworkAclRequestNetworkAclDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteNetworkAclRequestNetworkAclDeleteTypeDef

NetworkAcl.delete_entry method#

Deletes the specified ingress or egress entry (rule) from the specified network ACL.

Type annotations and code completion for boto3.resource("ec2").delete_entry method. boto3 documentation

# delete_entry method definition

def delete_entry(
    self,
    *,
    RuleNumber: int,
    Egress: bool,
    DryRun: bool = ...,
) -> None:
    ...
# delete_entry method usage example with argument unpacking

kwargs: DeleteNetworkAclEntryRequestNetworkAclDeleteEntryTypeDef = {  # (1)
    "RuleNumber": ...,
    "Egress": ...,
}

parent.delete_entry(**kwargs)
  1. See DeleteNetworkAclEntryRequestNetworkAclDeleteEntryTypeDef

NetworkAcl.replace_association method#

Changes which network ACL a subnet is associated with.

Type annotations and code completion for boto3.resource("ec2").replace_association method. boto3 documentation

# replace_association method definition

def replace_association(
    self,
    *,
    AssociationId: str,
    DryRun: bool = ...,
) -> ReplaceNetworkAclAssociationResultTypeDef:  # (1)
    ...
  1. See ReplaceNetworkAclAssociationResultTypeDef
# replace_association method usage example with argument unpacking

kwargs: ReplaceNetworkAclAssociationRequestNetworkAclReplaceAssociationTypeDef = {  # (1)
    "AssociationId": ...,
}

parent.replace_association(**kwargs)
  1. See ReplaceNetworkAclAssociationRequestNetworkAclReplaceAssociationTypeDef

NetworkAcl.replace_entry method#

Replaces an entry (rule) in a network ACL.

Type annotations and code completion for boto3.resource("ec2").replace_entry method. boto3 documentation

# replace_entry method definition

def replace_entry(
    self,
    *,
    RuleNumber: int,
    Protocol: str,
    RuleAction: RuleActionType,  # (1)
    Egress: bool,
    DryRun: bool = ...,
    CidrBlock: str = ...,
    Ipv6CidrBlock: str = ...,
    IcmpTypeCode: IcmpTypeCodeTypeDef = ...,  # (2)
    PortRange: PortRangeTypeDef = ...,  # (3)
) -> None:
    ...
  1. See RuleActionType
  2. See IcmpTypeCodeTypeDef
  3. See PortRangeTypeDef
# replace_entry method usage example with argument unpacking

kwargs: ReplaceNetworkAclEntryRequestNetworkAclReplaceEntryTypeDef = {  # (1)
    "RuleNumber": ...,
    "Protocol": ...,
    "RuleAction": ...,
    "Egress": ...,
}

parent.replace_entry(**kwargs)
  1. See ReplaceNetworkAclEntryRequestNetworkAclReplaceEntryTypeDef

NetworkAcl.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

NetworkAcl.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

NetworkInterface#

Type annotations and code completion for boto3.resource("ec2").NetworkInterface class. boto3 documentation

# NetworkInterface usage example

from mypy_boto3_ec2.service_resource import NetworkInterface

def get_resource() -> NetworkInterface:
    return boto3.resource("ec2").NetworkInterface(...)

NetworkInterface attributes#

NetworkInterface methods#

NetworkInterface.get_available_subresources method#

Returns a list of all the available sub-resources for this NetworkInterface.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

NetworkInterface.assign_private_ip_addresses method#

Assigns one or more secondary private IP addresses to the specified network interface.

Type annotations and code completion for boto3.resource("ec2").assign_private_ip_addresses method. boto3 documentation

# assign_private_ip_addresses method definition

def assign_private_ip_addresses(
    self,
    *,
    Ipv4Prefixes: Sequence[str] = ...,
    Ipv4PrefixCount: int = ...,
    PrivateIpAddresses: Sequence[str] = ...,
    SecondaryPrivateIpAddressCount: int = ...,
    AllowReassignment: bool = ...,
) -> AssignPrivateIpAddressesResultTypeDef:  # (1)
    ...
  1. See AssignPrivateIpAddressesResultTypeDef
# assign_private_ip_addresses method usage example with argument unpacking

kwargs: AssignPrivateIpAddressesRequestNetworkInterfaceAssignPrivateIpAddressesTypeDef = {  # (1)
    "Ipv4Prefixes": ...,
}

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

NetworkInterface.attach method#

Attaches a network interface to an instance.

Type annotations and code completion for boto3.resource("ec2").attach method. boto3 documentation

# attach method definition

def attach(
    self,
    *,
    InstanceId: str,
    DeviceIndex: int,
    NetworkCardIndex: int = ...,
    EnaSrdSpecification: EnaSrdSpecificationTypeDef = ...,  # (1)
    DryRun: bool = ...,
) -> AttachNetworkInterfaceResultTypeDef:  # (2)
    ...
  1. See EnaSrdSpecificationTypeDef
  2. See AttachNetworkInterfaceResultTypeDef
# attach method usage example with argument unpacking

kwargs: AttachNetworkInterfaceRequestNetworkInterfaceAttachTypeDef = {  # (1)
    "InstanceId": ...,
    "DeviceIndex": ...,
}

parent.attach(**kwargs)
  1. See AttachNetworkInterfaceRequestNetworkInterfaceAttachTypeDef

NetworkInterface.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

NetworkInterface.delete method#

Deletes the specified network interface.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteNetworkInterfaceRequestNetworkInterfaceDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteNetworkInterfaceRequestNetworkInterfaceDeleteTypeDef

NetworkInterface.describe_attribute method#

Describes a network interface attribute.

Type annotations and code completion for boto3.resource("ec2").describe_attribute method. boto3 documentation

# describe_attribute method definition

def describe_attribute(
    self,
    *,
    DryRun: bool = ...,
    Attribute: NetworkInterfaceAttributeType = ...,  # (1)
) -> DescribeNetworkInterfaceAttributeResultTypeDef:  # (2)
    ...
  1. See NetworkInterfaceAttributeType
  2. See DescribeNetworkInterfaceAttributeResultTypeDef
# describe_attribute method usage example with argument unpacking

kwargs: DescribeNetworkInterfaceAttributeRequestNetworkInterfaceDescribeAttributeTypeDef = {  # (1)
    "DryRun": ...,
}

parent.describe_attribute(**kwargs)
  1. See DescribeNetworkInterfaceAttributeRequestNetworkInterfaceDescribeAttributeTypeDef

NetworkInterface.detach method#

Detaches a network interface from an instance.

Type annotations and code completion for boto3.resource("ec2").detach method. boto3 documentation

# detach method definition

def detach(
    self,
    *,
    AttachmentId: str,
    DryRun: bool = ...,
    Force: bool = ...,
) -> None:
    ...
# detach method usage example with argument unpacking

kwargs: DetachNetworkInterfaceRequestNetworkInterfaceDetachTypeDef = {  # (1)
    "AttachmentId": ...,
}

parent.detach(**kwargs)
  1. See DetachNetworkInterfaceRequestNetworkInterfaceDetachTypeDef

NetworkInterface.modify_attribute method#

Modifies the specified network interface attribute.

Type annotations and code completion for boto3.resource("ec2").modify_attribute method. boto3 documentation

# modify_attribute method definition

def modify_attribute(
    self,
    *,
    EnaSrdSpecification: EnaSrdSpecificationTypeDef = ...,  # (1)
    EnablePrimaryIpv6: bool = ...,
    ConnectionTrackingSpecification: ConnectionTrackingSpecificationRequestTypeDef = ...,  # (2)
    AssociatePublicIpAddress: bool = ...,
    DryRun: bool = ...,
    Description: AttributeValueTypeDef = ...,  # (3)
    SourceDestCheck: AttributeBooleanValueTypeDef = ...,  # (4)
    Groups: Sequence[str] = ...,
    Attachment: NetworkInterfaceAttachmentChangesTypeDef = ...,  # (5)
) -> None:
    ...
  1. See EnaSrdSpecificationTypeDef
  2. See ConnectionTrackingSpecificationRequestTypeDef
  3. See AttributeValueTypeDef
  4. See AttributeBooleanValueTypeDef
  5. See NetworkInterfaceAttachmentChangesTypeDef
# modify_attribute method usage example with argument unpacking

kwargs: ModifyNetworkInterfaceAttributeRequestNetworkInterfaceModifyAttributeTypeDef = {  # (1)
    "EnaSrdSpecification": ...,
}

parent.modify_attribute(**kwargs)
  1. See ModifyNetworkInterfaceAttributeRequestNetworkInterfaceModifyAttributeTypeDef

NetworkInterface.reset_attribute method#

Resets a network interface attribute.

Type annotations and code completion for boto3.resource("ec2").reset_attribute method. boto3 documentation

# reset_attribute method definition

def reset_attribute(
    self,
    *,
    DryRun: bool = ...,
    SourceDestCheck: str = ...,
) -> None:
    ...
# reset_attribute method usage example with argument unpacking

kwargs: ResetNetworkInterfaceAttributeRequestNetworkInterfaceResetAttributeTypeDef = {  # (1)
    "DryRun": ...,
}

parent.reset_attribute(**kwargs)
  1. See ResetNetworkInterfaceAttributeRequestNetworkInterfaceResetAttributeTypeDef

NetworkInterface.unassign_private_ip_addresses method#

Unassigns one or more secondary private IP addresses, or IPv4 Prefix Delegation prefixes from a network interface.

Type annotations and code completion for boto3.resource("ec2").unassign_private_ip_addresses method. boto3 documentation

# unassign_private_ip_addresses method definition

def unassign_private_ip_addresses(
    self,
    *,
    Ipv4Prefixes: Sequence[str] = ...,
    PrivateIpAddresses: Sequence[str] = ...,
) -> None:
    ...
# unassign_private_ip_addresses method usage example with argument unpacking

kwargs: UnassignPrivateIpAddressesRequestNetworkInterfaceUnassignPrivateIpAddressesTypeDef = {  # (1)
    "Ipv4Prefixes": ...,
}

parent.unassign_private_ip_addresses(**kwargs)
  1. See UnassignPrivateIpAddressesRequestNetworkInterfaceUnassignPrivateIpAddressesTypeDef

NetworkInterface.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

NetworkInterface.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

NetworkInterfaceAssociation#

Type annotations and code completion for boto3.resource("ec2").NetworkInterfaceAssociation class. boto3 documentation

# NetworkInterfaceAssociation usage example

from mypy_boto3_ec2.service_resource import NetworkInterfaceAssociation

def get_resource() -> NetworkInterfaceAssociation:
    return boto3.resource("ec2").NetworkInterfaceAssociation(...)

NetworkInterfaceAssociation attributes#

  • id: str
  • address: VpcAddress
  • carrier_ip: str
  • customer_owned_ip: str
  • ip_owner_id: str
  • public_dns_name: str
  • public_ip: str
  • meta: EC2ResourceMeta

NetworkInterfaceAssociation methods#

NetworkInterfaceAssociation.get_available_subresources method#

Returns a list of all the available sub-resources for this NetworkInterfaceAssociation.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

NetworkInterfaceAssociation.delete method#

Disassociates an Elastic IP address from the instance or network interface it's associated with.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    PublicIp: str = ...,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DisassociateAddressRequestNetworkInterfaceAssociationDeleteTypeDef = {  # (1)
    "PublicIp": ...,
}

parent.delete(**kwargs)
  1. See DisassociateAddressRequestNetworkInterfaceAssociationDeleteTypeDef

NetworkInterfaceAssociation.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

NetworkInterfaceAssociation.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

PlacementGroup#

Type annotations and code completion for boto3.resource("ec2").PlacementGroup class. boto3 documentation

# PlacementGroup usage example

from mypy_boto3_ec2.service_resource import PlacementGroup

def get_resource() -> PlacementGroup:
    return boto3.resource("ec2").PlacementGroup(...)

PlacementGroup attributes#

PlacementGroup collections#

PlacementGroup.instances#

Provides access to Instance resource.

Type annotations and code completion for boto3.resource("ec2").PlacementGroup(...).instances collection. boto3 documentation

# PlacementGroupInstancesCollection usage example

from mypy_boto3_ec2.service_resource import PlacementGroupInstancesCollection

def get_collection() -> PlacementGroupInstancesCollection:
    resource = boto3.resource("ec2").PlacementGroup(...)
    return resource.instances

PlacementGroup methods#

PlacementGroup.get_available_subresources method#

Returns a list of all the available sub-resources for this PlacementGroup.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

PlacementGroup.delete method#

Deletes the specified placement group.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeletePlacementGroupRequestPlacementGroupDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeletePlacementGroupRequestPlacementGroupDeleteTypeDef

PlacementGroup.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

PlacementGroup.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Route#

Type annotations and code completion for boto3.resource("ec2").Route class. boto3 documentation

# Route usage example

from mypy_boto3_ec2.service_resource import Route

def get_resource() -> Route:
    return boto3.resource("ec2").Route(...)

Route attributes#

  • route_table_id: str
  • destination_cidr_block: str
  • destination_ipv6_cidr_block: str
  • destination_prefix_list_id: str
  • egress_only_internet_gateway_id: str
  • gateway_id: str
  • instance_id: str
  • instance_owner_id: str
  • nat_gateway_id: str
  • transit_gateway_id: str
  • local_gateway_id: str
  • carrier_gateway_id: str
  • network_interface_id: str
  • origin: RouteOriginType
  • state: RouteStateType
  • vpc_peering_connection_id: str
  • core_network_arn: str
  • meta: EC2ResourceMeta

Route methods#

Route.get_available_subresources method#

Returns a list of all the available sub-resources for this Route.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Route.delete method#

Deletes the specified route from the specified route table.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DestinationPrefixListId: str = ...,
    DryRun: bool = ...,
    DestinationIpv6CidrBlock: str = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteRouteRequestRouteDeleteTypeDef = {  # (1)
    "DestinationPrefixListId": ...,
}

parent.delete(**kwargs)
  1. See DeleteRouteRequestRouteDeleteTypeDef

Route.replace method#

Replaces an existing route within a route table in a VPC.

Type annotations and code completion for boto3.resource("ec2").replace method. boto3 documentation

# replace method definition

def replace(
    self,
    *,
    DestinationPrefixListId: str = ...,
    VpcEndpointId: str = ...,
    LocalTarget: bool = ...,
    TransitGatewayId: str = ...,
    LocalGatewayId: str = ...,
    CarrierGatewayId: str = ...,
    CoreNetworkArn: str = ...,
    DryRun: bool = ...,
    GatewayId: str = ...,
    DestinationIpv6CidrBlock: str = ...,
    EgressOnlyInternetGatewayId: str = ...,
    InstanceId: str = ...,
    NetworkInterfaceId: str = ...,
    VpcPeeringConnectionId: str = ...,
    NatGatewayId: str = ...,
) -> None:
    ...
# replace method usage example with argument unpacking

kwargs: ReplaceRouteRequestRouteReplaceTypeDef = {  # (1)
    "DestinationPrefixListId": ...,
}

parent.replace(**kwargs)
  1. See ReplaceRouteRequestRouteReplaceTypeDef

Route.RouteTable method#

Creates a RouteTable resource.

Type annotations and code completion for boto3.resource("ec2").RouteTable method. boto3 documentation

# RouteTable method definition

def RouteTable(
    self,
) -> _RouteTable:
    ...

RouteTable#

Type annotations and code completion for boto3.resource("ec2").RouteTable class. boto3 documentation

# RouteTable usage example

from mypy_boto3_ec2.service_resource import RouteTable

def get_resource() -> RouteTable:
    return boto3.resource("ec2").RouteTable(...)

RouteTable attributes#

RouteTable methods#

RouteTable.get_available_subresources method#

Returns a list of all the available sub-resources for this RouteTable.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

RouteTable.associate_with_subnet method#

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.resource("ec2").associate_with_subnet method. boto3 documentation

# associate_with_subnet method definition

def associate_with_subnet(
    self,
    *,
    GatewayId: str = ...,
    DryRun: bool = ...,
    SubnetId: str = ...,
) -> _RouteTableAssociation:
    ...
# associate_with_subnet method usage example with argument unpacking

kwargs: AssociateRouteTableRequestRouteTableAssociateWithSubnetTypeDef = {  # (1)
    "GatewayId": ...,
}

parent.associate_with_subnet(**kwargs)
  1. See AssociateRouteTableRequestRouteTableAssociateWithSubnetTypeDef

RouteTable.create_route method#

Creates a route in a route table within a VPC.

Type annotations and code completion for boto3.resource("ec2").create_route method. boto3 documentation

# create_route method definition

def create_route(
    self,
    *,
    DestinationPrefixListId: str = ...,
    VpcEndpointId: str = ...,
    TransitGatewayId: str = ...,
    LocalGatewayId: str = ...,
    CarrierGatewayId: str = ...,
    CoreNetworkArn: str = ...,
    DryRun: bool = ...,
    DestinationCidrBlock: str = ...,
    GatewayId: str = ...,
    DestinationIpv6CidrBlock: str = ...,
    EgressOnlyInternetGatewayId: str = ...,
    InstanceId: str = ...,
    NetworkInterfaceId: str = ...,
    VpcPeeringConnectionId: str = ...,
    NatGatewayId: str = ...,
) -> _Route:
    ...
# create_route method usage example with argument unpacking

kwargs: CreateRouteRequestRouteTableCreateRouteTypeDef = {  # (1)
    "DestinationPrefixListId": ...,
}

parent.create_route(**kwargs)
  1. See CreateRouteRequestRouteTableCreateRouteTypeDef

RouteTable.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

RouteTable.delete method#

Deletes the specified route table.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteRouteTableRequestRouteTableDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteRouteTableRequestRouteTableDeleteTypeDef

RouteTable.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

RouteTable.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

RouteTableAssociation#

Type annotations and code completion for boto3.resource("ec2").RouteTableAssociation class. boto3 documentation

# RouteTableAssociation usage example

from mypy_boto3_ec2.service_resource import RouteTableAssociation

def get_resource() -> RouteTableAssociation:
    return boto3.resource("ec2").RouteTableAssociation(...)

RouteTableAssociation attributes#

  • id: str
  • route_table: RouteTable
  • subnet: Subnet
  • main: bool
  • route_table_association_id: str
  • route_table_id: str
  • subnet_id: str
  • gateway_id: str
  • association_state: RouteTableAssociationStateTypeDef
  • meta: EC2ResourceMeta

RouteTableAssociation methods#

RouteTableAssociation.get_available_subresources method#

Returns a list of all the available sub-resources for this RouteTableAssociation.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

RouteTableAssociation.delete method#

Disassociates a subnet or gateway from a route table.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DisassociateRouteTableRequestRouteTableAssociationDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DisassociateRouteTableRequestRouteTableAssociationDeleteTypeDef

RouteTableAssociation.replace_subnet method#

Changes the route table associated with a given subnet, internet gateway, or virtual private gateway in a VPC.

Type annotations and code completion for boto3.resource("ec2").replace_subnet method. boto3 documentation

# replace_subnet method definition

def replace_subnet(
    self,
    *,
    RouteTableId: str,
    DryRun: bool = ...,
) -> _RouteTableAssociation:
    ...
# replace_subnet method usage example with argument unpacking

kwargs: ReplaceRouteTableAssociationRequestRouteTableAssociationReplaceSubnetTypeDef = {  # (1)
    "RouteTableId": ...,
}

parent.replace_subnet(**kwargs)
  1. See ReplaceRouteTableAssociationRequestRouteTableAssociationReplaceSubnetTypeDef

SecurityGroup#

Type annotations and code completion for boto3.resource("ec2").SecurityGroup class. boto3 documentation

# SecurityGroup usage example

from mypy_boto3_ec2.service_resource import SecurityGroup

def get_resource() -> SecurityGroup:
    return boto3.resource("ec2").SecurityGroup(...)

SecurityGroup attributes#

SecurityGroup methods#

SecurityGroup.get_available_subresources method#

Returns a list of all the available sub-resources for this SecurityGroup.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

SecurityGroup.authorize_egress method#

Adds the specified outbound (egress) rules to a security group.

Type annotations and code completion for boto3.resource("ec2").authorize_egress method. boto3 documentation

# authorize_egress method definition

def authorize_egress(
    self,
    *,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
    SourceSecurityGroupName: str = ...,
    SourceSecurityGroupOwnerId: str = ...,
    IpProtocol: str = ...,
    FromPort: int = ...,
    ToPort: int = ...,
    CidrIp: str = ...,
    IpPermissions: Sequence[IpPermissionTypeDef] = ...,  # (2)
) -> AuthorizeSecurityGroupEgressResultTypeDef:  # (3)
    ...
  1. See TagSpecificationTypeDef
  2. See IpPermissionTypeDef
  3. See AuthorizeSecurityGroupEgressResultTypeDef
# authorize_egress method usage example with argument unpacking

kwargs: AuthorizeSecurityGroupEgressRequestSecurityGroupAuthorizeEgressTypeDef = {  # (1)
    "TagSpecifications": ...,
}

parent.authorize_egress(**kwargs)
  1. See AuthorizeSecurityGroupEgressRequestSecurityGroupAuthorizeEgressTypeDef

SecurityGroup.authorize_ingress method#

Adds the specified inbound (ingress) rules to a security group.

Type annotations and code completion for boto3.resource("ec2").authorize_ingress method. boto3 documentation

# authorize_ingress method definition

def authorize_ingress(
    self,
    *,
    CidrIp: str = ...,
    FromPort: int = ...,
    GroupName: str = ...,
    IpPermissions: Sequence[IpPermissionTypeDef] = ...,  # (1)
    IpProtocol: str = ...,
    SourceSecurityGroupName: str = ...,
    SourceSecurityGroupOwnerId: str = ...,
    ToPort: int = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (2)
    DryRun: bool = ...,
) -> AuthorizeSecurityGroupIngressResultTypeDef:  # (3)
    ...
  1. See IpPermissionTypeDef
  2. See TagSpecificationTypeDef
  3. See AuthorizeSecurityGroupIngressResultTypeDef
# authorize_ingress method usage example with argument unpacking

kwargs: AuthorizeSecurityGroupIngressRequestSecurityGroupAuthorizeIngressTypeDef = {  # (1)
    "CidrIp": ...,
}

parent.authorize_ingress(**kwargs)
  1. See AuthorizeSecurityGroupIngressRequestSecurityGroupAuthorizeIngressTypeDef

SecurityGroup.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

SecurityGroup.delete method#

Deletes a security group.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    GroupName: str = ...,
    DryRun: bool = ...,
) -> DeleteSecurityGroupResultTypeDef:  # (1)
    ...
  1. See DeleteSecurityGroupResultTypeDef
# delete method usage example with argument unpacking

kwargs: DeleteSecurityGroupRequestSecurityGroupDeleteTypeDef = {  # (1)
    "GroupName": ...,
}

parent.delete(**kwargs)
  1. See DeleteSecurityGroupRequestSecurityGroupDeleteTypeDef

SecurityGroup.revoke_egress method#

Removes the specified outbound (egress) rules from the specified security group.

Type annotations and code completion for boto3.resource("ec2").revoke_egress method. boto3 documentation

# revoke_egress method definition

def revoke_egress(
    self,
    *,
    SecurityGroupRuleIds: Sequence[str] = ...,
    DryRun: bool = ...,
    SourceSecurityGroupName: str = ...,
    SourceSecurityGroupOwnerId: str = ...,
    IpProtocol: str = ...,
    FromPort: int = ...,
    ToPort: int = ...,
    CidrIp: str = ...,
    IpPermissions: Sequence[IpPermissionTypeDef] = ...,  # (1)
) -> RevokeSecurityGroupEgressResultTypeDef:  # (2)
    ...
  1. See IpPermissionTypeDef
  2. See RevokeSecurityGroupEgressResultTypeDef
# revoke_egress method usage example with argument unpacking

kwargs: RevokeSecurityGroupEgressRequestSecurityGroupRevokeEgressTypeDef = {  # (1)
    "SecurityGroupRuleIds": ...,
}

parent.revoke_egress(**kwargs)
  1. See RevokeSecurityGroupEgressRequestSecurityGroupRevokeEgressTypeDef

SecurityGroup.revoke_ingress method#

Removes the specified inbound (ingress) rules from a security group.

Type annotations and code completion for boto3.resource("ec2").revoke_ingress method. boto3 documentation

# revoke_ingress method definition

def revoke_ingress(
    self,
    *,
    CidrIp: str = ...,
    FromPort: int = ...,
    GroupName: str = ...,
    IpPermissions: Sequence[IpPermissionTypeDef] = ...,  # (1)
    IpProtocol: str = ...,
    SourceSecurityGroupName: str = ...,
    SourceSecurityGroupOwnerId: str = ...,
    ToPort: int = ...,
    SecurityGroupRuleIds: Sequence[str] = ...,
    DryRun: bool = ...,
) -> RevokeSecurityGroupIngressResultTypeDef:  # (2)
    ...
  1. See IpPermissionTypeDef
  2. See RevokeSecurityGroupIngressResultTypeDef
# revoke_ingress method usage example with argument unpacking

kwargs: RevokeSecurityGroupIngressRequestSecurityGroupRevokeIngressTypeDef = {  # (1)
    "CidrIp": ...,
}

parent.revoke_ingress(**kwargs)
  1. See RevokeSecurityGroupIngressRequestSecurityGroupRevokeIngressTypeDef

SecurityGroup.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

SecurityGroup.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Snapshot#

Type annotations and code completion for boto3.resource("ec2").Snapshot class. boto3 documentation

# Snapshot usage example

from mypy_boto3_ec2.service_resource import Snapshot

def get_resource() -> Snapshot:
    return boto3.resource("ec2").Snapshot(...)

Snapshot attributes#

  • id: str
  • volume: Volume
  • owner_alias: str
  • outpost_arn: str
  • tags: list[TagTypeDef]
  • storage_tier: StorageTierType
  • restore_expiry_time: datetime
  • sse_type: SSETypeType
  • availability_zone: str
  • transfer_type: TransferTypeType
  • completion_duration_minutes: int
  • completion_time: datetime
  • snapshot_id: str
  • volume_id: str
  • state: SnapshotStateType
  • state_message: str
  • start_time: datetime
  • progress: str
  • owner_id: str
  • description: str
  • volume_size: int
  • encrypted: bool
  • kms_key_id: str
  • data_encryption_key_id: str
  • meta: EC2ResourceMeta

Snapshot methods#

Snapshot.get_available_subresources method#

Returns a list of all the available sub-resources for this Snapshot.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Snapshot.copy method#

Copies a point-in-time snapshot of an EBS volume and stores it in Amazon S3.

Type annotations and code completion for boto3.resource("ec2").copy method. boto3 documentation

# copy method definition

def copy(
    self,
    *,
    SourceRegion: str,
    Description: str = ...,
    DestinationOutpostArn: str = ...,
    DestinationRegion: str = ...,
    Encrypted: bool = ...,
    KmsKeyId: str = ...,
    PresignedUrl: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    CompletionDurationMinutes: int = ...,
    DryRun: bool = ...,
) -> CopySnapshotResultTypeDef:  # (2)
    ...
  1. See TagSpecificationTypeDef
  2. See CopySnapshotResultTypeDef
# copy method usage example with argument unpacking

kwargs: CopySnapshotRequestSnapshotCopyTypeDef = {  # (1)
    "SourceRegion": ...,
}

parent.copy(**kwargs)
  1. See CopySnapshotRequestSnapshotCopyTypeDef

Snapshot.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

Snapshot.delete method#

Deletes the specified snapshot.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteSnapshotRequestSnapshotDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteSnapshotRequestSnapshotDeleteTypeDef

Snapshot.describe_attribute method#

Describes the specified attribute of the specified snapshot.

Type annotations and code completion for boto3.resource("ec2").describe_attribute method. boto3 documentation

# describe_attribute method definition

def describe_attribute(
    self,
    *,
    Attribute: SnapshotAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> DescribeSnapshotAttributeResultTypeDef:  # (2)
    ...
  1. See SnapshotAttributeNameType
  2. See DescribeSnapshotAttributeResultTypeDef
# describe_attribute method usage example with argument unpacking

kwargs: DescribeSnapshotAttributeRequestSnapshotDescribeAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.describe_attribute(**kwargs)
  1. See DescribeSnapshotAttributeRequestSnapshotDescribeAttributeTypeDef

Snapshot.modify_attribute method#

Adds or removes permission settings for the specified snapshot.

Type annotations and code completion for boto3.resource("ec2").modify_attribute method. boto3 documentation

# modify_attribute method definition

def modify_attribute(
    self,
    *,
    Attribute: SnapshotAttributeNameType = ...,  # (1)
    CreateVolumePermission: CreateVolumePermissionModificationsTypeDef = ...,  # (2)
    GroupNames: Sequence[str] = ...,
    OperationType: OperationTypeType = ...,  # (3)
    UserIds: Sequence[str] = ...,
    DryRun: bool = ...,
) -> None:
    ...
  1. See SnapshotAttributeNameType
  2. See CreateVolumePermissionModificationsTypeDef
  3. See OperationTypeType
# modify_attribute method usage example with argument unpacking

kwargs: ModifySnapshotAttributeRequestSnapshotModifyAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.modify_attribute(**kwargs)
  1. See ModifySnapshotAttributeRequestSnapshotModifyAttributeTypeDef

Snapshot.reset_attribute method#

Resets permission settings for the specified snapshot.

Type annotations and code completion for boto3.resource("ec2").reset_attribute method. boto3 documentation

# reset_attribute method definition

def reset_attribute(
    self,
    *,
    Attribute: SnapshotAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See SnapshotAttributeNameType
# reset_attribute method usage example with argument unpacking

kwargs: ResetSnapshotAttributeRequestSnapshotResetAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.reset_attribute(**kwargs)
  1. See ResetSnapshotAttributeRequestSnapshotResetAttributeTypeDef

Snapshot.wait_until_completed method#

Waits until Snapshot is completed.

Type annotations and code completion for boto3.resource("ec2").wait_until_completed method. boto3 documentation

# wait_until_completed method definition

def wait_until_completed(
    self,
) -> None:
    ...

Snapshot.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Snapshot.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Subnet#

Type annotations and code completion for boto3.resource("ec2").Subnet class. boto3 documentation

# Subnet usage example

from mypy_boto3_ec2.service_resource import Subnet

def get_resource() -> Subnet:
    return boto3.resource("ec2").Subnet(...)

Subnet attributes#

  • id: str
  • vpc: Vpc
  • instances: SubnetInstancesCollection
  • network_interfaces: SubnetNetworkInterfacesCollection
  • availability_zone_id: str
  • enable_lni_at_device_index: int
  • map_customer_owned_ip_on_launch: bool
  • customer_owned_ipv4_pool: str
  • owner_id: str
  • assign_ipv6_address_on_creation: bool
  • ipv6_cidr_block_association_set: list[SubnetIpv6CidrBlockAssociationTypeDef]
  • tags: list[TagTypeDef]
  • subnet_arn: str
  • outpost_arn: str
  • enable_dns64: bool
  • ipv6_native: bool
  • private_dns_name_options_on_launch: PrivateDnsNameOptionsOnLaunchTypeDef
  • block_public_access_states: BlockPublicAccessStatesTypeDef
  • subnet_id: str
  • state: SubnetStateType
  • vpc_id: str
  • cidr_block: str
  • available_ip_address_count: int
  • availability_zone: str
  • default_for_az: bool
  • map_public_ip_on_launch: bool
  • meta: EC2ResourceMeta

Subnet collections#

Subnet.instances#

Provides access to Instance resource.

Type annotations and code completion for boto3.resource("ec2").Subnet(...).instances collection. boto3 documentation

# SubnetInstancesCollection usage example

from mypy_boto3_ec2.service_resource import SubnetInstancesCollection

def get_collection() -> SubnetInstancesCollection:
    resource = boto3.resource("ec2").Subnet(...)
    return resource.instances

Subnet.network_interfaces#

Provides access to NetworkInterface resource.

Type annotations and code completion for boto3.resource("ec2").Subnet(...).network_interfaces collection. boto3 documentation

# SubnetNetworkInterfacesCollection usage example

from mypy_boto3_ec2.service_resource import SubnetNetworkInterfacesCollection

def get_collection() -> SubnetNetworkInterfacesCollection:
    resource = boto3.resource("ec2").Subnet(...)
    return resource.network_interfaces

Subnet methods#

Subnet.get_available_subresources method#

Returns a list of all the available sub-resources for this Subnet.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Subnet.create_instances method#

Launches the specified number of instances using an AMI for which you have permissions.

Type annotations and code completion for boto3.resource("ec2").create_instances method. boto3 documentation

# create_instances method definition

def create_instances(
    self,
    *,
    MaxCount: int,
    MinCount: int,
    BlockDeviceMappings: Sequence[BlockDeviceMappingTypeDef] = ...,  # (1)
    ImageId: str = ...,
    InstanceType: InstanceTypeType = ...,  # (2)
    Ipv6AddressCount: int = ...,
    Ipv6Addresses: Sequence[InstanceIpv6AddressTypeDef] = ...,  # (3)
    KernelId: str = ...,
    KeyName: str = ...,
    Monitoring: RunInstancesMonitoringEnabledTypeDef = ...,  # (4)
    Placement: PlacementTypeDef = ...,  # (5)
    RamdiskId: str = ...,
    SecurityGroupIds: Sequence[str] = ...,
    SecurityGroups: Sequence[str] = ...,
    UserData: str = ...,
    ElasticGpuSpecification: Sequence[ElasticGpuSpecificationTypeDef] = ...,  # (6)
    ElasticInferenceAccelerators: Sequence[ElasticInferenceAcceleratorTypeDef] = ...,  # (7)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (8)
    LaunchTemplate: LaunchTemplateSpecificationTypeDef = ...,  # (9)
    InstanceMarketOptions: InstanceMarketOptionsRequestTypeDef = ...,  # (10)
    CreditSpecification: CreditSpecificationRequestTypeDef = ...,  # (11)
    CpuOptions: CpuOptionsRequestTypeDef = ...,  # (12)
    CapacityReservationSpecification: CapacityReservationSpecificationTypeDef = ...,  # (13)
    HibernationOptions: HibernationOptionsRequestTypeDef = ...,  # (14)
    LicenseSpecifications: Sequence[LicenseConfigurationRequestTypeDef] = ...,  # (15)
    MetadataOptions: InstanceMetadataOptionsRequestTypeDef = ...,  # (16)
    EnclaveOptions: EnclaveOptionsRequestTypeDef = ...,  # (17)
    PrivateDnsNameOptions: PrivateDnsNameOptionsRequestTypeDef = ...,  # (18)
    MaintenanceOptions: InstanceMaintenanceOptionsRequestTypeDef = ...,  # (19)
    DisableApiStop: bool = ...,
    EnablePrimaryIpv6: bool = ...,
    NetworkPerformanceOptions: InstanceNetworkPerformanceOptionsRequestTypeDef = ...,  # (20)
    Operator: OperatorRequestTypeDef = ...,  # (21)
    DryRun: bool = ...,
    DisableApiTermination: bool = ...,
    InstanceInitiatedShutdownBehavior: ShutdownBehaviorType = ...,  # (22)
    PrivateIpAddress: str = ...,
    ClientToken: str = ...,
    AdditionalInfo: str = ...,
    NetworkInterfaces: Sequence[InstanceNetworkInterfaceSpecificationTypeDef] = ...,  # (23)
    IamInstanceProfile: IamInstanceProfileSpecificationTypeDef = ...,  # (24)
    EbsOptimized: bool = ...,
) -> list[_Instance]:
    ...
  1. See BlockDeviceMappingTypeDef
  2. See InstanceTypeType
  3. See InstanceIpv6AddressTypeDef
  4. See RunInstancesMonitoringEnabledTypeDef
  5. See PlacementTypeDef
  6. See ElasticGpuSpecificationTypeDef
  7. See ElasticInferenceAcceleratorTypeDef
  8. See TagSpecificationTypeDef
  9. See LaunchTemplateSpecificationTypeDef
  10. See InstanceMarketOptionsRequestTypeDef
  11. See CreditSpecificationRequestTypeDef
  12. See CpuOptionsRequestTypeDef
  13. See CapacityReservationSpecificationTypeDef
  14. See HibernationOptionsRequestTypeDef
  15. See LicenseConfigurationRequestTypeDef
  16. See InstanceMetadataOptionsRequestTypeDef
  17. See EnclaveOptionsRequestTypeDef
  18. See PrivateDnsNameOptionsRequestTypeDef
  19. See InstanceMaintenanceOptionsRequestTypeDef
  20. See InstanceNetworkPerformanceOptionsRequestTypeDef
  21. See OperatorRequestTypeDef
  22. See ShutdownBehaviorType
  23. See InstanceNetworkInterfaceSpecificationTypeDef
  24. See IamInstanceProfileSpecificationTypeDef
# create_instances method usage example with argument unpacking

kwargs: RunInstancesRequestSubnetCreateInstancesTypeDef = {  # (1)
    "MaxCount": ...,
    "MinCount": ...,
}

parent.create_instances(**kwargs)
  1. See RunInstancesRequestSubnetCreateInstancesTypeDef

Subnet.create_network_interface method#

Creates a network interface in the specified subnet.

Type annotations and code completion for boto3.resource("ec2").create_network_interface method. boto3 documentation

# create_network_interface method definition

def create_network_interface(
    self,
    *,
    Ipv4Prefixes: Sequence[Ipv4PrefixSpecificationRequestTypeDef] = ...,  # (1)
    Ipv4PrefixCount: int = ...,
    Ipv6Prefixes: Sequence[Ipv6PrefixSpecificationRequestTypeDef] = ...,  # (2)
    Ipv6PrefixCount: int = ...,
    InterfaceType: NetworkInterfaceCreationTypeType = ...,  # (3)
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (4)
    ClientToken: str = ...,
    EnablePrimaryIpv6: bool = ...,
    ConnectionTrackingSpecification: ConnectionTrackingSpecificationRequestTypeDef = ...,  # (5)
    Operator: OperatorRequestTypeDef = ...,  # (6)
    Description: str = ...,
    PrivateIpAddress: str = ...,
    Groups: Sequence[str] = ...,
    PrivateIpAddresses: Sequence[PrivateIpAddressSpecificationTypeDef] = ...,  # (7)
    SecondaryPrivateIpAddressCount: int = ...,
    Ipv6Addresses: Sequence[InstanceIpv6AddressTypeDef] = ...,  # (8)
    Ipv6AddressCount: int = ...,
    DryRun: bool = ...,
) -> _NetworkInterface:
    ...
  1. See Ipv4PrefixSpecificationRequestTypeDef
  2. See Ipv6PrefixSpecificationRequestTypeDef
  3. See NetworkInterfaceCreationTypeType
  4. See TagSpecificationTypeDef
  5. See ConnectionTrackingSpecificationRequestTypeDef
  6. See OperatorRequestTypeDef
  7. See PrivateIpAddressSpecificationTypeDef
  8. See InstanceIpv6AddressTypeDef
# create_network_interface method usage example with argument unpacking

kwargs: CreateNetworkInterfaceRequestSubnetCreateNetworkInterfaceTypeDef = {  # (1)
    "Ipv4Prefixes": ...,
}

parent.create_network_interface(**kwargs)
  1. See CreateNetworkInterfaceRequestSubnetCreateNetworkInterfaceTypeDef

Subnet.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

Subnet.delete method#

Deletes the specified subnet.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteSubnetRequestSubnetDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteSubnetRequestSubnetDeleteTypeDef

Subnet.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Subnet.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Tag#

Type annotations and code completion for boto3.resource("ec2").Tag class. boto3 documentation

# Tag usage example

from mypy_boto3_ec2.service_resource import Tag

def get_resource() -> Tag:
    return boto3.resource("ec2").Tag(...)

Tag attributes#

  • resource_id: str
  • key: str
  • value: str
  • resource_type: ResourceTypeType
  • meta: EC2ResourceMeta

Tag methods#

Tag.get_available_subresources method#

Returns a list of all the available sub-resources for this Tag.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Tag.delete method#

Deletes the specified set of tags from the specified set of resources.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteTagsRequestTagDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteTagsRequestTagDeleteTypeDef

Tag.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Tag.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Volume#

Type annotations and code completion for boto3.resource("ec2").Volume class. boto3 documentation

# Volume usage example

from mypy_boto3_ec2.service_resource import Volume

def get_resource() -> Volume:
    return boto3.resource("ec2").Volume(...)

Volume attributes#

Volume collections#

Volume.snapshots#

Provides access to Snapshot resource.

Type annotations and code completion for boto3.resource("ec2").Volume(...).snapshots collection. boto3 documentation

# VolumeSnapshotsCollection usage example

from mypy_boto3_ec2.service_resource import VolumeSnapshotsCollection

def get_collection() -> VolumeSnapshotsCollection:
    resource = boto3.resource("ec2").Volume(...)
    return resource.snapshots

Volume methods#

Volume.get_available_subresources method#

Returns a list of all the available sub-resources for this Volume.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Volume.attach_to_instance method#

Attaches an EBS volume to a running or stopped instance and exposes it to the instance with the specified device name.

Type annotations and code completion for boto3.resource("ec2").attach_to_instance method. boto3 documentation

# attach_to_instance method definition

def attach_to_instance(
    self,
    *,
    Device: str,
    InstanceId: str,
    DryRun: bool = ...,
) -> VolumeAttachmentResponseTypeDef:  # (1)
    ...
  1. See VolumeAttachmentResponseTypeDef
# attach_to_instance method usage example with argument unpacking

kwargs: AttachVolumeRequestVolumeAttachToInstanceTypeDef = {  # (1)
    "Device": ...,
    "InstanceId": ...,
}

parent.attach_to_instance(**kwargs)
  1. See AttachVolumeRequestVolumeAttachToInstanceTypeDef

Volume.create_snapshot method#

Creates a snapshot of an EBS volume and stores it in Amazon S3.

Type annotations and code completion for boto3.resource("ec2").create_snapshot method. boto3 documentation

# create_snapshot method definition

def create_snapshot(
    self,
    *,
    Description: str = ...,
    OutpostArn: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    Location: SnapshotLocationEnumType = ...,  # (2)
    DryRun: bool = ...,
) -> _Snapshot:
    ...
  1. See TagSpecificationTypeDef
  2. See SnapshotLocationEnumType
# create_snapshot method usage example with argument unpacking

kwargs: CreateSnapshotRequestVolumeCreateSnapshotTypeDef = {  # (1)
    "Description": ...,
}

parent.create_snapshot(**kwargs)
  1. See CreateSnapshotRequestVolumeCreateSnapshotTypeDef

Volume.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

Volume.delete method#

Deletes the specified EBS volume.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteVolumeRequestVolumeDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteVolumeRequestVolumeDeleteTypeDef

Volume.describe_attribute method#

Describes the specified attribute of the specified volume.

Type annotations and code completion for boto3.resource("ec2").describe_attribute method. boto3 documentation

# describe_attribute method definition

def describe_attribute(
    self,
    *,
    Attribute: VolumeAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> DescribeVolumeAttributeResultTypeDef:  # (2)
    ...
  1. See VolumeAttributeNameType
  2. See DescribeVolumeAttributeResultTypeDef
# describe_attribute method usage example with argument unpacking

kwargs: DescribeVolumeAttributeRequestVolumeDescribeAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.describe_attribute(**kwargs)
  1. See DescribeVolumeAttributeRequestVolumeDescribeAttributeTypeDef

Volume.describe_status method#

Describes the status of the specified volumes.

Type annotations and code completion for boto3.resource("ec2").describe_status method. boto3 documentation

# describe_status method definition

def describe_status(
    self,
    *,
    MaxResults: int = ...,
    NextToken: str = ...,
    DryRun: bool = ...,
    Filters: Sequence[FilterTypeDef] = ...,  # (1)
) -> DescribeVolumeStatusResultTypeDef:  # (2)
    ...
  1. See FilterTypeDef
  2. See DescribeVolumeStatusResultTypeDef
# describe_status method usage example with argument unpacking

kwargs: DescribeVolumeStatusRequestVolumeDescribeStatusTypeDef = {  # (1)
    "MaxResults": ...,
}

parent.describe_status(**kwargs)
  1. See DescribeVolumeStatusRequestVolumeDescribeStatusTypeDef

Volume.detach_from_instance method#

Detaches an EBS volume from an instance.

Type annotations and code completion for boto3.resource("ec2").detach_from_instance method. boto3 documentation

# detach_from_instance method definition

def detach_from_instance(
    self,
    *,
    Device: str = ...,
    Force: bool = ...,
    InstanceId: str = ...,
    DryRun: bool = ...,
) -> VolumeAttachmentResponseTypeDef:  # (1)
    ...
  1. See VolumeAttachmentResponseTypeDef
# detach_from_instance method usage example with argument unpacking

kwargs: DetachVolumeRequestVolumeDetachFromInstanceTypeDef = {  # (1)
    "Device": ...,
}

parent.detach_from_instance(**kwargs)
  1. See DetachVolumeRequestVolumeDetachFromInstanceTypeDef

Volume.enable_io method#

Enables I/O operations for a volume that had I/O operations disabled because the data on the volume was potentially inconsistent.

Type annotations and code completion for boto3.resource("ec2").enable_io method. boto3 documentation

# enable_io method definition

def enable_io(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# enable_io method usage example with argument unpacking

kwargs: EnableVolumeIORequestVolumeEnableIoTypeDef = {  # (1)
    "DryRun": ...,
}

parent.enable_io(**kwargs)
  1. See EnableVolumeIORequestVolumeEnableIoTypeDef

Volume.modify_attribute method#

Modifies a volume attribute.

Type annotations and code completion for boto3.resource("ec2").modify_attribute method. boto3 documentation

# modify_attribute method definition

def modify_attribute(
    self,
    *,
    AutoEnableIO: AttributeBooleanValueTypeDef = ...,  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See AttributeBooleanValueTypeDef
# modify_attribute method usage example with argument unpacking

kwargs: ModifyVolumeAttributeRequestVolumeModifyAttributeTypeDef = {  # (1)
    "AutoEnableIO": ...,
}

parent.modify_attribute(**kwargs)
  1. See ModifyVolumeAttributeRequestVolumeModifyAttributeTypeDef

Volume.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Volume.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

Vpc#

Type annotations and code completion for boto3.resource("ec2").Vpc class. boto3 documentation

# Vpc usage example

from mypy_boto3_ec2.service_resource import Vpc

def get_resource() -> Vpc:
    return boto3.resource("ec2").Vpc(...)

Vpc attributes#

  • id: str
  • dhcp_options: DhcpOptions
  • accepted_vpc_peering_connections: VpcAcceptedVpcPeeringConnectionsCollection
  • instances: VpcInstancesCollection
  • internet_gateways: VpcInternetGatewaysCollection
  • network_acls: VpcNetworkAclsCollection
  • network_interfaces: VpcNetworkInterfacesCollection
  • requested_vpc_peering_connections: VpcRequestedVpcPeeringConnectionsCollection
  • route_tables: VpcRouteTablesCollection
  • security_groups: VpcSecurityGroupsCollection
  • subnets: VpcSubnetsCollection
  • owner_id: str
  • instance_tenancy: TenancyType
  • ipv6_cidr_block_association_set: list[VpcIpv6CidrBlockAssociationTypeDef]
  • cidr_block_association_set: list[VpcCidrBlockAssociationTypeDef]
  • is_default: bool
  • tags: list[TagTypeDef]
  • block_public_access_states: BlockPublicAccessStatesTypeDef
  • vpc_id: str
  • state: VpcStateType
  • cidr_block: str
  • dhcp_options_id: str
  • meta: EC2ResourceMeta

Vpc collections#

Vpc.accepted_vpc_peering_connections#

Provides access to VpcPeeringConnection resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).accepted_vpc_peering_connections collection. boto3 documentation

# VpcAcceptedVpcPeeringConnectionsCollection usage example

from mypy_boto3_ec2.service_resource import VpcAcceptedVpcPeeringConnectionsCollection

def get_collection() -> VpcAcceptedVpcPeeringConnectionsCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.accepted_vpc_peering_connections

Vpc.instances#

Provides access to Instance resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).instances collection. boto3 documentation

# VpcInstancesCollection usage example

from mypy_boto3_ec2.service_resource import VpcInstancesCollection

def get_collection() -> VpcInstancesCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.instances

Vpc.internet_gateways#

Provides access to InternetGateway resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).internet_gateways collection. boto3 documentation

# VpcInternetGatewaysCollection usage example

from mypy_boto3_ec2.service_resource import VpcInternetGatewaysCollection

def get_collection() -> VpcInternetGatewaysCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.internet_gateways

Vpc.network_acls#

Provides access to NetworkAcl resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).network_acls collection. boto3 documentation

# VpcNetworkAclsCollection usage example

from mypy_boto3_ec2.service_resource import VpcNetworkAclsCollection

def get_collection() -> VpcNetworkAclsCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.network_acls

Vpc.network_interfaces#

Provides access to NetworkInterface resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).network_interfaces collection. boto3 documentation

# VpcNetworkInterfacesCollection usage example

from mypy_boto3_ec2.service_resource import VpcNetworkInterfacesCollection

def get_collection() -> VpcNetworkInterfacesCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.network_interfaces

Vpc.requested_vpc_peering_connections#

Provides access to VpcPeeringConnection resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).requested_vpc_peering_connections collection. boto3 documentation

# VpcRequestedVpcPeeringConnectionsCollection usage example

from mypy_boto3_ec2.service_resource import VpcRequestedVpcPeeringConnectionsCollection

def get_collection() -> VpcRequestedVpcPeeringConnectionsCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.requested_vpc_peering_connections

Vpc.route_tables#

Provides access to RouteTable resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).route_tables collection. boto3 documentation

# VpcRouteTablesCollection usage example

from mypy_boto3_ec2.service_resource import VpcRouteTablesCollection

def get_collection() -> VpcRouteTablesCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.route_tables

Vpc.security_groups#

Provides access to SecurityGroup resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).security_groups collection. boto3 documentation

# VpcSecurityGroupsCollection usage example

from mypy_boto3_ec2.service_resource import VpcSecurityGroupsCollection

def get_collection() -> VpcSecurityGroupsCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.security_groups

Vpc.subnets#

Provides access to Subnet resource.

Type annotations and code completion for boto3.resource("ec2").Vpc(...).subnets collection. boto3 documentation

# VpcSubnetsCollection usage example

from mypy_boto3_ec2.service_resource import VpcSubnetsCollection

def get_collection() -> VpcSubnetsCollection:
    resource = boto3.resource("ec2").Vpc(...)
    return resource.subnets

Vpc methods#

Vpc.get_available_subresources method#

Returns a list of all the available sub-resources for this Vpc.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

Vpc.associate_dhcp_options method#

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.resource("ec2").associate_dhcp_options method. boto3 documentation

# associate_dhcp_options method definition

def associate_dhcp_options(
    self,
    *,
    DhcpOptionsId: str,
    DryRun: bool = ...,
) -> None:
    ...
# associate_dhcp_options method usage example with argument unpacking

kwargs: AssociateDhcpOptionsRequestVpcAssociateDhcpOptionsTypeDef = {  # (1)
    "DhcpOptionsId": ...,
}

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

This action is deprecated.

Type annotations and code completion for boto3.resource("ec2").attach_classic_link_instance method. boto3 documentation

# attach_classic_link_instance method definition

def attach_classic_link_instance(
    self,
    *,
    InstanceId: str,
    Groups: Sequence[str],
    DryRun: bool = ...,
) -> AttachClassicLinkVpcResultTypeDef:  # (1)
    ...
  1. See AttachClassicLinkVpcResultTypeDef
# attach_classic_link_instance method usage example with argument unpacking

kwargs: AttachClassicLinkVpcRequestVpcAttachClassicLinkInstanceTypeDef = {  # (1)
    "InstanceId": ...,
    "Groups": ...,
}

parent.attach_classic_link_instance(**kwargs)
  1. See AttachClassicLinkVpcRequestVpcAttachClassicLinkInstanceTypeDef

Vpc.attach_internet_gateway method#

Attaches an internet gateway or a virtual private gateway to a VPC, enabling connectivity between the internet and the VPC.

Type annotations and code completion for boto3.resource("ec2").attach_internet_gateway method. boto3 documentation

# attach_internet_gateway method definition

def attach_internet_gateway(
    self,
    *,
    InternetGatewayId: str,
    DryRun: bool = ...,
) -> None:
    ...
# attach_internet_gateway method usage example with argument unpacking

kwargs: AttachInternetGatewayRequestVpcAttachInternetGatewayTypeDef = {  # (1)
    "InternetGatewayId": ...,
}

parent.attach_internet_gateway(**kwargs)
  1. See AttachInternetGatewayRequestVpcAttachInternetGatewayTypeDef

Vpc.create_network_acl method#

Creates a network ACL in a VPC.

Type annotations and code completion for boto3.resource("ec2").create_network_acl method. boto3 documentation

# create_network_acl method definition

def create_network_acl(
    self,
    *,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    ClientToken: str = ...,
    DryRun: bool = ...,
) -> _NetworkAcl:
    ...
  1. See TagSpecificationTypeDef
# create_network_acl method usage example with argument unpacking

kwargs: CreateNetworkAclRequestVpcCreateNetworkAclTypeDef = {  # (1)
    "TagSpecifications": ...,
}

parent.create_network_acl(**kwargs)
  1. See CreateNetworkAclRequestVpcCreateNetworkAclTypeDef

Vpc.create_route_table method#

Creates a route table for the specified VPC.

Type annotations and code completion for boto3.resource("ec2").create_route_table method. boto3 documentation

# create_route_table method definition

def create_route_table(
    self,
    *,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    ClientToken: str = ...,
    DryRun: bool = ...,
) -> _RouteTable:
    ...
  1. See TagSpecificationTypeDef
# create_route_table method usage example with argument unpacking

kwargs: CreateRouteTableRequestVpcCreateRouteTableTypeDef = {  # (1)
    "TagSpecifications": ...,
}

parent.create_route_table(**kwargs)
  1. See CreateRouteTableRequestVpcCreateRouteTableTypeDef

Vpc.create_security_group method#

Creates a security group.

Type annotations and code completion for boto3.resource("ec2").create_security_group method. boto3 documentation

# create_security_group method definition

def create_security_group(
    self,
    *,
    Description: str,
    GroupName: str,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
) -> _SecurityGroup:
    ...
  1. See TagSpecificationTypeDef
# create_security_group method usage example with argument unpacking

kwargs: CreateSecurityGroupRequestVpcCreateSecurityGroupTypeDef = {  # (1)
    "Description": ...,
    "GroupName": ...,
}

parent.create_security_group(**kwargs)
  1. See CreateSecurityGroupRequestVpcCreateSecurityGroupTypeDef

Vpc.create_subnet method#

Creates a subnet in the specified VPC.

Type annotations and code completion for boto3.resource("ec2").create_subnet method. boto3 documentation

# create_subnet method definition

def create_subnet(
    self,
    *,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    AvailabilityZone: str = ...,
    AvailabilityZoneId: str = ...,
    CidrBlock: str = ...,
    Ipv6CidrBlock: str = ...,
    OutpostArn: str = ...,
    Ipv6Native: bool = ...,
    Ipv4IpamPoolId: str = ...,
    Ipv4NetmaskLength: int = ...,
    Ipv6IpamPoolId: str = ...,
    Ipv6NetmaskLength: int = ...,
    DryRun: bool = ...,
) -> _Subnet:
    ...
  1. See TagSpecificationTypeDef
# create_subnet method usage example with argument unpacking

kwargs: CreateSubnetRequestVpcCreateSubnetTypeDef = {  # (1)
    "TagSpecifications": ...,
}

parent.create_subnet(**kwargs)
  1. See CreateSubnetRequestVpcCreateSubnetTypeDef

Vpc.create_tags method#

Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources.

Type annotations and code completion for boto3.resource("ec2").create_tags method. boto3 documentation

# create_tags method definition

def create_tags(
    self,
    *,
    Tags: Sequence[TagTypeDef],  # (1)
    DryRun: bool = ...,
) -> None:
    ...
  1. See TagTypeDef
# create_tags method usage example with argument unpacking

kwargs: VpcCreateTagsRequestTypeDef = {  # (1)
    "Tags": ...,
}

parent.create_tags(**kwargs)
  1. See VpcCreateTagsRequestTypeDef

Vpc.delete method#

Deletes the specified VPC.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> None:
    ...
# delete method usage example with argument unpacking

kwargs: DeleteVpcRequestVpcDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteVpcRequestVpcDeleteTypeDef

Vpc.describe_attribute method#

Describes the specified attribute of the specified VPC.

Type annotations and code completion for boto3.resource("ec2").describe_attribute method. boto3 documentation

# describe_attribute method definition

def describe_attribute(
    self,
    *,
    Attribute: VpcAttributeNameType,  # (1)
    DryRun: bool = ...,
) -> DescribeVpcAttributeResultTypeDef:  # (2)
    ...
  1. See VpcAttributeNameType
  2. See DescribeVpcAttributeResultTypeDef
# describe_attribute method usage example with argument unpacking

kwargs: DescribeVpcAttributeRequestVpcDescribeAttributeTypeDef = {  # (1)
    "Attribute": ...,
}

parent.describe_attribute(**kwargs)
  1. See DescribeVpcAttributeRequestVpcDescribeAttributeTypeDef

This action is deprecated.

Type annotations and code completion for boto3.resource("ec2").detach_classic_link_instance method. boto3 documentation

# detach_classic_link_instance method definition

def detach_classic_link_instance(
    self,
    *,
    InstanceId: str,
    DryRun: bool = ...,
) -> DetachClassicLinkVpcResultTypeDef:  # (1)
    ...
  1. See DetachClassicLinkVpcResultTypeDef
# detach_classic_link_instance method usage example with argument unpacking

kwargs: DetachClassicLinkVpcRequestVpcDetachClassicLinkInstanceTypeDef = {  # (1)
    "InstanceId": ...,
}

parent.detach_classic_link_instance(**kwargs)
  1. See DetachClassicLinkVpcRequestVpcDetachClassicLinkInstanceTypeDef

Vpc.detach_internet_gateway method#

Detaches an internet gateway from a VPC, disabling connectivity between the internet and the VPC.

Type annotations and code completion for boto3.resource("ec2").detach_internet_gateway method. boto3 documentation

# detach_internet_gateway method definition

def detach_internet_gateway(
    self,
    *,
    InternetGatewayId: str,
    DryRun: bool = ...,
) -> None:
    ...
# detach_internet_gateway method usage example with argument unpacking

kwargs: DetachInternetGatewayRequestVpcDetachInternetGatewayTypeDef = {  # (1)
    "InternetGatewayId": ...,
}

parent.detach_internet_gateway(**kwargs)
  1. See DetachInternetGatewayRequestVpcDetachInternetGatewayTypeDef

This action is deprecated.

Type annotations and code completion for boto3.resource("ec2").disable_classic_link method. boto3 documentation

# disable_classic_link method definition

def disable_classic_link(
    self,
    *,
    DryRun: bool = ...,
) -> DisableVpcClassicLinkResultTypeDef:  # (1)
    ...
  1. See DisableVpcClassicLinkResultTypeDef
# disable_classic_link method usage example with argument unpacking

kwargs: DisableVpcClassicLinkRequestVpcDisableClassicLinkTypeDef = {  # (1)
    "DryRun": ...,
}

parent.disable_classic_link(**kwargs)
  1. See DisableVpcClassicLinkRequestVpcDisableClassicLinkTypeDef

This action is deprecated.

Type annotations and code completion for boto3.resource("ec2").enable_classic_link method. boto3 documentation

# enable_classic_link method definition

def enable_classic_link(
    self,
    *,
    DryRun: bool = ...,
) -> EnableVpcClassicLinkResultTypeDef:  # (1)
    ...
  1. See EnableVpcClassicLinkResultTypeDef
# enable_classic_link method usage example with argument unpacking

kwargs: EnableVpcClassicLinkRequestVpcEnableClassicLinkTypeDef = {  # (1)
    "DryRun": ...,
}

parent.enable_classic_link(**kwargs)
  1. See EnableVpcClassicLinkRequestVpcEnableClassicLinkTypeDef

Vpc.modify_attribute method#

Modifies the specified attribute of the specified VPC.

Type annotations and code completion for boto3.resource("ec2").modify_attribute method. boto3 documentation

# modify_attribute method definition

def modify_attribute(
    self,
    *,
    EnableDnsHostnames: AttributeBooleanValueTypeDef = ...,  # (1)
    EnableDnsSupport: AttributeBooleanValueTypeDef = ...,  # (1)
    EnableNetworkAddressUsageMetrics: AttributeBooleanValueTypeDef = ...,  # (1)
) -> None:
    ...
  1. See AttributeBooleanValueTypeDef
  2. See AttributeBooleanValueTypeDef
  3. See AttributeBooleanValueTypeDef
# modify_attribute method usage example with argument unpacking

kwargs: ModifyVpcAttributeRequestVpcModifyAttributeTypeDef = {  # (1)
    "EnableDnsHostnames": ...,
}

parent.modify_attribute(**kwargs)
  1. See ModifyVpcAttributeRequestVpcModifyAttributeTypeDef

Vpc.request_vpc_peering_connection method#

Requests a VPC peering connection between two VPCs: a requester VPC that you own and an accepter VPC with which to create the connection.

Type annotations and code completion for boto3.resource("ec2").request_vpc_peering_connection method. boto3 documentation

# request_vpc_peering_connection method definition

def request_vpc_peering_connection(
    self,
    *,
    PeerRegion: str = ...,
    TagSpecifications: Sequence[TagSpecificationTypeDef] = ...,  # (1)
    DryRun: bool = ...,
    PeerVpcId: str = ...,
    PeerOwnerId: str = ...,
) -> _VpcPeeringConnection:
    ...
  1. See TagSpecificationTypeDef
# request_vpc_peering_connection method usage example with argument unpacking

kwargs: CreateVpcPeeringConnectionRequestVpcRequestVpcPeeringConnectionTypeDef = {  # (1)
    "PeerRegion": ...,
}

parent.request_vpc_peering_connection(**kwargs)
  1. See CreateVpcPeeringConnectionRequestVpcRequestVpcPeeringConnectionTypeDef

Vpc.wait_until_available method#

Waits until Vpc is available.

Type annotations and code completion for boto3.resource("ec2").wait_until_available method. boto3 documentation

# wait_until_available method definition

def wait_until_available(
    self,
) -> None:
    ...

Vpc.wait_until_exists method#

Waits until Vpc is exists.

Type annotations and code completion for boto3.resource("ec2").wait_until_exists method. boto3 documentation

# wait_until_exists method definition

def wait_until_exists(
    self,
) -> None:
    ...

Vpc.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

Vpc.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

VpcPeeringConnection#

Type annotations and code completion for boto3.resource("ec2").VpcPeeringConnection class. boto3 documentation

# VpcPeeringConnection usage example

from mypy_boto3_ec2.service_resource import VpcPeeringConnection

def get_resource() -> VpcPeeringConnection:
    return boto3.resource("ec2").VpcPeeringConnection(...)

VpcPeeringConnection attributes#

VpcPeeringConnection methods#

VpcPeeringConnection.get_available_subresources method#

Returns a list of all the available sub-resources for this VpcPeeringConnection.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

VpcPeeringConnection.accept method#

Accept a VPC peering connection request.

Type annotations and code completion for boto3.resource("ec2").accept method. boto3 documentation

# accept method definition

def accept(
    self,
    *,
    DryRun: bool = ...,
) -> AcceptVpcPeeringConnectionResultTypeDef:  # (1)
    ...
  1. See AcceptVpcPeeringConnectionResultTypeDef
# accept method usage example with argument unpacking

kwargs: AcceptVpcPeeringConnectionRequestVpcPeeringConnectionAcceptTypeDef = {  # (1)
    "DryRun": ...,
}

parent.accept(**kwargs)
  1. See AcceptVpcPeeringConnectionRequestVpcPeeringConnectionAcceptTypeDef

VpcPeeringConnection.delete method#

Deletes a VPC peering connection.

Type annotations and code completion for boto3.resource("ec2").delete method. boto3 documentation

# delete method definition

def delete(
    self,
    *,
    DryRun: bool = ...,
) -> DeleteVpcPeeringConnectionResultTypeDef:  # (1)
    ...
  1. See DeleteVpcPeeringConnectionResultTypeDef
# delete method usage example with argument unpacking

kwargs: DeleteVpcPeeringConnectionRequestVpcPeeringConnectionDeleteTypeDef = {  # (1)
    "DryRun": ...,
}

parent.delete(**kwargs)
  1. See DeleteVpcPeeringConnectionRequestVpcPeeringConnectionDeleteTypeDef

VpcPeeringConnection.reject method#

Rejects a VPC peering connection request.

Type annotations and code completion for boto3.resource("ec2").reject method. boto3 documentation

# reject method definition

def reject(
    self,
    *,
    DryRun: bool = ...,
) -> RejectVpcPeeringConnectionResultTypeDef:  # (1)
    ...
  1. See RejectVpcPeeringConnectionResultTypeDef
# reject method usage example with argument unpacking

kwargs: RejectVpcPeeringConnectionRequestVpcPeeringConnectionRejectTypeDef = {  # (1)
    "DryRun": ...,
}

parent.reject(**kwargs)
  1. See RejectVpcPeeringConnectionRequestVpcPeeringConnectionRejectTypeDef

VpcPeeringConnection.wait_until_exists method#

Waits until VpcPeeringConnection is exists.

Type annotations and code completion for boto3.resource("ec2").wait_until_exists method. boto3 documentation

# wait_until_exists method definition

def wait_until_exists(
    self,
) -> None:
    ...

VpcPeeringConnection.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

VpcPeeringConnection.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...

VpcAddress#

Type annotations and code completion for boto3.resource("ec2").VpcAddress class. boto3 documentation

# VpcAddress usage example

from mypy_boto3_ec2.service_resource import VpcAddress

def get_resource() -> VpcAddress:
    return boto3.resource("ec2").VpcAddress(...)

VpcAddress attributes#

  • allocation_id: str
  • association: NetworkInterfaceAssociation
  • association_id: str
  • domain: DomainTypeType
  • network_interface_id: str
  • network_interface_owner_id: str
  • private_ip_address: str
  • tags: list[TagTypeDef]
  • public_ipv4_pool: str
  • network_border_group: str
  • customer_owned_ip: str
  • customer_owned_ipv4_pool: str
  • carrier_ip: str
  • instance_id: str
  • public_ip: str
  • meta: EC2ResourceMeta

VpcAddress methods#

VpcAddress.get_available_subresources method#

Returns a list of all the available sub-resources for this VpcAddress.

Type annotations and code completion for boto3.resource("ec2").get_available_subresources method. boto3 documentation

# get_available_subresources method definition

def get_available_subresources(
    self,
) -> Sequence[str]:
    ...

VpcAddress.associate method#

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.resource("ec2").associate method. boto3 documentation

# associate method definition

def associate(
    self,
    *,
    InstanceId: str = ...,
    PublicIp: str = ...,
    DryRun: bool = ...,
    NetworkInterfaceId: str = ...,
    PrivateIpAddress: str = ...,
    AllowReassociation: bool = ...,
) -> AssociateAddressResultTypeDef:  # (1)
    ...
  1. See AssociateAddressResultTypeDef
# associate method usage example with argument unpacking

kwargs: AssociateAddressRequestVpcAddressAssociateTypeDef = {  # (1)
    "InstanceId": ...,
}

parent.associate(**kwargs)
  1. See AssociateAddressRequestVpcAddressAssociateTypeDef

VpcAddress.release method#

Releases the specified Elastic IP address.

Type annotations and code completion for boto3.resource("ec2").release method. boto3 documentation

# release method definition

def release(
    self,
    *,
    AllocationId: str = ...,
    PublicIp: str = ...,
    NetworkBorderGroup: str = ...,
    DryRun: bool = ...,
) -> None:
    ...
# release method usage example with argument unpacking

kwargs: ReleaseAddressRequestVpcAddressReleaseTypeDef = {  # (1)
    "AllocationId": ...,
}

parent.release(**kwargs)
  1. See ReleaseAddressRequestVpcAddressReleaseTypeDef

VpcAddress.load method#

Type annotations and code completion for boto3.resource("ec2").load method. boto3 documentation

# load method definition

def load(
    self,
) -> None:
    ...

VpcAddress.reload method#

Type annotations and code completion for boto3.resource("ec2").reload method. boto3 documentation

# reload method definition

def reload(
    self,
) -> None:
    ...