Best Python code snippet using localstack_python
bruteforce_tests.py
Source:bruteforce_tests.py
1BRUTEFORCE_TESTS = {2 "a4b": [3 "get_conference_preference",4 "get_device",5 "get_invitation_configuration",6 "get_profile",7 "get_room",8 "get_skill_group",9 "list_business_report_schedules",10 "list_conference_providers",11 "list_skills",12 "list_skills_store_categories"13 ],14 "acm": [15 "list_certificates"16 ],17 "amplify": [18 "list_apps"19 ],20 "apigateway": [21 "get_account",22 "get_api_keys",23 "get_client_certificates",24 "get_domain_names",25 "get_rest_apis",26 "get_sdk_types",27 "get_usage_plans",28 "get_vpc_links",29 "get_domain_names"30 ],31 "appmesh": [32 "list_meshes",33 "list_meshes"34 ],35 "appstream2": [36 "describe_directory_configs",37 "describe_fleets",38 "describe_image_builders",39 "describe_images",40 "describe_user_stack_associations"41 ],42 "appsync": [43 "list_graphql_apis"44 ],45 "athena": [46 "list_named_queries",47 "list_query_executions",48 "list_work_groups"49 ],50 "autoscaling": [51 "describe_account_limits",52 "describe_adjustment_types",53 "describe_auto_scaling_groups",54 "describe_auto_scaling_instances",55 "describe_auto_scaling_notification_types",56 "describe_launch_configurations",57 "describe_lifecycle_hook_types",58 "describe_metric_collection_types",59 "describe_notification_configurations",60 "describe_policies",61 "describe_scaling_activities",62 "describe_scaling_process_types",63 "describe_scheduled_actions",64 "describe_tags",65 "describe_termination_policy_types"66 ],67 "backup": [68 "get_supported_resource_types",69 "list_backup_jobs",70 "list_backup_plan_templates",71 "list_backup_plans",72 "list_backup_vaults",73 "list_protected_resources",74 "list_restore_jobs"75 ],76 "batch": [77 "describe_compute_environments",78 "describe_job_definitions",79 "describe_job_queues",80 "list_jobs"81 ],82 "chime": [83 "list_accounts"84 ],85 "cloud9": [86 "describe_environment_memberships",87 "list_environments"88 ],89 "clouddirectory": [90 "list_development_schema_arns",91 "list_directories",92 "list_published_schema_arns",93 "list_development_schema_arns",94 "list_directories",95 "list_managed_schema_arns",96 "list_published_schema_arns"97 ],98 "cloudformation": [99 "describe_account_limits",100 "describe_stack_events",101 "describe_stack_resources",102 "get_template",103 "get_template_summary",104 "list_exports",105 "list_stack_sets",106 "list_stacks"107 ],108 "cloudfront": [109 "list_cloud_front_origin_access_identities",110 "list_distributions",111 "list_field_level_encryption_configs",112 "list_field_level_encryption_profiles",113 "list_streaming_distributions",114 "list_cloud_front_origin_access_identities",115 "list_distributions",116 "list_streaming_distributions",117 "list_cloud_front_origin_access_identities",118 "list_distributions",119 "list_field_level_encryption_configs",120 "list_field_level_encryption_profiles",121 "list_streaming_distributions",122 "list_cloud_front_origin_access_identities",123 "list_distributions",124 "list_field_level_encryption_configs",125 "list_field_level_encryption_profiles",126 "list_streaming_distributions",127 "list_cloud_front_origin_access_identities",128 "list_distributions",129 "list_streaming_distributions"130 ],131 "cloudhsm": [132 "describe_hsm",133 "describe_luna_client",134 "list_available_zones",135 "list_hapgs",136 "list_hsms",137 "list_luna_clients"138 ],139 "cloudhsmv2": [140 "describe_backups",141 "describe_clusters"142 ],143 "cloudsearch": [144 "describe_domains",145 "list_domain_names",146 "describe_domains"147 ],148 "cloudtrail": [149 "describe_trails"150 ],151 "codebuild": [152 "list_builds",153 "list_curated_environment_images",154 "list_projects",155 "list_source_credentials"156 ],157 "codecommit": [158 "get_branch",159 "list_repositories"160 ],161 "codedeploy": [162 "batch_get_deployment_targets",163 "get_deployment_target",164 "list_applications",165 "list_deployment_configs",166 "list_deployment_targets",167 "list_deployments",168 "list_git_hub_account_token_names",169 "list_on_premises_instances"170 ],171 "codepipeline": [172 "list_action_types",173 "list_pipelines",174 "list_webhooks"175 ],176 "codestar": [177 "list_projects",178 "list_user_profiles"179 ],180 "cognito-sync": [181 "list_identity_pool_usage"182 ],183 "comprehend": [184 "list_document_classification_jobs",185 "list_document_classifiers",186 "list_dominant_language_detection_jobs",187 "list_entities_detection_jobs",188 "list_entity_recognizers",189 "list_key_phrases_detection_jobs",190 "list_sentiment_detection_jobs",191 "list_topics_detection_jobs"192 ],193 "config": [194 "describe_aggregation_authorizations",195 "describe_compliance_by_config_rule",196 "describe_compliance_by_resource",197 "describe_config_rule_evaluation_status",198 "describe_config_rules",199 "describe_configuration_aggregators",200 "describe_configuration_recorder_status",201 "describe_configuration_recorders",202 "describe_delivery_channel_status",203 "describe_delivery_channels",204 "describe_pending_aggregation_requests",205 "describe_retention_configurations",206 "get_compliance_summary_by_config_rule",207 "get_compliance_summary_by_resource_type",208 "get_discovered_resource_counts"209 ],210 "cur": [211 "describe_report_definitions"212 ],213 "data.mediastore": [214 "list_items"215 ],216 "datapipeline": [217 "list_pipelines"218 ],219 "datasync": [220 "list_agents",221 "list_locations",222 "list_task_executions",223 "list_tasks"224 ],225 "dax": [226 "describe_clusters",227 "describe_default_parameters",228 "describe_parameter_groups",229 "describe_subnet_groups"230 ],231 "devicefarm": [232 "get_account_settings",233 "get_offering_status",234 "list_device_instances",235 "list_devices",236 "list_instance_profiles",237 "list_offering_promotions",238 "list_offering_transactions",239 "list_offerings",240 "list_projects",241 "list_vpce_configurations"242 ],243 "devices.iot1click": [244 "list_devices"245 ],246 "directconnect": [247 "describe_connections",248 "describe_direct_connect_gateway_associations",249 "describe_direct_connect_gateway_attachments",250 "describe_direct_connect_gateways",251 "describe_interconnects",252 "describe_lags",253 "describe_locations",254 "describe_virtual_gateways",255 "describe_virtual_interfaces"256 ],257 "discovery": [258 "describe_agents",259 "describe_continuous_exports",260 "describe_export_configurations",261 "describe_export_tasks",262 "describe_import_tasks",263 "get_discovery_summary"264 ],265 "dlm": [266 "get_lifecycle_policies"267 ],268 "dms": [269 "describe_account_attributes",270 "describe_certificates",271 "describe_connections",272 "describe_endpoint_types",273 "describe_endpoints",274 "describe_event_categories",275 "describe_event_subscriptions",276 "describe_orderable_replication_instances",277 "describe_replication_instances",278 "describe_replication_subnet_groups",279 "describe_replication_task_assessment_results",280 "describe_replication_tasks"281 ],282 "ds": [283 "describe_directories",284 "describe_event_topics",285 "describe_snapshots",286 "describe_trusts",287 "get_directory_limits",288 "list_log_subscriptions"289 ],290 "dynamodb": [291 "describe_endpoints",292 "describe_limits",293 "list_backups",294 "list_global_tables",295 "list_tables",296 "list_tables"297 ],298 "ec2": [299 "describe_account_attributes",300 "describe_addresses",301 "describe_aggregate_id_format",302 "describe_availability_zones",303 "describe_bundle_tasks",304 "describe_capacity_reservations",305 "describe_classic_link_instances",306 "describe_client_vpn_endpoints",307 "describe_conversion_tasks",308 "describe_customer_gateways",309 "describe_dhcp_options",310 "describe_egress_only_internet_gateways",311 "describe_elastic_gpus",312 "describe_export_tasks",313 "describe_fleets",314 "describe_flow_logs",315 "describe_fpga_images",316 "describe_host_reservation_offerings",317 "describe_host_reservations",318 "describe_hosts",319 "describe_iam_instance_profile_associations",320 "describe_id_format",321 "describe_images",322 "describe_import_image_tasks",323 "describe_import_snapshot_tasks",324 "describe_instance_credit_specifications",325 "describe_instance_status",326 "describe_instances",327 "describe_internet_gateways",328 "describe_key_pairs",329 "describe_launch_template_versions",330 "describe_launch_templates",331 "describe_moving_addresses",332 "describe_nat_gateways",333 "describe_network_acls",334 "describe_network_interface_permissions",335 "describe_network_interfaces",336 "describe_placement_groups",337 "describe_prefix_lists",338 "describe_principal_id_format",339 "describe_public_ipv4_pools",340 "describe_regions",341 "describe_reserved_instances",342 "describe_reserved_instances_listings",343 "describe_reserved_instances_modifications",344 "describe_reserved_instances_offerings",345 "describe_route_tables",346 "describe_scheduled_instances",347 "describe_security_groups",348 "describe_snapshots",349 "describe_spot_datafeed_subscription",350 "describe_spot_fleet_requests",351 "describe_spot_instance_requests",352 "describe_spot_price_history",353 "describe_subnets",354 "describe_tags",355 "describe_transit_gateway_attachments",356 "describe_transit_gateway_route_tables",357 "describe_transit_gateway_vpc_attachments",358 "describe_transit_gateways",359 "describe_volume_status",360 "describe_volumes",361 "describe_volumes_modifications",362 "describe_vpc_classic_link",363 "describe_vpc_classic_link_dns_support",364 "describe_vpc_endpoint_connection_notifications",365 "describe_vpc_endpoint_connections",366 "describe_vpc_endpoint_service_configurations",367 "describe_vpc_endpoint_services",368 "describe_vpc_endpoints",369 "describe_vpc_peering_connections",370 "describe_vpcs",371 "describe_vpn_connections",372 "describe_vpn_gateways"373 ],374 "ecr": [375 "describe_repositories",376 "get_authorization_token"377 ],378 "ecs": [379 "describe_clusters",380 "list_account_settings",381 "list_clusters",382 "list_container_instances",383 "list_services",384 "list_task_definition_families",385 "list_task_definitions",386 "list_tasks"387 ],388 "eks": [389 "list_clusters"390 ],391 "elasticache": [392 "describe_cache_clusters",393 "describe_cache_engine_versions",394 "describe_cache_parameter_groups",395 "describe_cache_security_groups",396 "describe_cache_subnet_groups",397 "describe_replication_groups",398 "describe_reserved_cache_nodes",399 "describe_reserved_cache_nodes_offerings",400 "describe_snapshots",401 "list_allowed_node_type_modifications"402 ],403 "elasticbeanstalk": [404 "describe_account_attributes",405 "describe_configuration_options",406 "describe_environment_health",407 "describe_environment_managed_action_history",408 "describe_environment_managed_actions",409 "describe_environment_resources",410 "describe_instances_health",411 "describe_platform_version"412 ],413 "elasticfilesystem": [414 "describe_file_systems",415 "describe_mount_targets"416 ],417 "elasticloadbalancing": [418 "describe_account_limits",419 "describe_load_balancer_policies",420 "describe_load_balancer_policy_types",421 "describe_load_balancers",422 "describe_account_limits",423 "describe_listeners",424 "describe_load_balancers",425 "describe_rules",426 "describe_ssl_policies",427 "describe_target_groups"428 ],429 "elasticmapreduce": [430 "describe_job_flows",431 "list_clusters",432 "list_security_configurations"433 ],434 "elastictranscoder": [435 "list_pipelines",436 "list_presets"437 ],438 "email": [439 "get_account",440 "get_dedicated_ips",441 "get_deliverability_dashboard_options",442 "list_configuration_sets",443 "list_dedicated_ip_pools",444 "list_deliverability_test_reports",445 "list_email_identities",446 "describe_active_receipt_rule_set",447 "get_account_sending_enabled",448 "get_send_quota",449 "get_send_statistics",450 "list_configuration_sets",451 "list_custom_verification_email_templates",452 "list_identities",453 "list_receipt_filters",454 "list_receipt_rule_sets",455 "list_templates",456 "list_verified_email_addresses"457 ],458 "es": [459 "describe_reserved_elasticsearch_instance_offerings",460 "describe_reserved_elasticsearch_instances",461 "get_compatible_elasticsearch_versions",462 "list_domain_names",463 "list_elasticsearch_versions"464 ],465 "events": [466 "describe_event_bus",467 "list_rules"468 ],469 "firehose": [470 "list_delivery_streams"471 ],472 "fms": [473 "get_admin_account",474 "get_notification_channel",475 "list_member_accounts",476 "list_policies"477 ],478 "fsx": [479 "describe_backups",480 "describe_file_systems"481 ],482 "gamelift": [483 "describe_ec2_instance_limits",484 "describe_fleet_attributes",485 "describe_fleet_capacity",486 "describe_fleet_utilization",487 "describe_game_session_details",488 "describe_game_session_queues",489 "describe_game_sessions",490 "describe_matchmaking_configurations",491 "describe_matchmaking_rule_sets",492 "describe_player_sessions",493 "describe_vpc_peering_authorizations",494 "describe_vpc_peering_connections",495 "list_aliases",496 "list_builds",497 "list_fleets"498 ],499 "globalaccelerator": [500 "describe_accelerator_attributes",501 "list_accelerators"502 ],503 "glue": [504 "get_catalog_import_status",505 "get_classifiers",506 "get_connections",507 "get_crawler_metrics",508 "get_crawlers",509 "get_data_catalog_encryption_settings",510 "get_databases",511 "get_dataflow_graph",512 "get_dev_endpoints",513 "get_jobs",514 "get_resource_policy",515 "get_security_configurations",516 "get_triggers",517 "list_crawlers",518 "list_dev_endpoints",519 "list_jobs",520 "list_triggers"521 ],522 "greengrass": [523 "get_service_role_for_account",524 "list_bulk_deployments",525 "list_connector_definitions",526 "list_core_definitions",527 "list_device_definitions",528 "list_function_definitions",529 "list_groups",530 "list_logger_definitions",531 "list_resource_definitions",532 "list_subscription_definitions"533 ],534 "guardduty": [535 "get_invitations_count",536 "list_detectors",537 "list_invitations"538 ],539 "health": [540 "describe_entity_aggregates",541 "describe_event_types"542 ],543 "iam": [544 "get_account_authorization_details",545 "get_account_password_policy",546 "get_account_summary",547 "get_credential_report",548 "get_user",549 "list_access_keys",550 "list_account_aliases",551 "list_groups",552 "list_instance_profiles",553 "list_mfa_devices",554 "list_open_id_connect_providers",555 "list_policies",556 "list_roles",557 "list_saml_providers",558 "list_server_certificates",559 "list_service_specific_credentials",560 "list_signing_certificates",561 "list_ssh_public_keys",562 "list_users",563 "list_virtual_mfa_devices"564 ],565 "importexport": [566 "list_jobs"567 ],568 "inspector": [569 "describe_cross_account_access_role",570 "list_assessment_runs",571 "list_assessment_targets",572 "list_assessment_templates",573 "list_event_subscriptions",574 "list_findings",575 "list_rules_packages"576 ],577 "iot": [578 "describe_account_audit_configuration",579 "describe_default_authorizer",580 "describe_endpoint",581 "describe_event_configurations",582 "get_effective_policies",583 "get_indexing_configuration",584 "get_logging_options",585 "get_registration_code",586 "get_v2_logging_options",587 "list_active_violations",588 "list_audit_findings",589 "list_authorizers",590 "list_billing_groups",591 "list_ca_certificates",592 "list_certificates",593 "list_indices",594 "list_jobs",595 "list_ota_updates",596 "list_outgoing_certificates",597 "list_policies",598 "list_role_aliases",599 "list_scheduled_audits",600 "list_security_profiles",601 "list_streams",602 "list_thing_groups",603 "list_thing_registration_tasks",604 "list_thing_types",605 "list_things",606 "list_topic_rules",607 "list_v2_logging_levels"608 ],609 "iotanalytics": [610 "describe_logging_options",611 "list_channels",612 "list_datasets",613 "list_datastores",614 "list_pipelines"615 ],616 "kafka": [617 "list_clusters"618 ],619 "kinesis": [620 "describe_limits",621 "describe_stream_consumer",622 "list_shards",623 "list_streams"624 ],625 "kinesisanalytics": [626 "list_applications",627 "list_applications"628 ],629 "kinesisvideo": [630 "describe_stream",631 "list_streams",632 "list_tags_for_stream"633 ],634 "kms": [635 "describe_custom_key_stores",636 "list_aliases",637 "list_keys"638 ],639 "lambda": [640 "list_functions",641 "get_account_settings",642 "list_event_source_mappings",643 "list_functions",644 "list_layers"645 ],646 "license-manager": [647 "get_service_settings",648 "list_license_configurations"649 ],650 "lightsail": [651 "get_active_names",652 "get_blueprints",653 "get_bundles",654 "get_cloud_formation_stack_records",655 "get_disk_snapshots",656 "get_disks",657 "get_domains",658 "get_export_snapshot_records",659 "get_instance_snapshots",660 "get_instances",661 "get_key_pairs",662 "get_load_balancers",663 "get_operations",664 "get_regions",665 "get_relational_database_blueprints",666 "get_relational_database_bundles",667 "get_relational_database_snapshots",668 "get_relational_databases",669 "get_static_ips"670 ],671 "logs": [672 "describe_destinations",673 "describe_export_tasks",674 "describe_log_groups",675 "describe_metric_filters",676 "describe_queries",677 "describe_resource_policies"678 ],679 "machinelearning": [680 "describe_batch_predictions",681 "describe_data_sources",682 "describe_evaluations",683 "describe_ml_models"684 ],685 "macie": [686 "list_member_accounts",687 "list_s3_resources"688 ],689 "mediaconnect": [690 "list_entitlements",691 "list_flows"692 ],693 "mediaconvert": [694 "describe_endpoints",695 "list_job_templates",696 "list_jobs",697 "list_presets",698 "list_queues"699 ],700 "medialive": [701 "list_channels",702 "list_input_security_groups",703 "list_inputs",704 "list_offerings",705 "list_reservations"706 ],707 "mediapackage": [708 "list_channels",709 "list_origin_endpoints"710 ],711 "mediastore": [712 "describe_container",713 "list_containers"714 ],715 "mediatailor": [716 "list_playback_configurations"717 ],718 "mgh": [719 "list_migration_tasks",720 "list_progress_update_streams"721 ],722 "mobile": [723 "list_bundles",724 "list_projects"725 ],726 "models.lex": [727 "get_bots",728 "get_builtin_intents",729 "get_builtin_slot_types",730 "get_intents",731 "get_slot_types"732 ],733 "monitoring": [734 "describe_alarm_history",735 "describe_alarms",736 "list_dashboards"737 ],738 "mq": [739 "list_brokers",740 "list_configurations"741 ],742 "mturk-requester": [743 "get_account_balance",744 "list_bonus_payments",745 "list_hi_ts",746 "list_qualification_requests",747 "list_reviewable_hi_ts",748 "list_worker_blocks"749 ],750 "opsworks": [751 "describe_agent_versions",752 "describe_apps",753 "describe_commands",754 "describe_deployments",755 "describe_ecs_clusters",756 "describe_elastic_ips",757 "describe_elastic_load_balancers",758 "describe_instances",759 "describe_layers",760 "describe_my_user_profile",761 "describe_operating_systems",762 "describe_permissions",763 "describe_raid_arrays",764 "describe_user_profiles",765 "describe_volumes"766 ],767 "opworks": [768 "describe_account_attributes",769 "describe_backups",770 "describe_servers"771 ],772 "organizations": [773 "describe_organization",774 "list_accounts",775 "list_aws_service_access_for_organization",776 "list_create_account_status",777 "list_handshakes_for_account",778 "list_handshakes_for_organization",779 "list_roots"780 ],781 "pinpoint": [782 "get_apps"783 ],784 "polly": [785 "describe_voices",786 "list_lexicons",787 "list_speech_synthesis_tasks"788 ],789 "pricing": [790 "describe_services"791 ],792 "projects.iot1click": [793 "list_projects"794 ],795 "ram": [796 "get_resource_share_invitations"797 ],798 "rds": [799 "describe_db_engine_versions",800 "describe_db_instances",801 "describe_db_parameter_groups",802 "describe_db_security_groups",803 "describe_db_snapshots",804 "describe_db_subnet_groups",805 "describe_event_categories",806 "describe_event_subscriptions",807 "describe_option_groups",808 "describe_reserved_db_instances",809 "describe_reserved_db_instances_offerings",810 "describe_db_engine_versions",811 "describe_db_instances",812 "describe_db_parameter_groups",813 "describe_db_security_groups",814 "describe_db_snapshots",815 "describe_db_subnet_groups",816 "describe_event_categories",817 "describe_event_subscriptions",818 "describe_option_groups",819 "describe_reserved_db_instances",820 "describe_reserved_db_instances_offerings",821 "describe_account_attributes",822 "describe_certificates",823 "describe_db_cluster_endpoints",824 "describe_db_cluster_parameter_groups",825 "describe_db_cluster_snapshots",826 "describe_db_clusters",827 "describe_db_engine_versions",828 "describe_db_instance_automated_backups",829 "describe_db_instances",830 "describe_db_parameter_groups",831 "describe_db_security_groups",832 "describe_db_snapshots",833 "describe_db_subnet_groups",834 "describe_event_categories",835 "describe_event_subscriptions",836 "describe_global_clusters",837 "describe_option_groups",838 "describe_pending_maintenance_actions",839 "describe_reserved_db_instances",840 "describe_reserved_db_instances_offerings",841 "describe_source_regions",842 "describe_db_cluster_parameter_groups",843 "describe_db_cluster_snapshots",844 "describe_db_clusters",845 "describe_db_engine_versions",846 "describe_db_instances",847 "describe_db_parameter_groups",848 "describe_db_subnet_groups",849 "describe_event_categories",850 "describe_event_subscriptions",851 "describe_pending_maintenance_actions",852 "describe_db_engine_versions",853 "describe_db_instances",854 "describe_db_parameter_groups",855 "describe_db_security_groups",856 "describe_db_snapshots",857 "describe_db_subnet_groups",858 "describe_event_categories",859 "describe_event_subscriptions",860 "describe_option_groups",861 "describe_reserved_db_instances",862 "describe_reserved_db_instances_offerings",863 "describe_db_engine_versions",864 "describe_db_instances",865 "describe_db_parameter_groups",866 "describe_db_security_groups",867 "describe_db_snapshots",868 "describe_db_subnet_groups",869 "describe_event_categories",870 "describe_event_subscriptions",871 "describe_option_groups",872 "describe_reserved_db_instances",873 "describe_reserved_db_instances_offerings",874 "describe_db_cluster_parameter_groups",875 "describe_db_cluster_snapshots",876 "describe_db_clusters",877 "describe_db_engine_versions",878 "describe_db_instances",879 "describe_db_subnet_groups",880 "describe_event_categories",881 "describe_pending_maintenance_actions"882 ],883 "redshift": [884 "describe_account_attributes",885 "describe_cluster_db_revisions",886 "describe_cluster_parameter_groups",887 "describe_cluster_security_groups",888 "describe_cluster_subnet_groups",889 "describe_cluster_tracks",890 "describe_cluster_versions",891 "describe_clusters",892 "describe_event_categories",893 "describe_event_subscriptions",894 "describe_hsm_client_certificates",895 "describe_hsm_configurations",896 "describe_orderable_cluster_options",897 "describe_reserved_node_offerings",898 "describe_reserved_nodes",899 "describe_snapshot_copy_grants",900 "describe_snapshot_schedules",901 "describe_storage",902 "describe_table_restore_status",903 "describe_tags"904 ],905 "rekognition": [906 "list_collections",907 "list_stream_processors"908 ],909 "robomaker": [910 "list_deployment_jobs",911 "list_fleets",912 "list_robot_applications",913 "list_robots",914 "list_simulation_applications",915 "list_simulation_jobs"916 ],917 "route53": [918 "get_health_check_count",919 "get_hosted_zone_count",920 "get_traffic_policy_instance_count",921 "list_health_checks",922 "list_hosted_zones",923 "list_hosted_zones_by_name",924 "list_query_logging_configs",925 "list_reusable_delegation_sets",926 "list_traffic_policies",927 "list_traffic_policy_instances"928 ],929 "route53domains": [930 "get_contact_reachability_status",931 "list_domains",932 "list_operations"933 ],934 "route53resolver": [935 "list_resolver_endpoints",936 "list_resolver_rule_associations",937 "list_resolver_rules"938 ],939 "s3": [940 "list_buckets"941 ],942 "sagemaker": [943 "list_algorithms",944 "list_code_repositories",945 "list_compilation_jobs",946 "list_endpoint_configs",947 "list_endpoints",948 "list_hyper_parameter_tuning_jobs",949 "list_labeling_jobs",950 "list_model_packages",951 "list_models",952 "list_notebook_instance_lifecycle_configs",953 "list_notebook_instances",954 "list_subscribed_workteams",955 "list_training_jobs",956 "list_transform_jobs",957 "list_workteams"958 ],959 "sdb": [960 "list_domains"961 ],962 "secretsmanager": [963 "get_random_password",964 "list_secrets"965 ],966 "securityhub": [967 "get_enabled_standards",968 "get_findings",969 "get_insights",970 "get_invitations_count",971 "get_master_account",972 "list_enabled_products_for_import",973 "list_invitations",974 "list_members"975 ],976 "serverlessrepo": [977 "list_applications"978 ],979 "servicecatalog": [980 "get_aws_organizations_access_status",981 "list_accepted_portfolio_shares",982 "list_portfolios",983 "list_provisioned_product_plans",984 "list_record_history",985 "list_service_actions",986 "list_tag_options"987 ],988 "shield": [989 "describe_drt_access",990 "describe_emergency_contact_settings",991 "describe_protection",992 "describe_subscription",993 "get_subscription_state",994 "list_attacks",995 "list_protections"996 ],997 "signer": [998 "list_signing_jobs",999 "list_signing_platforms",1000 "list_signing_profiles"1001 ],1002 "sms": [1003 "get_app",1004 "get_app_launch_configuration",1005 "get_app_replication_configuration",1006 "get_connectors",1007 "get_replication_jobs",1008 "get_servers",1009 "list_apps"1010 ],1011 "sms-voice.pinpoint": [1012 "list_configuration_sets"1013 ],1014 "snowball": [1015 "describe_addresses",1016 "get_snowball_usage",1017 "list_clusters",1018 "list_compatible_images",1019 "list_jobs"1020 ],1021 "sns": [1022 "get_sms_attributes",1023 "list_phone_numbers_opted_out",1024 "list_platform_applications",1025 "list_subscriptions",1026 "list_topics"1027 ],1028 "sqs": [1029 "list_queues"1030 ],1031 "ssm": [1032 "describe_activations",1033 "describe_association",1034 "describe_available_patches",1035 "describe_inventory_deletions",1036 "describe_maintenance_window_schedule",1037 "describe_maintenance_windows",1038 "describe_patch_baselines",1039 "describe_patch_groups",1040 "get_default_patch_baseline",1041 "get_inventory_schema",1042 "list_command_invocations",1043 "list_commands",1044 "list_compliance_items",1045 "list_compliance_summaries",1046 "list_resource_compliance_summaries",1047 "list_resource_data_sync"1048 ],1049 "states": [1050 "list_activities",1051 "list_state_machines"1052 ],1053 "storagegateway": [1054 "describe_tape_archives",1055 "list_file_shares",1056 "list_gateways",1057 "list_tapes",1058 "list_volumes"1059 ],1060 "streams.dynamodb": [1061 "list_streams"1062 ],1063 "sts": [1064 "get_caller_identity",1065 "get_session_token"1066 ],1067 "support": [1068 "describe_cases",1069 "describe_services",1070 "describe_severity_levels"1071 ],1072 "tagging": [1073 "get_resources",1074 "get_tag_keys"1075 ],1076 "transcribe": [1077 "list_transcription_jobs",1078 "list_vocabularies"1079 ],1080 "transfer": [1081 "list_servers"1082 ],1083 "translate": [1084 "list_terminologies"1085 ],1086 "waf": [1087 "get_change_token",1088 "list_activated_rules_in_rule_group",1089 "list_byte_match_sets",1090 "list_geo_match_sets",1091 "list_ip_sets",1092 "list_logging_configurations",1093 "list_rate_based_rules",1094 "list_regex_match_sets",1095 "list_regex_pattern_sets",1096 "list_rule_groups",1097 "list_rules",1098 "list_size_constraint_sets",1099 "list_sql_injection_match_sets",1100 "list_subscribed_rule_groups",1101 "list_xss_match_sets"1102 ],1103 "waf-regional": [1104 "get_change_token",1105 "list_activated_rules_in_rule_group",1106 "list_byte_match_sets",1107 "list_geo_match_sets",1108 "list_ip_sets",1109 "list_logging_configurations",1110 "list_rate_based_rules",1111 "list_regex_match_sets",1112 "list_regex_pattern_sets",1113 "list_rule_groups",1114 "list_rules",1115 "list_size_constraint_sets",1116 "list_sql_injection_match_sets",1117 "list_subscribed_rule_groups",1118 "list_xss_match_sets"1119 ],1120 "workdocs": [1121 "describe_activities",1122 "describe_users",1123 "get_resources"1124 ],1125 "worklink": [1126 "list_fleets"1127 ],1128 "workmail": [1129 "list_organizations"1130 ],1131 "workspaces": [1132 "describe_account",1133 "describe_account_modifications",1134 "describe_ip_groups",1135 "describe_workspace_bundles",1136 "describe_workspace_directories",1137 "describe_workspace_images",1138 "describe_workspaces",1139 "describe_workspaces_connection_status"1140 ],1141 "xray": [1142 "get_encryption_config",1143 "get_group",1144 "get_groups",1145 "get_sampling_rules",1146 "get_sampling_statistic_summaries"1147 ]...
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() ...
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!!