Best Python code snippet using localstack_python
__init__.pyi
Source:__init__.pyi
1"""2Main interface for ec2 service.3Usage::4 ```python5 import boto36 from mypy_boto3_ec2 import (7 BundleTaskCompleteWaiter,8 Client,9 ConversionTaskCancelledWaiter,10 ConversionTaskCompletedWaiter,11 ConversionTaskDeletedWaiter,12 CustomerGatewayAvailableWaiter,13 DescribeByoipCidrsPaginator,14 DescribeCapacityReservationsPaginator,15 DescribeCarrierGatewaysPaginator,16 DescribeClassicLinkInstancesPaginator,17 DescribeClientVpnAuthorizationRulesPaginator,18 DescribeClientVpnConnectionsPaginator,19 DescribeClientVpnEndpointsPaginator,20 DescribeClientVpnRoutesPaginator,21 DescribeClientVpnTargetNetworksPaginator,22 DescribeCoipPoolsPaginator,23 DescribeDhcpOptionsPaginator,24 DescribeEgressOnlyInternetGatewaysPaginator,25 DescribeExportImageTasksPaginator,26 DescribeFastSnapshotRestoresPaginator,27 DescribeFleetsPaginator,28 DescribeFlowLogsPaginator,29 DescribeFpgaImagesPaginator,30 DescribeHostReservationOfferingsPaginator,31 DescribeHostReservationsPaginator,32 DescribeHostsPaginator,33 DescribeIamInstanceProfileAssociationsPaginator,34 DescribeImportImageTasksPaginator,35 DescribeImportSnapshotTasksPaginator,36 DescribeInstanceCreditSpecificationsPaginator,37 DescribeInstanceStatusPaginator,38 DescribeInstanceTypeOfferingsPaginator,39 DescribeInstanceTypesPaginator,40 DescribeInstancesPaginator,41 DescribeInternetGatewaysPaginator,42 DescribeIpv6PoolsPaginator,43 DescribeLaunchTemplateVersionsPaginator,44 DescribeLaunchTemplatesPaginator,45 DescribeLocalGatewayRouteTableVirtualInterfaceGroupAssociationsPaginator,46 DescribeLocalGatewayRouteTableVpcAssociationsPaginator,47 DescribeLocalGatewayRouteTablesPaginator,48 DescribeLocalGatewayVirtualInterfaceGroupsPaginator,49 DescribeLocalGatewayVirtualInterfacesPaginator,50 DescribeLocalGatewaysPaginator,51 DescribeManagedPrefixListsPaginator,52 DescribeMovingAddressesPaginator,53 DescribeNatGatewaysPaginator,54 DescribeNetworkAclsPaginator,55 DescribeNetworkInterfacePermissionsPaginator,56 DescribeNetworkInterfacesPaginator,57 DescribePrefixListsPaginator,58 DescribePrincipalIdFormatPaginator,59 DescribePublicIpv4PoolsPaginator,60 DescribeReservedInstancesModificationsPaginator,61 DescribeReservedInstancesOfferingsPaginator,62 DescribeRouteTablesPaginator,63 DescribeScheduledInstanceAvailabilityPaginator,64 DescribeScheduledInstancesPaginator,65 DescribeSecurityGroupsPaginator,66 DescribeSnapshotsPaginator,67 DescribeSpotFleetInstancesPaginator,68 DescribeSpotFleetRequestsPaginator,69 DescribeSpotInstanceRequestsPaginator,70 DescribeSpotPriceHistoryPaginator,71 DescribeStaleSecurityGroupsPaginator,72 DescribeSubnetsPaginator,73 DescribeTagsPaginator,74 DescribeTrafficMirrorFiltersPaginator,75 DescribeTrafficMirrorSessionsPaginator,76 DescribeTrafficMirrorTargetsPaginator,77 DescribeTransitGatewayAttachmentsPaginator,78 DescribeTransitGatewayMulticastDomainsPaginator,79 DescribeTransitGatewayPeeringAttachmentsPaginator,80 DescribeTransitGatewayRouteTablesPaginator,81 DescribeTransitGatewayVpcAttachmentsPaginator,82 DescribeTransitGatewaysPaginator,83 DescribeVolumeStatusPaginator,84 DescribeVolumesModificationsPaginator,85 DescribeVolumesPaginator,86 DescribeVpcClassicLinkDnsSupportPaginator,87 DescribeVpcEndpointConnectionNotificationsPaginator,88 DescribeVpcEndpointConnectionsPaginator,89 DescribeVpcEndpointServiceConfigurationsPaginator,90 DescribeVpcEndpointServicePermissionsPaginator,91 DescribeVpcEndpointServicesPaginator,92 DescribeVpcEndpointsPaginator,93 DescribeVpcPeeringConnectionsPaginator,94 DescribeVpcsPaginator,95 EC2Client,96 EC2ServiceResource,97 ExportTaskCancelledWaiter,98 ExportTaskCompletedWaiter,99 GetAssociatedIpv6PoolCidrsPaginator,100 GetGroupsForCapacityReservationPaginator,101 GetManagedPrefixListAssociationsPaginator,102 GetManagedPrefixListEntriesPaginator,103 GetTransitGatewayAttachmentPropagationsPaginator,104 GetTransitGatewayMulticastDomainAssociationsPaginator,105 GetTransitGatewayRouteTableAssociationsPaginator,106 GetTransitGatewayRouteTablePropagationsPaginator,107 ImageAvailableWaiter,108 ImageExistsWaiter,109 InstanceExistsWaiter,110 InstanceRunningWaiter,111 InstanceStatusOkWaiter,112 InstanceStoppedWaiter,113 InstanceTerminatedWaiter,114 KeyPairExistsWaiter,115 NatGatewayAvailableWaiter,116 NetworkInterfaceAvailableWaiter,117 PasswordDataAvailableWaiter,118 SearchLocalGatewayRoutesPaginator,119 SearchTransitGatewayMulticastGroupsPaginator,120 SecurityGroupExistsWaiter,121 ServiceResource,122 SnapshotCompletedWaiter,123 SpotInstanceRequestFulfilledWaiter,124 SubnetAvailableWaiter,125 SystemStatusOkWaiter,126 VolumeAvailableWaiter,127 VolumeDeletedWaiter,128 VolumeInUseWaiter,129 VpcAvailableWaiter,130 VpcExistsWaiter,131 VpcPeeringConnectionDeletedWaiter,132 VpcPeeringConnectionExistsWaiter,133 VpnConnectionAvailableWaiter,134 VpnConnectionDeletedWaiter,135 )136 session = boto3.Session()137 client: EC2Client = boto3.client("ec2")138 session_client: EC2Client = session.client("ec2")139 resource: EC2ServiceResource = boto3.resource("ec2")140 session_resource: EC2ServiceResource = session.resource("ec2")141 bundle_task_complete_waiter: BundleTaskCompleteWaiter = client.get_waiter("bundle_task_complete")142 conversion_task_cancelled_waiter: ConversionTaskCancelledWaiter = client.get_waiter("conversion_task_cancelled")143 conversion_task_completed_waiter: ConversionTaskCompletedWaiter = client.get_waiter("conversion_task_completed")144 conversion_task_deleted_waiter: ConversionTaskDeletedWaiter = client.get_waiter("conversion_task_deleted")145 customer_gateway_available_waiter: CustomerGatewayAvailableWaiter = client.get_waiter("customer_gateway_available")146 export_task_cancelled_waiter: ExportTaskCancelledWaiter = client.get_waiter("export_task_cancelled")147 export_task_completed_waiter: ExportTaskCompletedWaiter = client.get_waiter("export_task_completed")148 image_available_waiter: ImageAvailableWaiter = client.get_waiter("image_available")149 image_exists_waiter: ImageExistsWaiter = client.get_waiter("image_exists")150 instance_exists_waiter: InstanceExistsWaiter = client.get_waiter("instance_exists")151 instance_running_waiter: InstanceRunningWaiter = client.get_waiter("instance_running")152 instance_status_ok_waiter: InstanceStatusOkWaiter = client.get_waiter("instance_status_ok")153 instance_stopped_waiter: InstanceStoppedWaiter = client.get_waiter("instance_stopped")154 instance_terminated_waiter: InstanceTerminatedWaiter = client.get_waiter("instance_terminated")155 key_pair_exists_waiter: KeyPairExistsWaiter = client.get_waiter("key_pair_exists")156 nat_gateway_available_waiter: NatGatewayAvailableWaiter = client.get_waiter("nat_gateway_available")157 network_interface_available_waiter: NetworkInterfaceAvailableWaiter = client.get_waiter("network_interface_available")158 password_data_available_waiter: PasswordDataAvailableWaiter = client.get_waiter("password_data_available")159 security_group_exists_waiter: SecurityGroupExistsWaiter = client.get_waiter("security_group_exists")160 snapshot_completed_waiter: SnapshotCompletedWaiter = client.get_waiter("snapshot_completed")161 spot_instance_request_fulfilled_waiter: SpotInstanceRequestFulfilledWaiter = client.get_waiter("spot_instance_request_fulfilled")162 subnet_available_waiter: SubnetAvailableWaiter = client.get_waiter("subnet_available")163 system_status_ok_waiter: SystemStatusOkWaiter = client.get_waiter("system_status_ok")164 volume_available_waiter: VolumeAvailableWaiter = client.get_waiter("volume_available")165 volume_deleted_waiter: VolumeDeletedWaiter = client.get_waiter("volume_deleted")166 volume_in_use_waiter: VolumeInUseWaiter = client.get_waiter("volume_in_use")167 vpc_available_waiter: VpcAvailableWaiter = client.get_waiter("vpc_available")168 vpc_exists_waiter: VpcExistsWaiter = client.get_waiter("vpc_exists")169 vpc_peering_connection_deleted_waiter: VpcPeeringConnectionDeletedWaiter = client.get_waiter("vpc_peering_connection_deleted")170 vpc_peering_connection_exists_waiter: VpcPeeringConnectionExistsWaiter = client.get_waiter("vpc_peering_connection_exists")171 vpn_connection_available_waiter: VpnConnectionAvailableWaiter = client.get_waiter("vpn_connection_available")172 vpn_connection_deleted_waiter: VpnConnectionDeletedWaiter = client.get_waiter("vpn_connection_deleted")173 describe_byoip_cidrs_paginator: DescribeByoipCidrsPaginator = client.get_paginator("describe_byoip_cidrs")174 describe_capacity_reservations_paginator: DescribeCapacityReservationsPaginator = client.get_paginator("describe_capacity_reservations")175 describe_carrier_gateways_paginator: DescribeCarrierGatewaysPaginator = client.get_paginator("describe_carrier_gateways")176 describe_classic_link_instances_paginator: DescribeClassicLinkInstancesPaginator = client.get_paginator("describe_classic_link_instances")177 describe_client_vpn_authorization_rules_paginator: DescribeClientVpnAuthorizationRulesPaginator = client.get_paginator("describe_client_vpn_authorization_rules")178 describe_client_vpn_connections_paginator: DescribeClientVpnConnectionsPaginator = client.get_paginator("describe_client_vpn_connections")179 describe_client_vpn_endpoints_paginator: DescribeClientVpnEndpointsPaginator = client.get_paginator("describe_client_vpn_endpoints")180 describe_client_vpn_routes_paginator: DescribeClientVpnRoutesPaginator = client.get_paginator("describe_client_vpn_routes")181 describe_client_vpn_target_networks_paginator: DescribeClientVpnTargetNetworksPaginator = client.get_paginator("describe_client_vpn_target_networks")182 describe_coip_pools_paginator: DescribeCoipPoolsPaginator = client.get_paginator("describe_coip_pools")183 describe_dhcp_options_paginator: DescribeDhcpOptionsPaginator = client.get_paginator("describe_dhcp_options")184 describe_egress_only_internet_gateways_paginator: DescribeEgressOnlyInternetGatewaysPaginator = client.get_paginator("describe_egress_only_internet_gateways")185 describe_export_image_tasks_paginator: DescribeExportImageTasksPaginator = client.get_paginator("describe_export_image_tasks")186 describe_fast_snapshot_restores_paginator: DescribeFastSnapshotRestoresPaginator = client.get_paginator("describe_fast_snapshot_restores")187 describe_fleets_paginator: DescribeFleetsPaginator = client.get_paginator("describe_fleets")188 describe_flow_logs_paginator: DescribeFlowLogsPaginator = client.get_paginator("describe_flow_logs")189 describe_fpga_images_paginator: DescribeFpgaImagesPaginator = client.get_paginator("describe_fpga_images")190 describe_host_reservation_offerings_paginator: DescribeHostReservationOfferingsPaginator = client.get_paginator("describe_host_reservation_offerings")191 describe_host_reservations_paginator: DescribeHostReservationsPaginator = client.get_paginator("describe_host_reservations")192 describe_hosts_paginator: DescribeHostsPaginator = client.get_paginator("describe_hosts")193 describe_iam_instance_profile_associations_paginator: DescribeIamInstanceProfileAssociationsPaginator = client.get_paginator("describe_iam_instance_profile_associations")194 describe_import_image_tasks_paginator: DescribeImportImageTasksPaginator = client.get_paginator("describe_import_image_tasks")195 describe_import_snapshot_tasks_paginator: DescribeImportSnapshotTasksPaginator = client.get_paginator("describe_import_snapshot_tasks")196 describe_instance_credit_specifications_paginator: DescribeInstanceCreditSpecificationsPaginator = client.get_paginator("describe_instance_credit_specifications")197 describe_instance_status_paginator: DescribeInstanceStatusPaginator = client.get_paginator("describe_instance_status")198 describe_instance_type_offerings_paginator: DescribeInstanceTypeOfferingsPaginator = client.get_paginator("describe_instance_type_offerings")199 describe_instance_types_paginator: DescribeInstanceTypesPaginator = client.get_paginator("describe_instance_types")200 describe_instances_paginator: DescribeInstancesPaginator = client.get_paginator("describe_instances")201 describe_internet_gateways_paginator: DescribeInternetGatewaysPaginator = client.get_paginator("describe_internet_gateways")202 describe_ipv6_pools_paginator: DescribeIpv6PoolsPaginator = client.get_paginator("describe_ipv6_pools")203 describe_launch_template_versions_paginator: DescribeLaunchTemplateVersionsPaginator = client.get_paginator("describe_launch_template_versions")204 describe_launch_templates_paginator: DescribeLaunchTemplatesPaginator = client.get_paginator("describe_launch_templates")205 describe_local_gateway_route_table_virtual_interface_group_associations_paginator: DescribeLocalGatewayRouteTableVirtualInterfaceGroupAssociationsPaginator = client.get_paginator("describe_local_gateway_route_table_virtual_interface_group_associations")206 describe_local_gateway_route_table_vpc_associations_paginator: DescribeLocalGatewayRouteTableVpcAssociationsPaginator = client.get_paginator("describe_local_gateway_route_table_vpc_associations")207 describe_local_gateway_route_tables_paginator: DescribeLocalGatewayRouteTablesPaginator = client.get_paginator("describe_local_gateway_route_tables")208 describe_local_gateway_virtual_interface_groups_paginator: DescribeLocalGatewayVirtualInterfaceGroupsPaginator = client.get_paginator("describe_local_gateway_virtual_interface_groups")209 describe_local_gateway_virtual_interfaces_paginator: DescribeLocalGatewayVirtualInterfacesPaginator = client.get_paginator("describe_local_gateway_virtual_interfaces")210 describe_local_gateways_paginator: DescribeLocalGatewaysPaginator = client.get_paginator("describe_local_gateways")211 describe_managed_prefix_lists_paginator: DescribeManagedPrefixListsPaginator = client.get_paginator("describe_managed_prefix_lists")212 describe_moving_addresses_paginator: DescribeMovingAddressesPaginator = client.get_paginator("describe_moving_addresses")213 describe_nat_gateways_paginator: DescribeNatGatewaysPaginator = client.get_paginator("describe_nat_gateways")214 describe_network_acls_paginator: DescribeNetworkAclsPaginator = client.get_paginator("describe_network_acls")215 describe_network_interface_permissions_paginator: DescribeNetworkInterfacePermissionsPaginator = client.get_paginator("describe_network_interface_permissions")216 describe_network_interfaces_paginator: DescribeNetworkInterfacesPaginator = client.get_paginator("describe_network_interfaces")217 describe_prefix_lists_paginator: DescribePrefixListsPaginator = client.get_paginator("describe_prefix_lists")218 describe_principal_id_format_paginator: DescribePrincipalIdFormatPaginator = client.get_paginator("describe_principal_id_format")219 describe_public_ipv4_pools_paginator: DescribePublicIpv4PoolsPaginator = client.get_paginator("describe_public_ipv4_pools")220 describe_reserved_instances_modifications_paginator: DescribeReservedInstancesModificationsPaginator = client.get_paginator("describe_reserved_instances_modifications")221 describe_reserved_instances_offerings_paginator: DescribeReservedInstancesOfferingsPaginator = client.get_paginator("describe_reserved_instances_offerings")222 describe_route_tables_paginator: DescribeRouteTablesPaginator = client.get_paginator("describe_route_tables")223 describe_scheduled_instance_availability_paginator: DescribeScheduledInstanceAvailabilityPaginator = client.get_paginator("describe_scheduled_instance_availability")224 describe_scheduled_instances_paginator: DescribeScheduledInstancesPaginator = client.get_paginator("describe_scheduled_instances")225 describe_security_groups_paginator: DescribeSecurityGroupsPaginator = client.get_paginator("describe_security_groups")226 describe_snapshots_paginator: DescribeSnapshotsPaginator = client.get_paginator("describe_snapshots")227 describe_spot_fleet_instances_paginator: DescribeSpotFleetInstancesPaginator = client.get_paginator("describe_spot_fleet_instances")228 describe_spot_fleet_requests_paginator: DescribeSpotFleetRequestsPaginator = client.get_paginator("describe_spot_fleet_requests")229 describe_spot_instance_requests_paginator: DescribeSpotInstanceRequestsPaginator = client.get_paginator("describe_spot_instance_requests")230 describe_spot_price_history_paginator: DescribeSpotPriceHistoryPaginator = client.get_paginator("describe_spot_price_history")231 describe_stale_security_groups_paginator: DescribeStaleSecurityGroupsPaginator = client.get_paginator("describe_stale_security_groups")232 describe_subnets_paginator: DescribeSubnetsPaginator = client.get_paginator("describe_subnets")233 describe_tags_paginator: DescribeTagsPaginator = client.get_paginator("describe_tags")234 describe_traffic_mirror_filters_paginator: DescribeTrafficMirrorFiltersPaginator = client.get_paginator("describe_traffic_mirror_filters")235 describe_traffic_mirror_sessions_paginator: DescribeTrafficMirrorSessionsPaginator = client.get_paginator("describe_traffic_mirror_sessions")236 describe_traffic_mirror_targets_paginator: DescribeTrafficMirrorTargetsPaginator = client.get_paginator("describe_traffic_mirror_targets")237 describe_transit_gateway_attachments_paginator: DescribeTransitGatewayAttachmentsPaginator = client.get_paginator("describe_transit_gateway_attachments")238 describe_transit_gateway_multicast_domains_paginator: DescribeTransitGatewayMulticastDomainsPaginator = client.get_paginator("describe_transit_gateway_multicast_domains")239 describe_transit_gateway_peering_attachments_paginator: DescribeTransitGatewayPeeringAttachmentsPaginator = client.get_paginator("describe_transit_gateway_peering_attachments")240 describe_transit_gateway_route_tables_paginator: DescribeTransitGatewayRouteTablesPaginator = client.get_paginator("describe_transit_gateway_route_tables")241 describe_transit_gateway_vpc_attachments_paginator: DescribeTransitGatewayVpcAttachmentsPaginator = client.get_paginator("describe_transit_gateway_vpc_attachments")242 describe_transit_gateways_paginator: DescribeTransitGatewaysPaginator = client.get_paginator("describe_transit_gateways")243 describe_volume_status_paginator: DescribeVolumeStatusPaginator = client.get_paginator("describe_volume_status")244 describe_volumes_paginator: DescribeVolumesPaginator = client.get_paginator("describe_volumes")245 describe_volumes_modifications_paginator: DescribeVolumesModificationsPaginator = client.get_paginator("describe_volumes_modifications")246 describe_vpc_classic_link_dns_support_paginator: DescribeVpcClassicLinkDnsSupportPaginator = client.get_paginator("describe_vpc_classic_link_dns_support")247 describe_vpc_endpoint_connection_notifications_paginator: DescribeVpcEndpointConnectionNotificationsPaginator = client.get_paginator("describe_vpc_endpoint_connection_notifications")248 describe_vpc_endpoint_connections_paginator: DescribeVpcEndpointConnectionsPaginator = client.get_paginator("describe_vpc_endpoint_connections")249 describe_vpc_endpoint_service_configurations_paginator: DescribeVpcEndpointServiceConfigurationsPaginator = client.get_paginator("describe_vpc_endpoint_service_configurations")250 describe_vpc_endpoint_service_permissions_paginator: DescribeVpcEndpointServicePermissionsPaginator = client.get_paginator("describe_vpc_endpoint_service_permissions")251 describe_vpc_endpoint_services_paginator: DescribeVpcEndpointServicesPaginator = client.get_paginator("describe_vpc_endpoint_services")252 describe_vpc_endpoints_paginator: DescribeVpcEndpointsPaginator = client.get_paginator("describe_vpc_endpoints")253 describe_vpc_peering_connections_paginator: DescribeVpcPeeringConnectionsPaginator = client.get_paginator("describe_vpc_peering_connections")254 describe_vpcs_paginator: DescribeVpcsPaginator = client.get_paginator("describe_vpcs")255 get_associated_ipv6_pool_cidrs_paginator: GetAssociatedIpv6PoolCidrsPaginator = client.get_paginator("get_associated_ipv6_pool_cidrs")256 get_groups_for_capacity_reservation_paginator: GetGroupsForCapacityReservationPaginator = client.get_paginator("get_groups_for_capacity_reservation")257 get_managed_prefix_list_associations_paginator: GetManagedPrefixListAssociationsPaginator = client.get_paginator("get_managed_prefix_list_associations")258 get_managed_prefix_list_entries_paginator: GetManagedPrefixListEntriesPaginator = client.get_paginator("get_managed_prefix_list_entries")259 get_transit_gateway_attachment_propagations_paginator: GetTransitGatewayAttachmentPropagationsPaginator = client.get_paginator("get_transit_gateway_attachment_propagations")260 get_transit_gateway_multicast_domain_associations_paginator: GetTransitGatewayMulticastDomainAssociationsPaginator = client.get_paginator("get_transit_gateway_multicast_domain_associations")261 get_transit_gateway_route_table_associations_paginator: GetTransitGatewayRouteTableAssociationsPaginator = client.get_paginator("get_transit_gateway_route_table_associations")262 get_transit_gateway_route_table_propagations_paginator: GetTransitGatewayRouteTablePropagationsPaginator = client.get_paginator("get_transit_gateway_route_table_propagations")263 search_local_gateway_routes_paginator: SearchLocalGatewayRoutesPaginator = client.get_paginator("search_local_gateway_routes")264 search_transit_gateway_multicast_groups_paginator: SearchTransitGatewayMulticastGroupsPaginator = client.get_paginator("search_transit_gateway_multicast_groups")265 ```266"""267from mypy_boto3_ec2.client import EC2Client268from mypy_boto3_ec2.paginator import (269 DescribeByoipCidrsPaginator,270 DescribeCapacityReservationsPaginator,271 DescribeCarrierGatewaysPaginator,272 DescribeClassicLinkInstancesPaginator,273 DescribeClientVpnAuthorizationRulesPaginator,274 DescribeClientVpnConnectionsPaginator,275 DescribeClientVpnEndpointsPaginator,276 DescribeClientVpnRoutesPaginator,277 DescribeClientVpnTargetNetworksPaginator,278 DescribeCoipPoolsPaginator,279 DescribeDhcpOptionsPaginator,280 DescribeEgressOnlyInternetGatewaysPaginator,281 DescribeExportImageTasksPaginator,282 DescribeFastSnapshotRestoresPaginator,283 DescribeFleetsPaginator,284 DescribeFlowLogsPaginator,285 DescribeFpgaImagesPaginator,286 DescribeHostReservationOfferingsPaginator,287 DescribeHostReservationsPaginator,288 DescribeHostsPaginator,289 DescribeIamInstanceProfileAssociationsPaginator,290 DescribeImportImageTasksPaginator,291 DescribeImportSnapshotTasksPaginator,292 DescribeInstanceCreditSpecificationsPaginator,293 DescribeInstancesPaginator,294 DescribeInstanceStatusPaginator,295 DescribeInstanceTypeOfferingsPaginator,296 DescribeInstanceTypesPaginator,297 DescribeInternetGatewaysPaginator,298 DescribeIpv6PoolsPaginator,299 DescribeLaunchTemplatesPaginator,300 DescribeLaunchTemplateVersionsPaginator,301 DescribeLocalGatewayRouteTablesPaginator,302 DescribeLocalGatewayRouteTableVirtualInterfaceGroupAssociationsPaginator,303 DescribeLocalGatewayRouteTableVpcAssociationsPaginator,304 DescribeLocalGatewaysPaginator,305 DescribeLocalGatewayVirtualInterfaceGroupsPaginator,306 DescribeLocalGatewayVirtualInterfacesPaginator,307 DescribeManagedPrefixListsPaginator,308 DescribeMovingAddressesPaginator,309 DescribeNatGatewaysPaginator,310 DescribeNetworkAclsPaginator,311 DescribeNetworkInterfacePermissionsPaginator,312 DescribeNetworkInterfacesPaginator,313 DescribePrefixListsPaginator,314 DescribePrincipalIdFormatPaginator,315 DescribePublicIpv4PoolsPaginator,316 DescribeReservedInstancesModificationsPaginator,317 DescribeReservedInstancesOfferingsPaginator,318 DescribeRouteTablesPaginator,319 DescribeScheduledInstanceAvailabilityPaginator,320 DescribeScheduledInstancesPaginator,321 DescribeSecurityGroupsPaginator,322 DescribeSnapshotsPaginator,323 DescribeSpotFleetInstancesPaginator,324 DescribeSpotFleetRequestsPaginator,325 DescribeSpotInstanceRequestsPaginator,326 DescribeSpotPriceHistoryPaginator,327 DescribeStaleSecurityGroupsPaginator,328 DescribeSubnetsPaginator,329 DescribeTagsPaginator,330 DescribeTrafficMirrorFiltersPaginator,331 DescribeTrafficMirrorSessionsPaginator,332 DescribeTrafficMirrorTargetsPaginator,333 DescribeTransitGatewayAttachmentsPaginator,334 DescribeTransitGatewayMulticastDomainsPaginator,335 DescribeTransitGatewayPeeringAttachmentsPaginator,336 DescribeTransitGatewayRouteTablesPaginator,337 DescribeTransitGatewaysPaginator,338 DescribeTransitGatewayVpcAttachmentsPaginator,339 DescribeVolumesModificationsPaginator,340 DescribeVolumesPaginator,341 DescribeVolumeStatusPaginator,342 DescribeVpcClassicLinkDnsSupportPaginator,343 DescribeVpcEndpointConnectionNotificationsPaginator,344 DescribeVpcEndpointConnectionsPaginator,345 DescribeVpcEndpointServiceConfigurationsPaginator,346 DescribeVpcEndpointServicePermissionsPaginator,347 DescribeVpcEndpointServicesPaginator,348 DescribeVpcEndpointsPaginator,349 DescribeVpcPeeringConnectionsPaginator,350 DescribeVpcsPaginator,351 GetAssociatedIpv6PoolCidrsPaginator,352 GetGroupsForCapacityReservationPaginator,353 GetManagedPrefixListAssociationsPaginator,354 GetManagedPrefixListEntriesPaginator,355 GetTransitGatewayAttachmentPropagationsPaginator,356 GetTransitGatewayMulticastDomainAssociationsPaginator,357 GetTransitGatewayRouteTableAssociationsPaginator,358 GetTransitGatewayRouteTablePropagationsPaginator,359 SearchLocalGatewayRoutesPaginator,360 SearchTransitGatewayMulticastGroupsPaginator,361)362from mypy_boto3_ec2.service_resource import EC2ServiceResource363from mypy_boto3_ec2.waiter import (364 BundleTaskCompleteWaiter,365 ConversionTaskCancelledWaiter,366 ConversionTaskCompletedWaiter,367 ConversionTaskDeletedWaiter,368 CustomerGatewayAvailableWaiter,369 ExportTaskCancelledWaiter,370 ExportTaskCompletedWaiter,371 ImageAvailableWaiter,372 ImageExistsWaiter,373 InstanceExistsWaiter,374 InstanceRunningWaiter,375 InstanceStatusOkWaiter,376 InstanceStoppedWaiter,377 InstanceTerminatedWaiter,378 KeyPairExistsWaiter,379 NatGatewayAvailableWaiter,380 NetworkInterfaceAvailableWaiter,381 PasswordDataAvailableWaiter,382 SecurityGroupExistsWaiter,383 SnapshotCompletedWaiter,384 SpotInstanceRequestFulfilledWaiter,385 SubnetAvailableWaiter,386 SystemStatusOkWaiter,387 VolumeAvailableWaiter,388 VolumeDeletedWaiter,389 VolumeInUseWaiter,390 VpcAvailableWaiter,391 VpcExistsWaiter,392 VpcPeeringConnectionDeletedWaiter,393 VpcPeeringConnectionExistsWaiter,394 VpnConnectionAvailableWaiter,395 VpnConnectionDeletedWaiter,396)397Client = EC2Client398ServiceResource = EC2ServiceResource399__all__ = (400 "BundleTaskCompleteWaiter",401 "Client",402 "ConversionTaskCancelledWaiter",403 "ConversionTaskCompletedWaiter",404 "ConversionTaskDeletedWaiter",405 "CustomerGatewayAvailableWaiter",406 "DescribeByoipCidrsPaginator",407 "DescribeCapacityReservationsPaginator",408 "DescribeCarrierGatewaysPaginator",409 "DescribeClassicLinkInstancesPaginator",410 "DescribeClientVpnAuthorizationRulesPaginator",411 "DescribeClientVpnConnectionsPaginator",412 "DescribeClientVpnEndpointsPaginator",413 "DescribeClientVpnRoutesPaginator",414 "DescribeClientVpnTargetNetworksPaginator",415 "DescribeCoipPoolsPaginator",416 "DescribeDhcpOptionsPaginator",417 "DescribeEgressOnlyInternetGatewaysPaginator",418 "DescribeExportImageTasksPaginator",419 "DescribeFastSnapshotRestoresPaginator",420 "DescribeFleetsPaginator",421 "DescribeFlowLogsPaginator",422 "DescribeFpgaImagesPaginator",423 "DescribeHostReservationOfferingsPaginator",424 "DescribeHostReservationsPaginator",425 "DescribeHostsPaginator",426 "DescribeIamInstanceProfileAssociationsPaginator",427 "DescribeImportImageTasksPaginator",428 "DescribeImportSnapshotTasksPaginator",429 "DescribeInstanceCreditSpecificationsPaginator",430 "DescribeInstanceStatusPaginator",431 "DescribeInstanceTypeOfferingsPaginator",432 "DescribeInstanceTypesPaginator",433 "DescribeInstancesPaginator",434 "DescribeInternetGatewaysPaginator",435 "DescribeIpv6PoolsPaginator",436 "DescribeLaunchTemplateVersionsPaginator",437 "DescribeLaunchTemplatesPaginator",438 "DescribeLocalGatewayRouteTableVirtualInterfaceGroupAssociationsPaginator",439 "DescribeLocalGatewayRouteTableVpcAssociationsPaginator",440 "DescribeLocalGatewayRouteTablesPaginator",441 "DescribeLocalGatewayVirtualInterfaceGroupsPaginator",442 "DescribeLocalGatewayVirtualInterfacesPaginator",443 "DescribeLocalGatewaysPaginator",444 "DescribeManagedPrefixListsPaginator",445 "DescribeMovingAddressesPaginator",446 "DescribeNatGatewaysPaginator",447 "DescribeNetworkAclsPaginator",448 "DescribeNetworkInterfacePermissionsPaginator",449 "DescribeNetworkInterfacesPaginator",450 "DescribePrefixListsPaginator",451 "DescribePrincipalIdFormatPaginator",452 "DescribePublicIpv4PoolsPaginator",453 "DescribeReservedInstancesModificationsPaginator",454 "DescribeReservedInstancesOfferingsPaginator",455 "DescribeRouteTablesPaginator",456 "DescribeScheduledInstanceAvailabilityPaginator",457 "DescribeScheduledInstancesPaginator",458 "DescribeSecurityGroupsPaginator",459 "DescribeSnapshotsPaginator",460 "DescribeSpotFleetInstancesPaginator",461 "DescribeSpotFleetRequestsPaginator",462 "DescribeSpotInstanceRequestsPaginator",463 "DescribeSpotPriceHistoryPaginator",464 "DescribeStaleSecurityGroupsPaginator",465 "DescribeSubnetsPaginator",466 "DescribeTagsPaginator",467 "DescribeTrafficMirrorFiltersPaginator",468 "DescribeTrafficMirrorSessionsPaginator",469 "DescribeTrafficMirrorTargetsPaginator",470 "DescribeTransitGatewayAttachmentsPaginator",471 "DescribeTransitGatewayMulticastDomainsPaginator",472 "DescribeTransitGatewayPeeringAttachmentsPaginator",473 "DescribeTransitGatewayRouteTablesPaginator",474 "DescribeTransitGatewayVpcAttachmentsPaginator",475 "DescribeTransitGatewaysPaginator",476 "DescribeVolumeStatusPaginator",477 "DescribeVolumesModificationsPaginator",478 "DescribeVolumesPaginator",479 "DescribeVpcClassicLinkDnsSupportPaginator",480 "DescribeVpcEndpointConnectionNotificationsPaginator",481 "DescribeVpcEndpointConnectionsPaginator",482 "DescribeVpcEndpointServiceConfigurationsPaginator",483 "DescribeVpcEndpointServicePermissionsPaginator",484 "DescribeVpcEndpointServicesPaginator",485 "DescribeVpcEndpointsPaginator",486 "DescribeVpcPeeringConnectionsPaginator",487 "DescribeVpcsPaginator",488 "EC2Client",489 "EC2ServiceResource",490 "ExportTaskCancelledWaiter",491 "ExportTaskCompletedWaiter",492 "GetAssociatedIpv6PoolCidrsPaginator",493 "GetGroupsForCapacityReservationPaginator",494 "GetManagedPrefixListAssociationsPaginator",495 "GetManagedPrefixListEntriesPaginator",496 "GetTransitGatewayAttachmentPropagationsPaginator",497 "GetTransitGatewayMulticastDomainAssociationsPaginator",498 "GetTransitGatewayRouteTableAssociationsPaginator",499 "GetTransitGatewayRouteTablePropagationsPaginator",500 "ImageAvailableWaiter",501 "ImageExistsWaiter",502 "InstanceExistsWaiter",503 "InstanceRunningWaiter",504 "InstanceStatusOkWaiter",505 "InstanceStoppedWaiter",506 "InstanceTerminatedWaiter",507 "KeyPairExistsWaiter",508 "NatGatewayAvailableWaiter",509 "NetworkInterfaceAvailableWaiter",510 "PasswordDataAvailableWaiter",511 "SearchLocalGatewayRoutesPaginator",512 "SearchTransitGatewayMulticastGroupsPaginator",513 "SecurityGroupExistsWaiter",514 "ServiceResource",515 "SnapshotCompletedWaiter",516 "SpotInstanceRequestFulfilledWaiter",517 "SubnetAvailableWaiter",518 "SystemStatusOkWaiter",519 "VolumeAvailableWaiter",520 "VolumeDeletedWaiter",521 "VolumeInUseWaiter",522 "VpcAvailableWaiter",523 "VpcExistsWaiter",524 "VpcPeeringConnectionDeletedWaiter",525 "VpcPeeringConnectionExistsWaiter",526 "VpnConnectionAvailableWaiter",527 "VpnConnectionDeletedWaiter",...
2017-12-05-aws_machine.py
Source:2017-12-05-aws_machine.py
1# ------------------------------------------------------------------------ # 2# # 3# libraries # 4# # 5# ------------------------------------------------------------------------ # 6import sys7import boto38from botocore.exceptions import ClientError9# ------------------------------------------------------------------------ #10# # 11# constants # 12# # 13# ------------------------------------------------------------------------ # 14g_profile = 'us-east' # profiles: au | us-east | eu15g_instance_type = 'm4.large'16ami = 'ami-31ecfb26' # only in us-east-1, virginia17# Fixed constansts18g_name = 'fast-ai'19g_cidr = '0.0.0/0'20g_cidr_block = '10.0.0.0/28'21# --- Create22# ------------------------------------------------------------------------ # 23# # 24# Create VPC # 25# # 26# ------------------------------------------------------------------------ # 27def create_vpc(p_ec2_resource, p_ec2_client):28 """29 Create a Virtual Private Channel (VPC)30 Add a tag, even though I cannot see the tag later.... <sigh>31 Enable DNS32 Enable Hostname support33 Return the ID.34 """35 36 l_vpc_id = p_ec2_resource.create_vpc(CidrBlock=g_cidr_block)37 l_vpc_id.create_tags(Tags=[{"Key": "VPCName", "Value": g_name}])38 print('----------')39 print(l_vpc_id.id)40 # int(l_vpc_id['id'])41 print('----------')42 # ec2_client.modify_vpc_attribute(VpcId=l_vpc_id.id, EnableDnsSupport={'Value': True})43 # ec2_client.modify_vpc_attribute(VpcId=l_vpc_id.id, EnableDnsHostnames={'Value': True})44 45 print('Creating...please wait')46 l_vpc_id.wait_until_available()47 print('Complete')48 print(l_vpc_id)49 50 return l_vpc_id51 52# ------------------------------------------------------------------------ # 53# # 54# Create Internet Gateway # 55# # 56# ------------------------------------------------------------------------ # 57def create_gateway(p_ec2_resource, p_vpc_id):58 """59 Create an Internet Gateway60 Add a tag, still do not understand tags <bigger sigh>61 return ID62 """63 64 l_ig = p_ec2_resource.create_internet_gateway()65 print('my ig = {}'.format(l_ig))66 l_ig.attach_to_vpc(VpcId=p_vpc_id)67 return l_ig68 69# ec2_client.modify_vpc_attribute(VpcId=my_vpc['Vpc']['VpcId'], EnableDnsSupport={'Value':True})70# ec2_client.modify_vpc_attribute(VpcId=my_vpc['Vpc']['VpcId'], EnableDnsHostnames={'Value':True}) 71# Create an Internet Gateway72# export internetGatewayId=$(aws ec2 create-internet-gateway --query 'InternetGateway.InternetGatewayId' 73# --output text)74# aws ec2 create-tags --resources $internetGatewayId --tags --tags Key=Name,Value=$name-gateway75# aws ec2 attach-internet-gateway --internet-gateway-id $internetGatewayId --vpc-id $vpcId76 77# --- deletes 78# ------------------------------------------------------------------------ # 79# # 80# detach internet gateway # 81# # 82# ------------------------------------------------------------------------ # 83 84def detach_internet_gateway(p_ig, p_ig_id):85 """86 Detach the Internet Gateway from the VPC87 If it fails with Client Error of not attached, it should be OK88 verify error is 89 'ClientError: An error occurred (Gateway.NotAttached) when calling the 90 DetachInternetGateway operation: resource igw-8f4bc9f6 is not 91 attached to network igw-8f4bc9f6'92 """93 command_status = False94 95 try:96 l_response = p_ig.detach_from_vpc(VpcId = p_ig_id)97 98 print(l_response)99 command_status = True100 101 except ClientError as e:102 if e.response['Error']['Code'] == 'Gateway.NotAttached':103 # This error is ok.104 command_status = True105 106 return command_status107# ------------------------------------------------------------------------ # 108# # 109# delete internet gateway # 110# # 111# ------------------------------------------------------------------------ # 112 113def delete_internet_gateway(p_ig, p_ig_id):114 """115 delete the Internet Gateway from the VPC116 If it fails with Client Error, NOT OK117 verify error is 118 'ClientError: An error occurred (DependencyViolation) when calling 119 the DeleteInternetGateway operation: The internetGateway 'igw-8f4bc9f6' 120 has dependencies and cannot be deleted.121 """122 command_status = False123 124 try:125 l_response = p_ig.delete()126 print(l_response)127 command_status = True128 129 except ClientError as e:130 if e.response['Error']['Code'] == 'DependencyViolation':131 command_status = False132 # This error is NOT ok.133 print("Unable to delete internet gateway due to a dependency violation")134 print('error text: {}'.format(e))135 else:136 command_status = False 137 print('Unknown Error when deleting Internet Gateway {}'.format(e.response['Error']['Code']) )138 print('error text: {}'.format(e))139 140 return command_status 141# ------------------------------------------------------------------------ # 142# # 143# delete security group # 144# # 145# ------------------------------------------------------------------------ # 146 147def delete_security_group(p_sg, p_sg_id):148 """149 delete the security group from the VPC150 """151 command_status = False152 153 try:154 l_response = p_sg.delete()155 delete_result = l_response['ResponseMetadata']['HTTPStatusCode']156 if delete_result == 200:157 command_status = True158 else:159 print('ERROR: Failed to delete security for unknown reasons, error not raised')160 print(l_response)161 print('-----------------------------------------------------')162 command_status = False163 164 except ClientError as e:165 if e.response['Error']['Code'] == 'DependencyViolation':166 command_status = False167 # This error is NOT ok.168 print("Unable to delete security group due to a dependency violation")169 print('error text: {}'.format(e))170 else:171 command_status = False 172 print('Unknown Error when deleting Security Group {}'.format(e.response['Error']['Code']) )173 print('error text: {}'.format(e))174 175 return command_status 176# ------------------------------------------------------------------------ # 177# # 178# delete subnet # 179# # 180# ------------------------------------------------------------------------ # 181 182def delete_subnet(p_subnet, p_subnet_id):183 """184 delete the subnet from the VPC185 """186 command_status = False187 188 try:189 l_response = p_subnet.delete()190 delete_result = l_response['ResponseMetadata']['HTTPStatusCode']191 if delete_result == 200:192 command_status = True193 else:194 print('ERROR: Failed to delete subnet for unknown reasons, error not raised')195 print(l_response)196 print('-----------------------------------------------------')197 command_status = False198 199 except ClientError as e:200 if e.response['Error']['Code'] == 'DependencyViolation':201 command_status = False202 # This error is NOT ok.203 print("Unable to delete subnet due to a dependency violation")204 print('error text: {}'.format(e))205 else:206 command_status = False 207 print('Unknown Error when deleting subnet {}'.format(e.response['Error']['Code']) )208 print('error text: {}'.format(e))209 210 return command_status 211 212# --- remove components213# ------------------------------------------------------------------------ # 214# # 215# Remove vpc network acls # 216# # 217# ------------------------------------------------------------------------ # 218def remove_vpc_network_acls(p_ec2_resource, p_vpc_id, p_level): 219 """220 Remove all subnets for this vpc221 """222 p_level += 4223 224 overall_success = True225 overall_success = False226 227 228 for subnet in p_ec2_resource.meta.client.describe_network_acls()['SecurityGroups']:229 230 l_subnet_id = subnet['GroupId']231 l_vpc_owner_id = subnet['VpcId'] 232 l_subnet = p_ec2_resource.SecurityGroup(l_sg_id)233 234 if l_vpc_owner_id != p_vpc_id.id:235 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))236 continue237 238 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))239 if not delete_security_group(l_sg, l_sg_id):240 overall_success = False241 else:242 print('{} security group deleted'.format(' '*p_level)) 243 244 p_level -= 4245 return overall_success 246# ------------------------------------------------------------------------ # 247# # 248# Remove vpc vpn attachments # 249# # 250# ------------------------------------------------------------------------ # 251def remove_vpc_vpn_attachments(p_ec2_resource, p_vpc_id, p_level): 252 """253 Remove all subnets for this vpc254 """255 p_level += 4256 257 overall_success = True258 overall_success = False259 260 261 for subnet in p_ec2_resource.meta.client.describe_vpn_gateways()['SecurityGroups']:262 263 l_subnet_id = subnet['GroupId']264 l_vpc_owner_id = subnet['VpcId'] 265 l_subnet = p_ec2_resource.SecurityGroup(l_sg_id)266 267 if l_vpc_owner_id != p_vpc_id.id:268 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))269 continue270 271 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))272 if not delete_security_group(l_sg, l_sg_id):273 overall_success = False274 else:275 print('{} security group deleted'.format(' '*p_level)) 276 277 p_level -= 4278 return overall_success 279 280# ------------------------------------------------------------------------ # 281# # 282# Remove vpc route tables # 283# # 284# ------------------------------------------------------------------------ # 285 286def remove_vpc_route_tables(p_ec2_resource, p_vpc_id, p_level): 287 """288 Remove all subnets for this vpc289 """290 p_level += 4291 292 overall_success = True293 overall_success = False294 295 296 for subnet in p_ec2_resource.meta.client.describe_route_tables()['SecurityGroups']:297 298 l_subnet_id = subnet['GroupId']299 l_vpc_owner_id = subnet['VpcId'] 300 l_subnet = p_ec2_resource.SecurityGroup(l_sg_id)301 302 if l_vpc_owner_id != p_vpc_id.id:303 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))304 continue305 306 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))307 if not delete_security_group(l_sg, l_sg_id):308 overall_success = False309 else:310 print('{} security group deleted'.format(' '*p_level)) 311 312 p_level -= 4313 return overall_success 314 315# ------------------------------------------------------------------------ # 316# # 317# Remove vpc network interfaces # 318# # 319# ------------------------------------------------------------------------ # 320def remove_vpc_network_interfaces(p_ec2_resource, p_vpc_id, p_level): 321 """322 Remove all subnets for this vpc323 """324 p_level += 4325 326 overall_success = True327 overall_success = False328 329 330 for subnet in p_ec2_resource.meta.client.describe_network_interfaces()['SecurityGroups']:331 332 l_subnet_id = subnet['GroupId']333 l_vpc_owner_id = subnet['VpcId'] 334 l_subnet = p_ec2_resource.SecurityGroup(l_sg_id)335 336 if l_vpc_owner_id != p_vpc_id.id:337 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))338 continue339 340 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))341 if not delete_security_group(l_sg, l_sg_id):342 overall_success = False343 else:344 print('{} security group deleted'.format(' '*p_level)) 345 346 p_level -= 4347 return overall_success 348 349 350# ------------------------------------------------------------------------ # 351# # 352# Remove vpc peering connections # 353# # 354# ------------------------------------------------------------------------ # 355def remove_vpc_peering_connections(p_ec2_resource, p_vpc_id, p_level): 356 """357 Remove all subnets for this vpc358 """359 p_level += 4360 361 overall_success = True362 overall_success = False363 364 365 for subnet in p_ec2_resource.meta.client.describe_vpc_peering_connections()['SecurityGroups']:366 367 l_subnet_id = subnet['GroupId']368 l_vpc_owner_id = subnet['VpcId'] 369 l_subnet = p_ec2_resource.SecurityGroup(l_sg_id)370 371 if l_vpc_owner_id != p_vpc_id.id:372 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))373 continue374 375 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))376 if not delete_security_group(l_sg, l_sg_id):377 overall_success = False378 else:379 print('{} security group deleted'.format(' '*p_level)) 380 381 p_level -= 4382 return overall_success 383 384# ------------------------------------------------------------------------ # 385# # 386# Remove vpc vpn connections # 387# # 388# ------------------------------------------------------------------------ # 389 390def remove_vpc_vpn_connection(p_ec2_resource, p_vpc_id, p_level): 391 """392 Remove all subnets for this vpc393 """394 p_level += 4395 396 overall_success = True397 overall_success = False398 399 400 for vpn in p_ec2_resource.meta.client.describe_vpn_connections()['SecurityGroups']:401 402 l_subnet_id = subnet['GroupId']403 l_vpc_owner_id = subnet['VpcId'] 404 l_subnet = p_ec2_resource.SecurityGroup(l_sg_id)405 406 if l_vpc_owner_id != p_vpc_id.id:407 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))408 continue409 410 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))411 if not delete_security_group(l_sg, l_sg_id):412 overall_success = False413 else:414 print('{} security group deleted'.format(' '*p_level)) 415 416 p_level -= 4417 return overall_success 418 419# ------------------------------------------------------------------------ # 420# # 421# Remove vpc subnet # 422# # 423# ------------------------------------------------------------------------ # 424def remove_vpc_subnets(p_ec2_resource, p_vpc_id, p_level): 425 """426 Remove all subnets for this vpc427 """428 p_level += 4429 430 overall_success = True431 overall_success = False432 433 for subnet in p_ec2_resource.meta.client.describe_subnets()['Subnets']:434 l_vpc_owner_id = subnet['VpcId'] 435 l_subnet_id = subnet['SubnetId']436 l_subnet = p_ec2_resource.SecurityGroup(l_subnet_id)437 if l_vpc_owner_id != p_vpc_id.id:438 print('{} subnet VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_subnet_id, l_vpc_owner_id))439 continue440 441 442 print('{} subnet {}, owner VPC {}'.format(' '*p_level, l_subnet_id, l_vpc_owner_id))443 if not delete_subnet(l_subnet, l_subnet_id):444 overall_success = False445 else:446 print('{} subnet deleted'.format(' '*p_level)) 447 448 p_level -= 4449 return overall_success 450 451# ------------------------------------------------------------------------ # 452# # 453# Remove vpc security group # 454# # 455# ------------------------------------------------------------------------ # 456def remove_vpc_security_group(p_ec2_resource, p_vpc_id, p_level): 457 """458 Remove all security groups for this vpc459 """460 p_level += 4461 462 overall_success = True463 overall_success = False464 465 466 for sg in p_ec2_resource.meta.client.describe_security_groups()['SecurityGroups']:467 468 l_sg_id = sg['GroupId']469 l_vpc_owner_id = sg['VpcId'] 470 l_sg = p_ec2_resource.SecurityGroup(l_sg_id)471 472 if l_vpc_owner_id != p_vpc_id.id:473 print('{} Security Group VPC {}, owner VPC {} - skip, wrong VPC'.format(' '*p_level, l_sg_id, l_vpc_owner_id))474 continue475 476 print('{} Security Group {}, owner VPC {}'.format(' '*p_level, l_sg_id, l_vpc_owner_id))477 if not delete_security_group(l_sg, l_sg_id):478 overall_success = False479 else:480 print('{} security group deleted'.format(' '*p_level)) 481 482 p_level -= 4483 return overall_success 484# ------------------------------------------------------------------------ # 485# # 486# Remove Internet Gateway # 487# # 488# ------------------------------------------------------------------------ # 489def remove_vpc_internet_gateway(p_ec2_resource, p_vpc_id, p_level): 490 """491 Remove all Internet Gateways...492 dunno about the default, is there one?493 Bugger it, just remove em all....494 """495 496 p_level += 4497 498 overall_success = True499 500 for ig in p_ec2_resource.meta.client.describe_internet_gateways()['InternetGateways']:501 502 l_ig_id = ig['InternetGatewayId']503 504 # This gateway can be attached to multiple VPC505 # Loop through each attachment, and see if attached to this VPC at all.506 is_attached_to_vpc = False 507 is_attached_count = 0508 509 for att in ig['Attachments']:510 is_attached_count += 1511 l_vpc_owner_id = att['VpcId']512 if l_vpc_owner_id != p_vpc_id.id:513 is_attached_to_vpc = True514 515 if not is_attached_to_vpc:516 print('{} internet gateway not attached to this VPC - skip'.format(' '*p_level))517 continue518 519 l_ig = p_ec2_resource.InternetGateway(l_ig_id)520 print('{} Process removal internet gateway : {}'.format(' ' * p_level, l_ig_id))521 p_level += 4522 if not detach_internet_gateway(l_ig, l_ig_id):523 print('{} internet gateway failed to detach '.format(' '*p_level)) 524 overall_success = False525 else:526 print('{} internet gateway detached'.format(' '*p_level)) 527 is_attached_count -= 1528 529 # Test to see if attached to any other VPC, if not, then delete.530 if is_attached_count == 0: 531 if not delete_internet_gateway(l_ig, l_ig_id):532 print('{} internet gateway failed to delete '.format(' '*p_level)) 533 overall_success = False534 else:535 print('{} internet gateway deleted'.format(' '*p_level)) 536 537 p_level -= 4538 539 p_level -= 4540 return overall_success 541 542# --- remove VPC543# ------------------------------------------------------------------------ # 544# # 545# Remove VPC # 546# # 547# ------------------------------------------------------------------------ # 548def remove_all_vpc(p_ec2_resource):549 """550 Remove all VPC551 except for default552 553 This will start failing where there are dependencies....will have to fix that later!554 """555 level = 0556 print('Start process - Remove all VPC except default')557 for r in p_ec2_resource.meta.client.describe_vpcs()[ 'Vpcs']:558 level += 4559 560 l_vpc_default = r['IsDefault']561 l_vpc_id = r['VpcId']562 563 vpc_ready_for_delete = True564 565 if l_vpc_default:566 print(' vpc id {}: is default, not removing'.format(l_vpc_id))567 else:568 print(' vpc id {}: prepare for delete'.format(l_vpc_id))569 570 l_vpc = p_ec2_resource.Vpc(id = l_vpc_id)571 if l_vpc.tags is not None:572 for tag in l_vpc.tags:573 print('{} vpc tags: : {} {}'.format(' '*level * 2, tag['Key'], tag['Value']))574 575 if not remove_vpc_security_group(p_ec2_resource, l_vpc, level):576 vpc_ready_for_delete = False577 578 if not remove_vpc_subnets(p_ec2_resource, l_vpc, level):579 vpc_ready_for_delete = False580 581 if not remove_vpc_network_acls(p_ec2_resource, l_vpc, level):582 vpc_ready_for_delete = False583 584# =============================================================================585# if not remove_vpc_vpn_attachments(p_ec2_resource, l_vpc, level):586# vpc_ready_for_delete = False587# 588# if not remove_vpc_route_tables(p_ec2_resource, l_vpc, level):589# vpc_ready_for_delete = False590# 591# if not remove_vpc_network_interfaces(p_ec2_resource, l_vpc, level):592# vpc_ready_for_delete = False593# 594# if not remove_vpc_vpc_peering_connections(p_ec2_resource, l_vpc, level):595# vpc_ready_for_delete = False596# 597# if not remove_vpc_vpn_connection(p_ec2_resource, l_vpc, level):598# vpc_ready_for_delete = False599# 600# if not remove_vpc_internet_gateway(p_ec2_resource, l_vpc, level):601# vpc_ready_for_delete = False602# =============================================================================603 if vpc_ready_for_delete:604 l_vpc.delete()605 else:606 print('{} VPC not ready for delete...bugger'.format(' '*level))607 608# =============================================================================609# 610# Possible dependencies611# ---------------------612# DONE Security Group613# DONE Internet Gateways614#615# Subnets616# Network ACLs617# VPN Attachments618# Route Tables619# Network Interfaces620# VPC Peering Connections621# vpn-connection. 622# 623# =============================================================================624# =============================================================================625# dir(p_ec2_resource.meta.client)626# 627# u'describe_subnets',628# 629# u'describe_network_acls',630#631# u'describe_vpn_gateways', 632#633# u'describe_route_tables',634#635# u'describe_network_interfaces',636#637# u'describe_vpc_peering_connections',638#639# u'describe_vpn_connections',640# --------------------------------- 641# u'describe_account_attributes',642# u'describe_addresses',643# u'describe_availability_zones',644# u'describe_bundle_tasks',645# u'describe_classic_link_instances',646# u'describe_conversion_tasks',647# u'describe_customer_gateways',648# u'describe_dhcp_options',649# u'describe_egress_only_internet_gateways',650# u'describe_export_tasks',651# u'describe_flow_logs',652# u'describe_fpga_images',653# u'describe_host_reservation_offerings',654# u'describe_host_reservations',655# u'describe_hosts',656# u'describe_iam_instance_profile_associations',657# u'describe_id_format',658# u'describe_identity_id_format',659# u'describe_image_attribute',660# u'describe_images',661# u'describe_import_image_tasks',662# u'describe_import_snapshot_tasks',663# u'describe_instance_attribute',664# u'describe_instance_status',665# u'describe_instances',666# u'describe_internet_gateways',667# u'describe_key_pairs',668# u'describe_moving_addresses',669# u'describe_nat_gateways',670# u'describe_network_interface_attribute',671# u'describe_network_interface_permissions',672# u'describe_placement_groups',673# u'describe_prefix_lists',674# u'describe_regions',675# u'describe_reserved_instances',676# u'describe_reserved_instances_listings',677# u'describe_reserved_instances_modifications',678# u'describe_reserved_instances_offerings',679# u'describe_scheduled_instance_availability',680# u'describe_scheduled_instances',681# u'describe_security_group_references',682# u'describe_security_groups',683# u'describe_snapshot_attribute',684# u'describe_snapshots',685# u'describe_spot_datafeed_subscription',686# u'describe_spot_fleet_instances',687# u'describe_spot_fleet_request_history',688# u'describe_spot_fleet_requests',689# u'describe_spot_instance_requests',690# u'describe_spot_price_history',691# u'describe_stale_security_groups',692# u'describe_tags',693# u'describe_volume_attribute',694# u'describe_volume_status',695# u'describe_volumes',696# u'describe_volumes_modifications',697# u'describe_vpc_attribute',698# u'describe_vpc_classic_link',699# u'describe_vpc_classic_link_dns_support',700# u'describe_vpc_endpoint_services',701# u'describe_vpc_endpoints',702# u'describe_vpcs',703# 704# =============================================================================705# --- main 706# ------------------------------------------------------------------------ # 707# # 708# main # 709# # 710# ------------------------------------------------------------------------ # 711def main():712 713 l_session = boto3.Session(profile_name = g_profile)714 l_region = l_session.region_name715 716 print('Configuration')717 print('-------------')718 print(' Current region: {}'.format(l_region))719 print('\n')720 721 ec2_resource = l_session.resource('ec2') 722 ec2_client = l_session.client('ec2') # lowest level723 724 remove_all_vpc(ec2_resource)725 726 # my_vpc_id = create_vpc(ec2_resource, ec2_client)727 # print('My VPC ID: {}, type = {}'.format(my_vpc_id.id, type(my_vpc_id.id)))728 729 730 # my_gateway_id = create_gateway(ec2_resource, my_vpc_id.id)731 # print('My Internet Gateway ID: {}'.format(my_gateway_id))732 733 734 # for r in ec2_resource.meta.client.describe_vpcs()[ 'Vpcs']:735 # l_vpc_id = r['VpcId']736 # for s in r.meta.client.describe_internet_gateways()['InternetGateways']:737 # print(s) 738# ------------------------------------------------------------------------ # 739# # 740# begin # 741# # 742# ------------------------------------------------------------------------ # 743 744if __name__ == "__main__":745 main() ...
ec2_fixtures.py
Source:ec2_fixtures.py
1import boto32import pytest3from moto import mock_ec24from tests.utils import random_str5@pytest.fixture6def gen_ec2_client(aws_setup):7 with mock_ec2():8 yield boto3.client("ec2")9@pytest.fixture10def gen_ec2_resource(aws_setup):11 with mock_ec2():12 yield boto3.resource("ec2")13# ============================14# WAITER15# ============================16@pytest.fixture17def gen_instance_exists_waiter(gen_ec2_client):18 return gen_ec2_client.get_waiter("instance_exists")19@pytest.fixture20def gen_bundle_task_complete_waiter(gen_ec2_client):21 return gen_ec2_client.get_waiter("bundle_task_complete")22@pytest.fixture23def gen_conversion_task_cancelled_waiter(gen_ec2_client):24 return gen_ec2_client.get_waiter("conversion_task_cancelled")25@pytest.fixture26def gen_conversion_task_completed_waiter(gen_ec2_client):27 return gen_ec2_client.get_waiter("conversion_task_completed")28@pytest.fixture29def gen_conversion_task_deleted_waiter(gen_ec2_client):30 return gen_ec2_client.get_waiter("conversion_task_deleted")31@pytest.fixture32def gen_customer_gateway_available_waiter(gen_ec2_client):33 return gen_ec2_client.get_waiter("customer_gateway_available")34@pytest.fixture35def gen_export_task_cancelled_waiter(gen_ec2_client):36 return gen_ec2_client.get_waiter("export_task_cancelled")37@pytest.fixture38def gen_export_task_completed_waiter(gen_ec2_client):39 return gen_ec2_client.get_waiter("export_task_completed")40@pytest.fixture41def gen_image_exists_waiter(gen_ec2_client):42 return gen_ec2_client.get_waiter("image_exists")43@pytest.fixture44def gen_image_available_waiter(gen_ec2_client):45 return gen_ec2_client.get_waiter("image_available")46@pytest.fixture47def gen_instance_running_waiter(gen_ec2_client):48 return gen_ec2_client.get_waiter("instance_running")49@pytest.fixture50def gen_instance_status_ok_waiter(gen_ec2_client):51 return gen_ec2_client.get_waiter("instance_status_ok")52@pytest.fixture53def gen_instance_stopped_waiter(gen_ec2_client):54 return gen_ec2_client.get_waiter("instance_stopped")55@pytest.fixture56def gen_instance_terminated_waiter(gen_ec2_client):57 return gen_ec2_client.get_waiter("instance_terminated")58@pytest.fixture59def gen_key_pair_exists_waiter(gen_ec2_client):60 return gen_ec2_client.get_waiter("key_pair_exists")61@pytest.fixture62def gen_nat_gateway_available_waiter(gen_ec2_client):63 return gen_ec2_client.get_waiter("nat_gateway_available")64@pytest.fixture65def gen_network_interface_available_waiter(gen_ec2_client):66 return gen_ec2_client.get_waiter("network_interface_available")67@pytest.fixture68def gen_password_data_available_waiter(gen_ec2_client):69 return gen_ec2_client.get_waiter("password_data_available")70@pytest.fixture71def gen_snapshot_completed_waiter(gen_ec2_client):72 return gen_ec2_client.get_waiter("snapshot_completed")73@pytest.fixture74def gen_security_group_exists_waiter(gen_ec2_client):75 return gen_ec2_client.get_waiter("security_group_exists")76@pytest.fixture77def gen_spot_instance_request_fulfilled_waiter(gen_ec2_client):78 return gen_ec2_client.get_waiter("spot_instance_request_fulfilled")79@pytest.fixture80def gen_subnet_available_waiter(gen_ec2_client):81 return gen_ec2_client.get_waiter("subnet_available")82@pytest.fixture83def gen_system_status_ok_waiter(gen_ec2_client):84 return gen_ec2_client.get_waiter("system_status_ok")85@pytest.fixture86def gen_volume_available_waiter(gen_ec2_client):87 return gen_ec2_client.get_waiter("volume_available")88@pytest.fixture89def gen_volume_deleted_waiter(gen_ec2_client):90 return gen_ec2_client.get_waiter("volume_deleted")91@pytest.fixture92def gen_volume_in_use_waiter(gen_ec2_client):93 return gen_ec2_client.get_waiter("volume_in_use")94@pytest.fixture95def gen_vpc_available_waiter(gen_ec2_client):96 return gen_ec2_client.get_waiter("vpc_available")97@pytest.fixture98def gen_vpc_exists_waiter(gen_ec2_client):99 return gen_ec2_client.get_waiter("vpc_exists")100@pytest.fixture101def gen_vpn_connection_available_waiter(gen_ec2_client):102 return gen_ec2_client.get_waiter("vpn_connection_available")103@pytest.fixture104def gen_vpn_connection_deleted_waiter(gen_ec2_client):105 return gen_ec2_client.get_waiter("vpn_connection_deleted")106@pytest.fixture107def gen_vpc_peering_connection_exists_waiter(gen_ec2_client):108 return gen_ec2_client.get_waiter("vpc_peering_connection_exists")109@pytest.fixture110def gen_vpc_peering_connection_deleted_waiter(gen_ec2_client):111 return gen_ec2_client.get_waiter("vpc_peering_connection_deleted")112# ============================113# PAGINATOR114# ============================115@pytest.fixture116def gen_describe_route_tables_paginator(gen_ec2_client):117 return gen_ec2_client.get_paginator("describe_route_tables")118@pytest.fixture119def gen_describe_iam_instance_profile_associations_paginator(gen_ec2_client):120 return gen_ec2_client.get_paginator("describe_iam_instance_profile_associations")121@pytest.fixture122def gen_describe_instance_status_paginator(gen_ec2_client):123 return gen_ec2_client.get_paginator("describe_instance_status")124@pytest.fixture125def gen_describe_instances_paginator(gen_ec2_client):126 return gen_ec2_client.get_paginator("describe_instances")127@pytest.fixture128def gen_describe_reserved_instances_offerings_paginator(gen_ec2_client):129 return gen_ec2_client.get_paginator("describe_reserved_instances_offerings")130@pytest.fixture131def gen_describe_reserved_instances_modifications_paginator(gen_ec2_client):132 return gen_ec2_client.get_paginator("describe_reserved_instances_modifications")133@pytest.fixture134def gen_describe_security_groups_paginator(gen_ec2_client):135 return gen_ec2_client.get_paginator("describe_security_groups")136@pytest.fixture137def gen_describe_snapshots_paginator(gen_ec2_client):138 return gen_ec2_client.get_paginator("describe_snapshots")139@pytest.fixture140def gen_describe_spot_fleet_instances_paginator(gen_ec2_client):141 return gen_ec2_client.get_paginator("describe_spot_fleet_instances")142@pytest.fixture143def gen_describe_spot_fleet_requests_paginator(gen_ec2_client):144 return gen_ec2_client.get_paginator("describe_spot_fleet_requests")145@pytest.fixture146def gen_describe_spot_price_history_paginator(gen_ec2_client):147 return gen_ec2_client.get_paginator("describe_spot_price_history")148@pytest.fixture149def gen_describe_tags_paginator(gen_ec2_client):150 return gen_ec2_client.get_paginator("describe_tags")151@pytest.fixture152def gen_describe_volume_status_paginator(gen_ec2_client):153 return gen_ec2_client.get_paginator("describe_volume_status")154@pytest.fixture155def gen_describe_volumes_paginator(gen_ec2_client):156 return gen_ec2_client.get_paginator("describe_volumes")157@pytest.fixture158def gen_describe_nat_gateways_paginator(gen_ec2_client):159 return gen_ec2_client.get_paginator("describe_nat_gateways")160@pytest.fixture161def gen_describe_network_interfaces_paginator(gen_ec2_client):162 return gen_ec2_client.get_paginator("describe_network_interfaces")163@pytest.fixture164def gen_describe_vpc_endpoints_paginator(gen_ec2_client):165 return gen_ec2_client.get_paginator("describe_vpc_endpoints")166@pytest.fixture167def gen_describe_vpc_endpoint_services_paginator(gen_ec2_client):168 return gen_ec2_client.get_paginator("describe_vpc_endpoint_services")169@pytest.fixture170def gen_describe_vpc_endpoint_connections_paginator(gen_ec2_client):171 return gen_ec2_client.get_paginator("describe_vpc_endpoint_connections")172@pytest.fixture173def gen_describe_byoip_cidrs_paginator(gen_ec2_client):174 return gen_ec2_client.get_paginator("describe_byoip_cidrs")175@pytest.fixture176def gen_describe_capacity_reservations_paginator(gen_ec2_client):177 return gen_ec2_client.get_paginator("describe_capacity_reservations")178@pytest.fixture179def gen_describe_classic_link_instances_paginator(gen_ec2_client):180 return gen_ec2_client.get_paginator("describe_classic_link_instances")181@pytest.fixture182def gen_describe_client_vpn_authorization_rules_paginator(gen_ec2_client):183 return gen_ec2_client.get_paginator("describe_client_vpn_authorization_rules")184@pytest.fixture185def gen_describe_client_vpn_connections_paginator(gen_ec2_client):186 return gen_ec2_client.get_paginator("describe_client_vpn_connections")187@pytest.fixture188def gen_describe_client_vpn_endpoints_paginator(gen_ec2_client):189 return gen_ec2_client.get_paginator("describe_client_vpn_endpoints")190@pytest.fixture191def gen_describe_client_vpn_routes_paginator(gen_ec2_client):192 return gen_ec2_client.get_paginator("describe_client_vpn_routes")193@pytest.fixture194def gen_describe_client_vpn_target_networks_paginator(gen_ec2_client):195 return gen_ec2_client.get_paginator("describe_client_vpn_target_networks")196@pytest.fixture197def gen_describe_egress_only_internet_gateways_paginator(gen_ec2_client):198 return gen_ec2_client.get_paginator("describe_egress_only_internet_gateways")199@pytest.fixture200def gen_describe_fleets_paginator(gen_ec2_client):201 return gen_ec2_client.get_paginator("describe_fleets")202@pytest.fixture203def gen_describe_flow_logs_paginator(gen_ec2_client):204 return gen_ec2_client.get_paginator("describe_flow_logs")205@pytest.fixture206def gen_describe_fpga_images_paginator(gen_ec2_client):207 return gen_ec2_client.get_paginator("describe_fpga_images")208@pytest.fixture209def gen_describe_host_reservation_offerings_paginator(gen_ec2_client):210 return gen_ec2_client.get_paginator("describe_host_reservation_offerings")211@pytest.fixture212def gen_describe_host_reservations_paginator(gen_ec2_client):213 return gen_ec2_client.get_paginator("describe_host_reservations")214@pytest.fixture215def gen_describe_hosts_paginator(gen_ec2_client):216 return gen_ec2_client.get_paginator("describe_hosts")217@pytest.fixture218def gen_describe_import_image_tasks_paginator(gen_ec2_client):219 return gen_ec2_client.get_paginator("describe_import_image_tasks")220@pytest.fixture221def gen_describe_import_snapshot_tasks_paginator(gen_ec2_client):222 return gen_ec2_client.get_paginator("describe_import_snapshot_tasks")223@pytest.fixture224def gen_describe_instance_credit_specifications_paginator(gen_ec2_client):225 return gen_ec2_client.get_paginator("describe_instance_credit_specifications")226@pytest.fixture227def gen_describe_launch_template_versions_paginator(gen_ec2_client):228 return gen_ec2_client.get_paginator("describe_launch_template_versions")229@pytest.fixture230def gen_describe_launch_templates_paginator(gen_ec2_client):231 return gen_ec2_client.get_paginator("describe_launch_templates")232@pytest.fixture233def gen_describe_moving_addresses_paginator(gen_ec2_client):234 return gen_ec2_client.get_paginator("describe_moving_addresses")235@pytest.fixture236def gen_describe_network_interface_permissions_paginator(gen_ec2_client):237 return gen_ec2_client.get_paginator("describe_network_interface_permissions")238@pytest.fixture239def gen_describe_prefix_lists_paginator(gen_ec2_client):240 return gen_ec2_client.get_paginator("describe_prefix_lists")241@pytest.fixture242def gen_describe_principal_id_format_paginator(gen_ec2_client):243 return gen_ec2_client.get_paginator("describe_principal_id_format")244@pytest.fixture245def gen_describe_public_ipv4_pools_paginator(gen_ec2_client):246 return gen_ec2_client.get_paginator("describe_public_ipv4_pools")247@pytest.fixture248def gen_describe_scheduled_instance_availability_paginator(gen_ec2_client):249 return gen_ec2_client.get_paginator("describe_scheduled_instance_availability")250@pytest.fixture251def gen_describe_scheduled_instances_paginator(gen_ec2_client):252 return gen_ec2_client.get_paginator("describe_scheduled_instances")253@pytest.fixture254def gen_describe_stale_security_groups_paginator(gen_ec2_client):255 return gen_ec2_client.get_paginator("describe_stale_security_groups")256@pytest.fixture257def gen_describe_transit_gateway_attachments_paginator(gen_ec2_client):258 return gen_ec2_client.get_paginator("describe_transit_gateway_attachments")259@pytest.fixture260def gen_describe_transit_gateway_route_tables_paginator(gen_ec2_client):261 return gen_ec2_client.get_paginator("describe_transit_gateway_route_tables")262@pytest.fixture263def gen_describe_transit_gateway_vpc_attachments_paginator(gen_ec2_client):264 return gen_ec2_client.get_paginator("describe_transit_gateway_vpc_attachments")265@pytest.fixture266def gen_describe_transit_gateways_paginator(gen_ec2_client):267 return gen_ec2_client.get_paginator("describe_transit_gateways")268@pytest.fixture269def gen_describe_volumes_modifications_paginator(gen_ec2_client):270 return gen_ec2_client.get_paginator("describe_volumes_modifications")271@pytest.fixture272def gen_describe_vpc_classic_link_dns_support_paginator(gen_ec2_client):273 return gen_ec2_client.get_paginator("describe_vpc_classic_link_dns_support")274@pytest.fixture275def gen_describe_vpc_endpoint_connection_notifications_paginator(gen_ec2_client):276 return gen_ec2_client.get_paginator(277 "describe_vpc_endpoint_connection_notifications"278 )279@pytest.fixture280def gen_describe_vpc_endpoint_service_configurations_paginator(gen_ec2_client):281 return gen_ec2_client.get_paginator("describe_vpc_endpoint_service_configurations")282@pytest.fixture283def gen_describe_vpc_endpoint_service_permissions_paginator(gen_ec2_client):284 return gen_ec2_client.get_paginator("describe_vpc_endpoint_service_permissions")285@pytest.fixture286def gen_describe_vpc_peering_connections_paginator(gen_ec2_client):287 return gen_ec2_client.get_paginator("describe_vpc_peering_connections")288@pytest.fixture289def gen_get_transit_gateway_attachment_propagations_paginator(gen_ec2_client):290 return gen_ec2_client.get_paginator("get_transit_gateway_attachment_propagations")291@pytest.fixture292def gen_get_transit_gateway_route_table_associations_paginator(gen_ec2_client):293 return gen_ec2_client.get_paginator("get_transit_gateway_route_table_associations")294@pytest.fixture295def gen_get_transit_gateway_route_table_propagations_paginator(gen_ec2_client):296 return gen_ec2_client.get_paginator("get_transit_gateway_route_table_propagations")297@pytest.fixture298def gen_describe_internet_gateways_paginator(gen_ec2_client):299 return gen_ec2_client.get_paginator("describe_internet_gateways")300@pytest.fixture301def gen_describe_network_acls_paginator(gen_ec2_client):302 return gen_ec2_client.get_paginator("describe_network_acls")303@pytest.fixture304def gen_describe_vpcs_paginator(gen_ec2_client):305 return gen_ec2_client.get_paginator("describe_vpcs")306@pytest.fixture307def gen_describe_spot_instance_requests_paginator(gen_ec2_client):308 return gen_ec2_client.get_paginator("describe_spot_instance_requests")309@pytest.fixture310def gen_describe_dhcp_options_paginator(gen_ec2_client):311 return gen_ec2_client.get_paginator("describe_dhcp_options")312@pytest.fixture313def gen_describe_subnets_paginator(gen_ec2_client):314 return gen_ec2_client.get_paginator("describe_subnets")315@pytest.fixture316def gen_describe_traffic_mirror_filters_paginator(gen_ec2_client):317 return gen_ec2_client.get_paginator("describe_traffic_mirror_filters")318@pytest.fixture319def gen_describe_traffic_mirror_sessions_paginator(gen_ec2_client):320 return gen_ec2_client.get_paginator("describe_traffic_mirror_sessions")321@pytest.fixture322def gen_describe_traffic_mirror_targets_paginator(gen_ec2_client):323 return gen_ec2_client.get_paginator("describe_traffic_mirror_targets")324@pytest.fixture325def gen_describe_export_image_tasks_paginator(gen_ec2_client):326 return gen_ec2_client.get_paginator("describe_export_image_tasks")327@pytest.fixture328def gen_describe_fast_snapshot_restores_paginator(gen_ec2_client):329 return gen_ec2_client.get_paginator("describe_fast_snapshot_restores")330@pytest.fixture331def gen_describe_ipv6_pools_paginator(gen_ec2_client):332 return gen_ec2_client.get_paginator("describe_ipv6_pools")333@pytest.fixture334def gen_get_associated_ipv6_pool_cidrs_paginator(gen_ec2_client):335 return gen_ec2_client.get_paginator("get_associated_ipv6_pool_cidrs")336@pytest.fixture337def gen_describe_coip_pools_paginator(gen_ec2_client):338 return gen_ec2_client.get_paginator("describe_coip_pools")339@pytest.fixture340def gen_describe_instance_type_offerings_paginator(gen_ec2_client):341 return gen_ec2_client.get_paginator("describe_instance_type_offerings")342@pytest.fixture343def gen_describe_instance_types_paginator(gen_ec2_client):344 return gen_ec2_client.get_paginator("describe_instance_types")345@pytest.fixture346def gen_describe_local_gateway_route_table_virtual_interface_group_associations_paginator(347 gen_ec2_client,348):349 return gen_ec2_client.get_paginator(350 "describe_local_gateway_route_table_virtual_interface_group_associations"351 )352@pytest.fixture353def gen_describe_local_gateway_route_table_vpc_associations_paginator(gen_ec2_client):354 return gen_ec2_client.get_paginator(355 "describe_local_gateway_route_table_vpc_associations"356 )357@pytest.fixture358def gen_describe_local_gateway_route_tables_paginator(gen_ec2_client):359 return gen_ec2_client.get_paginator("describe_local_gateway_route_tables")360@pytest.fixture361def gen_describe_local_gateway_virtual_interface_groups_paginator(gen_ec2_client):362 return gen_ec2_client.get_paginator(363 "describe_local_gateway_virtual_interface_groups"364 )365@pytest.fixture366def gen_describe_local_gateway_virtual_interfaces_paginator(gen_ec2_client):367 return gen_ec2_client.get_paginator("describe_local_gateway_virtual_interfaces")368@pytest.fixture369def gen_describe_local_gateways_paginator(gen_ec2_client):370 return gen_ec2_client.get_paginator("describe_local_gateways")371@pytest.fixture372def gen_describe_transit_gateway_multicast_domains_paginator(gen_ec2_client):373 return gen_ec2_client.get_paginator("describe_transit_gateway_multicast_domains")374@pytest.fixture375def gen_describe_transit_gateway_peering_attachments_paginator(gen_ec2_client):376 return gen_ec2_client.get_paginator("describe_transit_gateway_peering_attachments")377@pytest.fixture378def gen_get_transit_gateway_multicast_domain_associations_paginator(gen_ec2_client):379 return gen_ec2_client.get_paginator(380 "get_transit_gateway_multicast_domain_associations"381 )382@pytest.fixture383def gen_search_local_gateway_routes_paginator(gen_ec2_client):384 return gen_ec2_client.get_paginator("search_local_gateway_routes")385@pytest.fixture386def gen_search_transit_gateway_multicast_groups_paginator(gen_ec2_client):387 return gen_ec2_client.get_paginator("search_transit_gateway_multicast_groups")388@pytest.fixture389def gen_describe_managed_prefix_lists_paginator(gen_ec2_client):390 return gen_ec2_client.get_paginator("describe_managed_prefix_lists")391@pytest.fixture392def gen_get_managed_prefix_list_associations_paginator(gen_ec2_client):393 return gen_ec2_client.get_paginator("get_managed_prefix_list_associations")394@pytest.fixture395def gen_get_managed_prefix_list_entries_paginator(gen_ec2_client):396 return gen_ec2_client.get_paginator("get_managed_prefix_list_entries")397@pytest.fixture398def gen_get_groups_for_capacity_reservation_paginator(gen_ec2_client):399 return gen_ec2_client.get_paginator("get_groups_for_capacity_reservation")400@pytest.fixture401def gen_describe_carrier_gateways_paginator(gen_ec2_client):402 return gen_ec2_client.get_paginator("describe_carrier_gateways")403@pytest.fixture404def gen_get_transit_gateway_prefix_list_references_paginator(gen_ec2_client):405 return gen_ec2_client.get_paginator("get_transit_gateway_prefix_list_references")406@pytest.fixture407def gen_describe_network_insights_analyses_paginator(gen_ec2_client):408 return gen_ec2_client.get_paginator("describe_network_insights_analyses")409@pytest.fixture410def gen_describe_network_insights_paths_paginator(gen_ec2_client):411 return gen_ec2_client.get_paginator("describe_network_insights_paths")412@pytest.fixture413def gen_describe_transit_gateway_connect_peers_paginator(gen_ec2_client):414 return gen_ec2_client.get_paginator("describe_transit_gateway_connect_peers")415@pytest.fixture416def gen_describe_transit_gateway_connects_paginator(gen_ec2_client):417 return gen_ec2_client.get_paginator("describe_transit_gateway_connects")418@pytest.fixture419def gen_describe_addresses_attribute_paginator(gen_ec2_client):420 return gen_ec2_client.get_paginator("describe_addresses_attribute")421@pytest.fixture422def gen_describe_replace_root_volume_tasks_paginator(gen_ec2_client):423 return gen_ec2_client.get_paginator("describe_replace_root_volume_tasks")424@pytest.fixture425def gen_describe_store_image_tasks_paginator(gen_ec2_client):426 return gen_ec2_client.get_paginator("describe_store_image_tasks")427@pytest.fixture428def gen_describe_security_group_rules_paginator(gen_ec2_client):429 return gen_ec2_client.get_paginator("describe_security_group_rules")430@pytest.fixture431def gen_describe_instance_event_windows_paginator(gen_ec2_client):432 return gen_ec2_client.get_paginator("describe_instance_event_windows")433@pytest.fixture434def gen_describe_trunk_interface_associations_paginator(gen_ec2_client):435 return gen_ec2_client.get_paginator("describe_trunk_interface_associations")436@pytest.fixture437def gen_get_vpn_connection_device_types_paginator(gen_ec2_client):438 return gen_ec2_client.get_paginator("get_vpn_connection_device_types")439@pytest.fixture440def gen_describe_capacity_reservation_fleets_paginator(gen_ec2_client):441 return gen_ec2_client.get_paginator("describe_capacity_reservation_fleets")442@pytest.fixture443def gen_get_instance_types_from_instance_requirements_paginator(gen_ec2_client):444 return gen_ec2_client.get_paginator("get_instance_types_from_instance_requirements")445@pytest.fixture446def gen_get_spot_placement_scores_paginator(gen_ec2_client):447 return gen_ec2_client.get_paginator("get_spot_placement_scores")448# ============================449# RESOURCES450# ============================451@pytest.fixture452def gen_classic_address(gen_ec2_resource):453 return gen_ec2_resource.ClassicAddress(random_str())454@pytest.fixture455def gen_dhcp_options(gen_ec2_resource):456 return gen_ec2_resource.DhcpOptions(random_str())457@pytest.fixture458def gen_image(gen_ec2_resource):459 return gen_ec2_resource.Image(random_str())460@pytest.fixture461def gen_instance(gen_ec2_resource):462 return gen_ec2_resource.Instance(random_str())463@pytest.fixture464def gen_internet_gateway(gen_ec2_resource):465 return gen_ec2_resource.InternetGateway(random_str())466@pytest.fixture467def gen_key_pair(gen_ec2_resource):468 return gen_ec2_resource.KeyPair(random_str())469@pytest.fixture470def gen_network_acl(gen_ec2_resource):471 return gen_ec2_resource.NetworkAcl(random_str())472@pytest.fixture473def gen_network_interface(gen_ec2_resource):474 return gen_ec2_resource.NetworkInterface(random_str())475@pytest.fixture476def gen_network_interface_association(gen_ec2_resource):477 return gen_ec2_resource.NetworkInterfaceAssociation(random_str())478@pytest.fixture479def gen_placement_group(gen_ec2_resource):480 return gen_ec2_resource.PlacementGroup(random_str())481@pytest.fixture482def gen_route(gen_ec2_resource):483 return gen_ec2_resource.Route(random_str(), random_str())484@pytest.fixture485def gen_route_table(gen_ec2_resource):486 return gen_ec2_resource.RouteTable(random_str())487@pytest.fixture488def gen_route_table_association(gen_ec2_resource):489 return gen_ec2_resource.RouteTableAssociation(random_str())490@pytest.fixture491def gen_security_group(gen_ec2_resource):492 return gen_ec2_resource.SecurityGroup(random_str())493@pytest.fixture494def gen_snapshot(gen_ec2_resource):495 return gen_ec2_resource.Snapshot(random_str())496@pytest.fixture497def gen_subnet(gen_ec2_resource):498 return gen_ec2_resource.Subnet(random_str())499@pytest.fixture500def gen_tag(gen_ec2_resource):501 return gen_ec2_resource.Tag(random_str(), random_str(), random_str())502@pytest.fixture503def gen_volume(gen_ec2_resource):504 return gen_ec2_resource.Volume(random_str())505@pytest.fixture506def gen_vpc(gen_ec2_resource):507 return gen_ec2_resource.Vpc(random_str())508@pytest.fixture509def gen_vpc_peering_connection(gen_ec2_resource):510 return gen_ec2_resource.VpcPeeringConnection(random_str())511@pytest.fixture512def gen_vpc_address(gen_ec2_resource):513 return gen_ec2_resource.VpcAddress(random_str())514# ============================515# COLLECTIONS516# ============================517@pytest.fixture518def gen_service_resource_classic_addresses_collection(gen_ec2_resource):519 return gen_ec2_resource.classic_addresses.all()520@pytest.fixture521def gen_service_resource_dhcp_options_sets_collection(gen_ec2_resource):522 return gen_ec2_resource.dhcp_options_sets.all()523@pytest.fixture524def gen_service_resource_images_collection(gen_ec2_resource):525 return gen_ec2_resource.images.all()526@pytest.fixture527def gen_service_resource_instances_collection(gen_ec2_resource):528 return gen_ec2_resource.instances.all()529@pytest.fixture530def gen_service_resource_internet_gateways_collection(gen_ec2_resource):531 return gen_ec2_resource.internet_gateways.all()532@pytest.fixture533def gen_service_resource_key_pairs_collection(gen_ec2_resource):534 return gen_ec2_resource.key_pairs.all()535@pytest.fixture536def gen_service_resource_network_acls_collection(gen_ec2_resource):537 return gen_ec2_resource.network_acls.all()538@pytest.fixture539def gen_service_resource_network_interfaces_collection(gen_ec2_resource):540 return gen_ec2_resource.network_interfaces.all()541@pytest.fixture542def gen_service_resource_placement_groups_collection(gen_ec2_resource):543 return gen_ec2_resource.placement_groups.all()544@pytest.fixture545def gen_service_resource_route_tables_collection(gen_ec2_resource):546 return gen_ec2_resource.route_tables.all()547@pytest.fixture548def gen_service_resource_security_groups_collection(gen_ec2_resource):549 return gen_ec2_resource.security_groups.all()550@pytest.fixture551def gen_service_resource_snapshots_collection(gen_ec2_resource):552 return gen_ec2_resource.snapshots.all()553@pytest.fixture554def gen_service_resource_subnets_collection(gen_ec2_resource):555 return gen_ec2_resource.subnets.all()556@pytest.fixture557def gen_service_resource_volumes_collection(gen_ec2_resource):558 return gen_ec2_resource.volumes.all()559@pytest.fixture560def gen_service_resource_vpc_addresses_collection(gen_ec2_resource):561 return gen_ec2_resource.vpc_addresses.all()562@pytest.fixture563def gen_service_resource_vpc_peering_connections_collection(gen_ec2_resource):564 return gen_ec2_resource.vpc_peering_connections.all()565@pytest.fixture566def gen_service_resource_vpcs_collection(gen_ec2_resource):567 return gen_ec2_resource.vpcs.all()568@pytest.fixture569def gen_instance_volumes_collection(gen_instance):570 return gen_instance.volumes.all()571@pytest.fixture572def gen_instance_vpc_addresses_collection(gen_instance):573 return gen_instance.vpc_addresses.all()574@pytest.fixture575def gen_placement_group_instances_collection(gen_placement_group):576 return gen_placement_group.instances.all()577@pytest.fixture578def gen_subnet_instances_collection(gen_subnet):579 return gen_subnet.instances.all()580@pytest.fixture581def gen_subnet_network_interfaces_collection(gen_subnet):582 return gen_subnet.network_interfaces.all()583@pytest.fixture584def gen_volume_snapshots_collection(gen_volume):585 return gen_volume.snapshots.all()586@pytest.fixture587def gen_vpc_accepted_vpc_peering_connections_collection(gen_vpc):588 return gen_vpc.accepted_vpc_peering_connections.all()589@pytest.fixture590def gen_vpc_instances_collection(gen_vpc):591 return gen_vpc.instances.all()592@pytest.fixture593def gen_vpc_internet_gateways_collection(gen_vpc):594 return gen_vpc.internet_gateways.all()595@pytest.fixture596def gen_vpc_network_acls_collection(gen_vpc):597 return gen_vpc.network_acls.all()598@pytest.fixture599def gen_vpc_network_interfaces_collection(gen_vpc):600 return gen_vpc.network_interfaces.all()601@pytest.fixture602def gen_vpc_requested_vpc_peering_connections_collection(gen_vpc):603 return gen_vpc.requested_vpc_peering_connections.all()604@pytest.fixture605def gen_vpc_route_tables_collection(gen_vpc):606 return gen_vpc.route_tables.all()607@pytest.fixture608def gen_vpc_security_groups_collection(gen_vpc):609 return gen_vpc.security_groups.all()610@pytest.fixture611def gen_vpc_subnets_collection(gen_vpc):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!