Skip to content

/AWS1/IF_IAM=>ACQUIREROLE()

About AcquireRole

Creates an IAM role from the specified role template. The new role takes its configuration—including its name, path, trust policy, inline and managed policies, permissions boundary, tags, and maximum session duration—from the role template version that you specify. For more information about roles, see IAM roles in the IAM User Guide.

If the template version defines parameters, use the ReplacementValues parameter to supply the values that the service substitutes into the role during creation.

Method Signature

METHODS /AWS1/IF_IAM~ACQUIREROLE
  IMPORTING
    !IV_TEMPLATEARN TYPE /AWS1/IAMARNTYPE OPTIONAL
    !IV_TEMPLATEMINORVERSION TYPE /AWS1/IAMINTEGERTYPE OPTIONAL
    !IT_REPLACEMENTVALUES TYPE /AWS1/CL_IAMREPLVALUEENTRY=>TT_MAPSTRINGREPLVALUEENTRY OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_iamacquirerolersp
  RAISING
    /AWS1/CX_IAMCONCURRENTMODEX
    /AWS1/CX_IAMENTITYALRDYEXEX
    /AWS1/CX_IAMINVALIDINPUTEX
    /AWS1/CX_IAMLIMITEXCEEDEDEX
    /AWS1/CX_IAMMALFORMEDPLYDOCEX
    /AWS1/CX_IAMNAMECONFLICTEX
    /AWS1/CX_IAMNOSUCHENTITYEX
    /AWS1/CX_IAMROLEMODIFIEDEX
    /AWS1/CX_IAMROLETMPLTDISBLEX
    /AWS1/CX_IAMSERVICEFAILUREEX
    /AWS1/CX_IAMCLIENTEXC
    /AWS1/CX_IAMSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_templatearn TYPE /AWS1/IAMARNTYPE /AWS1/IAMARNTYPE

The Amazon Resource Name (ARN) of the role template to create the role from.

For more information about ARNs, see Amazon Resource Names (ARNs) in the Amazon Web Services General Reference.

Optional arguments:

iv_templateminorversion TYPE /AWS1/IAMINTEGERTYPE /AWS1/IAMINTEGERTYPE

The minor version of the role template to use. If you do not specify a minor version, the service uses the template's default minor version.

it_replacementvalues TYPE /AWS1/CL_IAMREPLVALUEENTRY=>TT_MAPSTRINGREPLVALUEENTRY TT_MAPSTRINGREPLVALUEENTRY

A map of values to substitute for the parameters that are defined in the role template version. Each key is a parameter name from the template, and each value is a structure that contains the replacement values for that parameter.

RETURNING

oo_output TYPE REF TO /aws1/cl_iamacquirerolersp /AWS1/CL_IAMACQUIREROLERSP

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->acquirerole(
  it_replacementvalues = VALUE /aws1/cl_iamreplvalueentry=>tt_mapstringreplvalueentry(
    (
      VALUE /aws1/cl_iamreplvalueentry=>ts_mapstrreplvalueentry_maprow(
        key = |string|
        value = new /aws1/cl_iamreplvalueentry(
          it_values = VALUE /aws1/cl_iamreplvallisttype_w=>tt_replacementvaluelisttype(
            ( new /aws1/cl_iamreplvallisttype_w( |string| ) )
          )
        )
      )
    )
  )
  iv_templatearn = |string|
  iv_templateminorversion = 123
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lo_role = lo_result->get_role( ).
  IF lo_role IS NOT INITIAL.
    lv_pathtype = lo_role->get_path( ).
    lv_rolenametype = lo_role->get_rolename( ).
    lv_idtype = lo_role->get_roleid( ).
    lv_arntype = lo_role->get_arn( ).
    lv_datetype = lo_role->get_createdate( ).
    lv_policydocumenttype = lo_role->get_assumerolepolicydocument( ).
    lv_roledescriptiontype = lo_role->get_description( ).
    lv_rolemaxsessiondurationt = lo_role->get_maxsessionduration( ).
    lo_attachedpermissionsboun = lo_role->get_permissionsboundary( ).
    IF lo_attachedpermissionsboun IS NOT INITIAL.
      lv_permissionsboundaryatta = lo_attachedpermissionsboun->get_permissionsboundarytype( ).
      lv_arntype = lo_attachedpermissionsboun->get_permissionsboundaryarn( ).
    ENDIF.
    LOOP AT lo_role->get_tags( ) into lo_row.
      lo_row_1 = lo_row.
      IF lo_row_1 IS NOT INITIAL.
        lv_tagkeytype = lo_row_1->get_key( ).
        lv_tagvaluetype = lo_row_1->get_value( ).
      ENDIF.
    ENDLOOP.
    lo_rolelastused = lo_role->get_rolelastused( ).
    IF lo_rolelastused IS NOT INITIAL.
      lv_datetype = lo_rolelastused->get_lastuseddate( ).
      lv_stringtype = lo_rolelastused->get_region( ).
    ENDIF.
    lo_sourceroletemplate = lo_role->get_sourceroletemplate( ).
    IF lo_sourceroletemplate IS NOT INITIAL.
      lv_arntype = lo_sourceroletemplate->get_templatearn( ).
      lv_integertype = lo_sourceroletemplate->get_templateminorversion( ).
    ENDIF.
  ENDIF.
ENDIF.