AWS Control Tower examples using SDK for SAP ABAP - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

AWS Control Tower examples using SDK for SAP ABAP

The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for SAP ABAP with AWS Control Tower.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use DisableBaseline.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

TRY. " Disable the baseline DATA(lo_output) = io_ctt->disablebaseline( iv_enabledbaselineidentifier = iv_enabled_baseline_identifier ). DATA(lv_operation_id) = lo_output->get_operationidentifier( ). " Wait for operation to complete DATA lv_status TYPE /aws1/cttbaselineopstatus. DO 100 TIMES. lv_status = get_baseline_operation( io_ctt = io_ctt iv_operation_id = lv_operation_id ). DATA(lv_msg) = |Baseline operation status: { lv_status }|. MESSAGE lv_msg TYPE 'I'. IF lv_status = 'SUCCEEDED' OR lv_status = 'FAILED'. EXIT. ENDIF. " Wait 30 seconds WAIT UP TO 30 SECONDS. ENDDO. ov_operation_id = lv_operation_id. MESSAGE 'Baseline disabled successfully.' TYPE 'I'. CATCH /aws1/cx_cttconflictexception INTO DATA(lo_conflict). " Log conflict but don't fail - return empty operation ID DATA(lv_msg2) = |Conflict disabling baseline: { lo_conflict->get_text( ) }. Skipping disable step.|. MESSAGE lv_msg2 TYPE 'I'. CLEAR ov_operation_id. ENDTRY.
  • For API details, see DisableBaseline in AWS SDK for SAP ABAP API reference.

The following code example shows how to use DisableControl.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

" Disable the control DATA(lo_output) = io_ctt->disablecontrol( iv_controlidentifier = iv_control_arn iv_targetidentifier = iv_target_identifier ). DATA(lv_operation_id) = lo_output->get_operationidentifier( ). " Wait for operation to complete DATA lv_status TYPE /aws1/cttcontrolopstatus. DO 100 TIMES. lv_status = get_control_operation( io_ctt = io_ctt iv_operation_id = lv_operation_id ). DATA(lv_msg) = |Control operation status: { lv_status }|. MESSAGE lv_msg TYPE 'I'. IF lv_status = 'SUCCEEDED' OR lv_status = 'FAILED'. EXIT. ENDIF. " Wait 30 seconds WAIT UP TO 30 SECONDS. ENDDO. ov_operation_id = lv_operation_id. MESSAGE 'Control disabled successfully.' TYPE 'I'.
  • For API details, see DisableControl in AWS SDK for SAP ABAP API reference.

The following code example shows how to use EnableBaseline.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

" Prepare parameters for enabling baseline DATA lt_parameters TYPE /aws1/cl_cttenbdbaselineparam=>tt_enabledbaselineparameters. " Add Identity Center baseline parameter if provided IF iv_identity_center_baseline IS NOT INITIAL. " Create a JSON document with the baseline ARN value DATA(lv_json) = |\{ "IdentityCenterEnabledBaselineArn": "{ iv_identity_center_baseline }" \}|. DATA(lo_param) = NEW /aws1/cl_cttenbdbaselineparam( iv_key = 'IdentityCenterEnabledBaselineArn' io_value = /aws1/cl_rt_document=>from_json_str( lv_json ) ). APPEND lo_param TO lt_parameters. ENDIF. " Enable the baseline DATA(lo_output) = io_ctt->enablebaseline( iv_baselineidentifier = iv_baseline_identifier iv_baselineversion = iv_baseline_version iv_targetidentifier = iv_target_identifier it_parameters = lt_parameters ). DATA(lv_operation_id) = lo_output->get_operationidentifier( ). " Wait for operation to complete DATA lv_status TYPE /aws1/cttbaselineopstatus. DO 100 TIMES. lv_status = get_baseline_operation( io_ctt = io_ctt iv_operation_id = lv_operation_id ). DATA(lv_msg) = |Baseline operation status: { lv_status }|. MESSAGE lv_msg TYPE 'I'. IF lv_status = 'SUCCEEDED' OR lv_status = 'FAILED'. EXIT. ENDIF. " Wait 30 seconds WAIT UP TO 30 SECONDS. ENDDO. ov_enabled_baseline_arn = lo_output->get_arn( ). MESSAGE 'Baseline enabled successfully.' TYPE 'I'.
  • For API details, see EnableBaseline in AWS SDK for SAP ABAP API reference.

The following code example shows how to use EnableControl.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

" Enable the control DATA(lo_output) = io_ctt->enablecontrol( iv_controlidentifier = iv_control_arn iv_targetidentifier = iv_target_identifier ). DATA(lv_operation_id) = lo_output->get_operationidentifier( ). " Wait for operation to complete DATA lv_status TYPE /aws1/cttcontrolopstatus. DO 100 TIMES. lv_status = get_control_operation( io_ctt = io_ctt iv_operation_id = lv_operation_id ). DATA(lv_msg) = |Control operation status: { lv_status }|. MESSAGE lv_msg TYPE 'I'. IF lv_status = 'SUCCEEDED' OR lv_status = 'FAILED'. EXIT. ENDIF. " Wait 30 seconds WAIT UP TO 30 SECONDS. ENDDO. ov_operation_id = lv_operation_id. MESSAGE 'Control enabled successfully.' TYPE 'I'.
  • For API details, see EnableControl in AWS SDK for SAP ABAP API reference.

