Weitere AWS SDK-Beispiele sind im AWS Doc SDK Examples
Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
Beispiele für Amazon EC2 unter Verwendung von SDK für SAP ABAP
Die folgenden Codebeispiele zeigen Ihnen, wie Sie mithilfe des AWS SDK für SAP ABAP mit Amazon EC2 Aktionen ausführen und gängige Szenarien implementieren.
Aktionen sind Codeauszüge aus größeren Programmen und müssen im Kontext ausgeführt werden. Während Aktionen Ihnen zeigen, wie Sie einzelne Service-Funktionen aufrufen, können Sie Aktionen im Kontext der zugehörigen Szenarien anzeigen.
Jedes Beispiel enthält einen Link zum vollständigen Quellcode, wo Sie Anweisungen zum Einrichten und Ausführen des Codes im Kodex finden.
Themen
Aktionen
Das folgende Codebeispiel zeigt die Verwendung. AllocateAddress
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->allocateaddress( iv_domain = 'vpc' ). " oo_result is returned for testing purposes. " MESSAGE 'Allocated an Elastic IP address.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie AllocateAddress in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungAssociateAddress.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->associateaddress( " oo_result is returned for testing purposes. " iv_allocationid = iv_allocation_id iv_instanceid = iv_instance_id ). MESSAGE 'Associated an Elastic IP address with an EC2 instance.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie AssociateAddress in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungAuthorizeSecurityGroupIngress.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. " Create IP permissions for SSH access (port 22) " iv_cidr_ip = '192.0.2.0/24' DATA lt_ip_permissions TYPE /aws1/cl_ec2ippermission=>tt_ippermissionlist. DATA(lo_ip_permission) = NEW /aws1/cl_ec2ippermission( iv_ipprotocol = 'tcp' iv_fromport = 22 iv_toport = 22 it_ipranges = VALUE /aws1/cl_ec2iprange=>tt_iprangelist( ( NEW /aws1/cl_ec2iprange( iv_cidrip = iv_cidr_ip ) ) ) ). APPEND lo_ip_permission TO lt_ip_permissions. TRY. oo_result = lo_ec2->authsecuritygroupingress( " oo_result is returned for testing purposes. " iv_groupid = iv_group_id it_ippermissions = lt_ip_permissions ). MESSAGE 'Authorized ingress rule for security group.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie AuthorizeSecurityGroupIngress in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungCreateKeyPair.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->createkeypair( iv_keyname = iv_key_name ). " oo_result is returned for testing purposes. " MESSAGE 'Amazon EC2 key pair created.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie CreateKeyPair in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungCreateSecurityGroup.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->createsecuritygroup( " oo_result is returned for testing purposes. " iv_description = 'Security group example' iv_groupname = iv_security_group_name iv_vpcid = iv_vpc_id ). MESSAGE 'Security group created.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie CreateSecurityGroup in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungCreateVpc.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. " iv_cidr_block = '10.0.0.0/16' TRY. oo_result = lo_ec2->createvpc( iv_cidrblock = iv_cidr_block ). " oo_result is returned for testing purposes. " DATA(lv_vpc_id) = oo_result->get_vpc( )->get_vpcid( ). MESSAGE 'Created VPC.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie CreateVpc in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungCreateVpcEndpoint.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. " iv_vpc_id = 'vpc-abc123' " iv_service_name = 'com.amazonaws.region.service' TRY. oo_result = lo_ec2->createvpcendpoint( " oo_result is returned for testing purposes. " iv_vpcid = iv_vpc_id iv_servicename = iv_service_name it_routetableids = it_route_table_ids ). DATA(lv_vpc_endpoint_id) = oo_result->get_vpcendpoint( )->get_vpcendpointid( ). MESSAGE 'Created VPC endpoint.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie CreateVpcEndpoint in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDeleteKeyPair.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. lo_ec2->deletekeypair( iv_keyname = iv_key_name ). MESSAGE 'Amazon EC2 key pair deleted.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DeleteKeyPair in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDeleteSecurityGroup.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. lo_ec2->deletesecuritygroup( iv_groupid = iv_security_group_id ). MESSAGE 'Security group deleted.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DeleteSecurityGroup in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDeleteVpc.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. lo_ec2->deletevpc( iv_vpcid = iv_vpc_id ). MESSAGE 'Deleted VPC.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DeleteVpc in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDeleteVpcEndpoints.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. lo_ec2->deletevpcendpoints( it_vpcendpointids = it_vpc_endpoint_ids ). MESSAGE 'Deleted VPC endpoint(s).' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DeleteVpcEndpoints in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeAddresses.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->describeaddresses( ). " oo_result is returned for testing purposes. " DATA(lt_addresses) = oo_result->get_addresses( ). MESSAGE 'Retrieved information about Elastic IP addresses.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeAddresses in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeAvailabilityZones.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->describeavailabilityzones( ). " oo_result is returned for testing purposes. " DATA(lt_zones) = oo_result->get_availabilityzones( ). MESSAGE 'Retrieved information about Availability Zones.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeAvailabilityZones in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeImages.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->describeimages( it_imageids = it_image_ids ). " oo_result is returned for testing purposes. " DATA(lt_images) = oo_result->get_images( ). MESSAGE 'Retrieved information about Amazon Machine Images (AMIs).' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeImages in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeInstanceTypes.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. " Create filters for architecture and instance type patterns " iv_architecture = 'x86_64' DATA lt_filters TYPE /aws1/cl_ec2filter=>tt_filterlist. APPEND NEW /aws1/cl_ec2filter( iv_name = 'processor-info.supported-architecture' it_values = VALUE /aws1/cl_ec2valuestringlist_w=>tt_valuestringlist( ( NEW /aws1/cl_ec2valuestringlist_w( iv_architecture ) ) ) ) TO lt_filters. " Filter for instance type patterns like '*.micro', '*.small' APPEND NEW /aws1/cl_ec2filter( iv_name = 'instance-type' it_values = VALUE /aws1/cl_ec2valuestringlist_w=>tt_valuestringlist( ( NEW /aws1/cl_ec2valuestringlist_w( '*.micro' ) ) ( NEW /aws1/cl_ec2valuestringlist_w( '*.small' ) ) ) ) TO lt_filters. TRY. oo_result = lo_ec2->describeinstancetypes( it_filters = lt_filters ). " oo_result is returned for testing purposes. " DATA(lt_instance_types) = oo_result->get_instancetypes( ). MESSAGE 'Retrieved information about EC2 instance types.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeInstanceTypes in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeInstances.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->describeinstances( ). " oo_result is returned for testing purposes. " " Retrieving details of EC2 instances. " DATA: lv_istance_id TYPE /aws1/ec2string, lv_status TYPE /aws1/ec2instancestatename, lv_instance_type TYPE /aws1/ec2instancetype, lv_image_id TYPE /aws1/ec2string. LOOP AT oo_result->get_reservations( ) INTO DATA(lo_reservation). LOOP AT lo_reservation->get_instances( ) INTO DATA(lo_instance). lv_istance_id = lo_instance->get_instanceid( ). lv_status = lo_instance->get_state( )->get_name( ). lv_instance_type = lo_instance->get_instancetype( ). lv_image_id = lo_instance->get_imageid( ). ENDLOOP. ENDLOOP. MESSAGE 'Retrieved information about EC2 instances.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeInstances in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeKeyPairs.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->describekeypairs( ). " oo_result is returned for testing purposes. " DATA(lt_key_pairs) = oo_result->get_keypairs( ). MESSAGE 'Retrieved information about key pairs.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeKeyPairs in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeRegions.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. oo_result = lo_ec2->describeregions( ). " oo_result is returned for testing purposes. " DATA(lt_regions) = oo_result->get_regions( ). MESSAGE 'Retrieved information about Regions.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeRegions in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeRouteTables.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. " Create filter for VPC ID " iv_vpc_id = 'vpc-abc123' DATA lt_filters TYPE /aws1/cl_ec2filter=>tt_filterlist. APPEND NEW /aws1/cl_ec2filter( iv_name = 'vpc-id' it_values = VALUE /aws1/cl_ec2valuestringlist_w=>tt_valuestringlist( ( NEW /aws1/cl_ec2valuestringlist_w( iv_vpc_id ) ) ) ) TO lt_filters. TRY. oo_result = lo_ec2->describeroutetables( it_filters = lt_filters ). " oo_result is returned for testing purposes. " DATA(lt_route_tables) = oo_result->get_routetables( ). MESSAGE 'Retrieved information about route tables.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeRouteTables in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungDescribeSecurityGroups.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. DATA lt_group_ids TYPE /aws1/cl_ec2groupidstrlist_w=>tt_groupidstringlist. APPEND NEW /aws1/cl_ec2groupidstrlist_w( iv_value = iv_group_id ) TO lt_group_ids. oo_result = lo_ec2->describesecuritygroups( it_groupids = lt_group_ids ). " oo_result is returned for testing purposes. " DATA(lt_security_groups) = oo_result->get_securitygroups( ). MESSAGE 'Retrieved information about security groups.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie DescribeSecurityGroups in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungMonitorInstances.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. DATA lt_instance_ids TYPE /aws1/cl_ec2instidstringlist_w=>tt_instanceidstringlist. APPEND NEW /aws1/cl_ec2instidstringlist_w( iv_value = iv_instance_id ) TO lt_instance_ids. "Perform dry run" TRY. " DryRun is set to true. This checks for the required permissions to monitor the instance without actually making the request. " lo_ec2->monitorinstances( it_instanceids = lt_instance_ids iv_dryrun = abap_true ). CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). " If the error code returned is `DryRunOperation`, then you have the required permissions to monitor this instance. " IF lo_exception->av_err_code = 'DryRunOperation'. MESSAGE 'Dry run to enable detailed monitoring completed.' TYPE 'I'. " DryRun is set to false to enable detailed monitoring. " lo_ec2->monitorinstances( it_instanceids = lt_instance_ids iv_dryrun = abap_false ). MESSAGE 'Detailed monitoring enabled.' TYPE 'I'. " If the error code returned is `UnauthorizedOperation`, then you don't have the required permissions to monitor this instance. " ELSEIF lo_exception->av_err_code = 'UnauthorizedOperation'. MESSAGE 'Dry run to enable detailed monitoring failed. User does not have the permissions to monitor the instance.' TYPE 'E'. ELSE. DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDIF. ENDTRY.-
API-Details finden Sie MonitorInstances in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungRebootInstances.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. DATA lt_instance_ids TYPE /aws1/cl_ec2instidstringlist_w=>tt_instanceidstringlist. APPEND NEW /aws1/cl_ec2instidstringlist_w( iv_value = iv_instance_id ) TO lt_instance_ids. "Perform dry run" TRY. " DryRun is set to true. This checks for the required permissions to reboot the instance without actually making the request. " lo_ec2->rebootinstances( it_instanceids = lt_instance_ids iv_dryrun = abap_true ). CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). " If the error code returned is `DryRunOperation`, then you have the required permissions to reboot this instance. " IF lo_exception->av_err_code = 'DryRunOperation'. MESSAGE 'Dry run to reboot instance completed.' TYPE 'I'. " DryRun is set to false to make a reboot request. " lo_ec2->rebootinstances( it_instanceids = lt_instance_ids iv_dryrun = abap_false ). MESSAGE 'Instance rebooted.' TYPE 'I'. " If the error code returned is `UnauthorizedOperation`, then you don't have the required permissions to reboot this instance. " ELSEIF lo_exception->av_err_code = 'UnauthorizedOperation'. MESSAGE 'Dry run to reboot instance failed. User does not have permissions to reboot the instance.' TYPE 'E'. ELSE. DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDIF. ENDTRY.-
API-Details finden Sie RebootInstances in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungReleaseAddress.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. TRY. lo_ec2->releaseaddress( iv_allocationid = iv_allocation_id ). MESSAGE 'Elastic IP address released.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie ReleaseAddress in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungRunInstances.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. " Create tags for resource created during instance launch. " DATA lt_tagspecifications TYPE /aws1/cl_ec2tagspecification=>tt_tagspecificationlist. DATA ls_tagspecifications LIKE LINE OF lt_tagspecifications. ls_tagspecifications = NEW /aws1/cl_ec2tagspecification( iv_resourcetype = 'instance' it_tags = VALUE /aws1/cl_ec2tag=>tt_taglist( ( NEW /aws1/cl_ec2tag( iv_key = 'Name' iv_value = iv_tag_value ) ) ) ). APPEND ls_tagspecifications TO lt_tagspecifications. TRY. " Create/launch Amazon Elastic Compute Cloud (Amazon EC2) instance. " oo_result = lo_ec2->runinstances( " oo_result is returned for testing purposes. " iv_imageid = iv_ami_id iv_instancetype = 't3.micro' iv_maxcount = 1 iv_mincount = 1 it_tagspecifications = lt_tagspecifications iv_subnetid = iv_subnet_id ). MESSAGE 'EC2 instance created.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API-Details finden Sie RunInstances in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungStartInstances.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. DATA lt_instance_ids TYPE /aws1/cl_ec2instidstringlist_w=>tt_instanceidstringlist. APPEND NEW /aws1/cl_ec2instidstringlist_w( iv_value = iv_instance_id ) TO lt_instance_ids. "Perform dry run" TRY. " DryRun is set to true. This checks for the required permissions to start the instance without actually making the request. " lo_ec2->startinstances( it_instanceids = lt_instance_ids iv_dryrun = abap_true ). CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). " If the error code returned is `DryRunOperation`, then you have the required permissions to start this instance. " IF lo_exception->av_err_code = 'DryRunOperation'. MESSAGE 'Dry run to start instance completed.' TYPE 'I'. " DryRun is set to false to start instance. " oo_result = lo_ec2->startinstances( " oo_result is returned for testing purposes. " it_instanceids = lt_instance_ids iv_dryrun = abap_false ). MESSAGE 'Successfully started the EC2 instance.' TYPE 'I'. " If the error code returned is `UnauthorizedOperation`, then you don't have the required permissions to start this instance. " ELSEIF lo_exception->av_err_code = 'UnauthorizedOperation'. MESSAGE 'Dry run to start instance failed. User does not have permissions to start the instance.' TYPE 'E'. ELSE. DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDIF. ENDTRY.-
API-Details finden Sie StartInstances in der AWS SDK for SAP ABAP API-Referenz.
-
Das folgende Codebeispiel zeigt die VerwendungStopInstances.
- SDK für SAP ABAP
-
Anmerkung
Es läuft noch mehr. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. DATA lt_instance_ids TYPE /aws1/cl_ec2instidstringlist_w=>tt_instanceidstringlist. APPEND NEW /aws1/cl_ec2instidstringlist_w( iv_value = iv_instance_id ) TO lt_instance_ids. "Perform dry run" TRY. " DryRun is set to true. This checks for the required permissions to stop the instance without actually making the request. " lo_ec2->stopinstances( it_instanceids = lt_instance_ids iv_dryrun = abap_true ). CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). " If the error code returned is `DryRunOperation`, then you have the required permissions to stop this instance. " IF lo_exception->av_err_code = 'DryRunOperation'. MESSAGE 'Dry run to stop instance completed.' TYPE 'I'. " DryRun is set to false to stop instance. " oo_result = lo_ec2->stopinstances( " oo_result is returned for testing purposes. " it_instanceids = lt_instance_ids iv_dryrun = abap_false ). MESSAGE 'Successfully stopped the EC2 instance.' TYPE 'I'. " If the error code returned is `UnauthorizedOperation`, then you don't have the required permissions to stop this instance. " ELSEIF lo_exception->av_err_code = 'UnauthorizedOperation'. MESSAGE 'Dry run to stop instance failed. User does not have permissions to stop the instance.' TYPE 'E'. ELSE. DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDIF. ENDTRY.-
API-Details finden Sie StopInstances in der AWS SDK for SAP ABAP API-Referenz.
-