Secrets Manager 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.

Secrets Manager 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 Secrets Manager.

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 BatchGetSecretValue.

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. " iv_filter_name = 'mySecret' DATA(lo_result) = lo_smr->batchgetsecretvalue( it_filters = VALUE /aws1/cl_smrfilter=>tt_filterslisttype( ( NEW /aws1/cl_smrfilter( iv_key = 'name' it_values = VALUE /aws1/cl_smrfiltvalsstrlist_w=>tt_filtervaluesstringlist( ( NEW /aws1/cl_smrfiltvalsstrlist_w( iv_value = iv_filter_name ) ) ) ) ) ) ). ot_secret_values = lo_result->get_secretvalues( ). MESSAGE 'Secrets retrieved successfully.' TYPE 'I'. CATCH /aws1/cx_smrresourcenotfoundex. MESSAGE 'One or more requested secrets were not found.' TYPE 'E'. CATCH /aws1/cx_smrdecryptionfailure. MESSAGE 'Failed to decrypt one or more secrets.' TYPE 'E'. CATCH /aws1/cx_smrinvalidparameterex. MESSAGE 'Invalid parameter provided.' TYPE 'E'. CATCH /aws1/cx_smrinvalidrequestex. MESSAGE 'Invalid request.' TYPE 'E'. ENDTRY.

The following code example shows how to use GetSecretValue.

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. " iv_secret_name = 'MySecretName' DATA(lo_result) = lo_smr->getsecretvalue( iv_secretid = iv_secret_name ). ov_secret_value = lo_result->get_secretstring( ). MESSAGE 'Secret value retrieved successfully.' TYPE 'I'. CATCH /aws1/cx_smrresourcenotfoundex. MESSAGE 'The requested secret was not found.' TYPE 'E'. CATCH /aws1/cx_smrdecryptionfailure. MESSAGE 'Failed to decrypt the secret.' TYPE 'E'. CATCH /aws1/cx_smrinvalidparameterex. MESSAGE 'Invalid parameter provided.' TYPE 'E'. CATCH /aws1/cx_smrinvalidrequestex. MESSAGE 'Invalid request.' TYPE 'E'. ENDTRY.
  • For API details, see GetSecretValue in AWS SDK for SAP ABAP API reference.