The following code example shows how to use GetBaselineOperation.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

DATA(lo_output) = io_ctt->getbaselineoperation( iv_operationidentifier = iv_operation_id ). ov_status = lo_output->get_baselineoperation( )->get_status( ).

The following code example shows how to use GetControlOperation.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

DATA(lo_output) = io_ctt->getcontroloperation( iv_operationidentifier = iv_operation_id ). ov_status = lo_output->get_controloperation( )->get_status( ).

The following code example shows how to use ListBaselines.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

DATA lt_baselines TYPE /aws1/cl_cttbaselinesummary=>tt_baselines. DATA lv_nexttoken TYPE /aws1/cttstring. " List all baselines using pagination DO. DATA(lo_output) = io_ctt->listbaselines( iv_nexttoken = lv_nexttoken ). APPEND LINES OF lo_output->get_baselines( ) TO lt_baselines. lv_nexttoken = lo_output->get_nexttoken( ). IF lv_nexttoken IS INITIAL. EXIT. ENDIF. ENDDO. ot_baselines = lt_baselines. MESSAGE 'Listed baselines successfully.' TYPE 'I'.
  • For API details, see ListBaselines in AWS SDK for SAP ABAP API reference.

The following code example shows how to use ListEnabledBaselines.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

DATA lt_enabled_baselines TYPE /aws1/cl_cttenbdbaselinesumm=>tt_enabledbaselines. DATA lv_nexttoken TYPE /aws1/cttlstenbdbaselinesnex00. " List all enabled baselines using pagination DO. DATA(lo_output) = io_ctt->listenabledbaselines( iv_nexttoken = lv_nexttoken ). APPEND LINES OF lo_output->get_enabledbaselines( ) TO lt_enabled_baselines. lv_nexttoken = lo_output->get_nexttoken( ). IF lv_nexttoken IS INITIAL. EXIT. ENDIF. ENDDO. ot_enabled_baselines = lt_enabled_baselines. MESSAGE 'Listed enabled baselines successfully.' TYPE 'I'.

The following code example shows how to use ListEnabledControls.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

DATA lt_enabled_controls TYPE /aws1/cl_cttenabledcontrolsumm=>tt_enabledcontrols. DATA lv_nexttoken TYPE /aws1/cttstring. " List all enabled controls using pagination DO. DATA(lo_output) = io_ctt->listenabledcontrols( iv_targetidentifier = iv_target_identifier iv_nexttoken = lv_nexttoken ). APPEND LINES OF lo_output->get_enabledcontrols( ) TO lt_enabled_controls. lv_nexttoken = lo_output->get_nexttoken( ). IF lv_nexttoken IS INITIAL. EXIT. ENDIF. ENDDO. ot_enabled_controls = lt_enabled_controls. MESSAGE 'Listed enabled controls successfully.' TYPE 'I'.

The following code example shows how to use ListLandingZones.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

DATA lt_landing_zones TYPE /aws1/cl_cttlandingzonesummary=>tt_landingzonesummaries. DATA lv_nexttoken TYPE /aws1/cttstring. " List all landing zones using pagination DO. DATA(lo_output) = io_ctt->listlandingzones( iv_nexttoken = lv_nexttoken ). APPEND LINES OF lo_output->get_landingzones( ) TO lt_landing_zones. lv_nexttoken = lo_output->get_nexttoken( ). IF lv_nexttoken IS INITIAL. EXIT. ENDIF. ENDDO. ot_landing_zones = lt_landing_zones. MESSAGE 'Listed landing zones successfully.' TYPE 'I'.

The following code example shows how to use ResetEnabledBaseline.

SDK for SAP ABAP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

" Reset the enabled baseline DATA(lo_output) = io_ctt->resetenabledbaseline( iv_enabledbaselineidentifier = iv_enabled_baseline_identifier ). DATA(lv_operation_id) = lo_output->get_operationidentifier( ). " Wait for operation to complete DATA lv_status TYPE /aws1/cttbaselineopstatus. DO 100 TIMES. lv_status = get_baseline_operation( io_ctt = io_ctt iv_operation_id = lv_operation_id ). DATA(lv_msg) = |Baseline operation status: { lv_status }|. MESSAGE lv_msg TYPE 'I'. IF lv_status = 'SUCCEEDED' OR lv_status = 'FAILED'. EXIT. ENDIF. " Wait 30 seconds WAIT UP TO 30 SECONDS. ENDDO. ov_operation_id = lv_operation_id. MESSAGE 'Baseline reset successfully.' TYPE 'I'.