Skip to content

get_data_access

get_data_access(
    account_id: AccountId,
    target: S3Prefix,
    permission: Permission,
    *,
    config_overrides: Optional[S3ControlClientConfig] = None,
    duration_seconds: Optional[DurationSeconds] = None,
    privilege: Optional[Privilege] = None,
    target_type: Optional[S3PrefixType] = None,
    audit_context: Optional[AuditContext] = None,
    instance_scope: Optional[InstanceScope] = None,
) -> GetDataAccessResult

Returns a temporary access credential from S3 Access Grants to the grantee or client application. The temporary credential is an Amazon Web Services STS token that grants them access to the S3 data. By default, S3 Access Grants searches for a matching grant in the instance of the Amazon Web Services account ID in the request. To also search instances shared with the caller through Amazon Web Services Resource Access Manager (RAM), set the InstanceScope parameter to ALL.

S3 Access Grants considers every identity in a request when it matches grants. It matches grants for the IAM role used for the session, the directory user, and the user's groups. For users who sign in through IAM federation, it also matches grants for the user's attributes. A user's grants can use the user's name or IAM Identity Center ID, and S3 Access Grants matches both. A group's grants can use the group's display name or ID, and S3 Access Grants matches both. Group grants and grants that use an IAM Identity Center ID match federated users only when your IAM identity provider is configured for group-based access.

If more than one grant matches, S3 Access Grants returns credentials for the grant whose location most closely matches the requested target. If two grants match the target equally closely, a user grant takes priority over a group grant. A group grant takes priority over an attribute grant, and an attribute grant over an IAM grant.

In some cases, S3 Access Grants looks up the user in IAM Identity Center. This happens when your IAM identity provider is configured for group-based access, or when your IAM Identity Center instance uses the simplified experience. If S3 Access Grants can't find the user, it denies the request. No grant applies, including grants for the IAM role. Each user needs an IAM Identity Center username that matches their subject.

Permissions

You must have the s3:GetDataAccess permission to use this operation.

Additional Permissions

The IAM role that S3 Access Grants assumes must have the following permissions specified in the trust policy when registering the location: sts:AssumeRole, for directory users or groups sts:SetContext, and for IAM users or roles sts:SetSourceIdentity.

Parameters:

  • account_id (AccountId) –

    The Amazon Web Services account ID of the S3 Access Grants instance.

  • target (S3Prefix) –

    The S3 URI path of the data to which you are requesting temporary access credentials. If the requesting account has an access grant for this data, S3 Access Grants vends temporary access credentials in the response.

  • permission (Permission) –

    The type of permission granted to your S3 data, which can be set to one of the following values:

    • READ – Grant read-only access to the S3 data.

    • WRITE – Grant write-only access to the S3 data.

    • READWRITE – Grant both read and write access to the S3 data.

  • duration_seconds (Optional[DurationSeconds], default: None ) –

    The session duration, in seconds, of the temporary access credential that S3 Access Grants vends to the grantee or client application. The default value is 1 hour, but the grantee can specify a range from 900 seconds (15 minutes) up to 43200 seconds (12 hours). If the grantee requests a value higher than this maximum, the operation fails.

  • privilege (Optional[Privilege], default: None ) –

    The scope of the temporary access credential that S3 Access Grants vends to the grantee or client application.

    • Default – The scope of the returned temporary access token is the scope of the grant that is closest to the target scope.

    • Minimal – The scope of the returned temporary access token is the same as the requested target scope as long as the requested scope is the same as or a subset of the grant scope.

  • target_type (Optional[S3PrefixType], default: None ) –

    The type of Target. The only possible value is Object. Pass this value if the target data that you would like to access is a path to an object. Do not pass this value if the target data is a bucket or a bucket and a prefix.

  • audit_context (Optional[AuditContext], default: None ) –

    The context to identify the job or query associated with the credential request. This information will be displayed in CloudTrail log in your account.

  • instance_scope (Optional[InstanceScope], default: None ) –

    The scope of S3 Access Grants instances to search for a grant matching the requested S3 URI path.

    • SELF – Searches only the instance of the Amazon Web Services account ID in the request.

    • ALL – Searches the instance of the Amazon Web Services account ID in the request and all instances shared with the caller's account through Amazon Web Services Resource Access Manager (RAM).

Raises:

Source code in docs_src/capo_s3_control/_services/s3_control.py
def get_data_access(
    self,
    account_id: "capo_s3_control.types.account_id.AccountId",
    target: "capo_s3_control.types.s3_prefix.S3Prefix",
    permission: "capo_s3_control.types.permission.Permission",
    *,
    config_overrides: Optional[S3ControlClientConfig] = None,
    duration_seconds: Optional[
        "capo_s3_control.types.duration_seconds.DurationSeconds"
    ] = None,
    privilege: Optional["capo_s3_control.types.privilege.Privilege"] = None,
    target_type: Optional[
        "capo_s3_control.types.s3_prefix_type.S3PrefixType"
    ] = None,
    audit_context: Optional[
        "capo_s3_control.types.audit_context.AuditContext"
    ] = None,
    instance_scope: Optional[
        "capo_s3_control.types.instance_scope.InstanceScope"
    ] = None,
) -> "capo_s3_control.types.get_data_access_result.GetDataAccessResult":
    """<p>Returns a temporary access credential from S3 Access Grants to the grantee or client application. The <a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_Credentials.html">temporary credential</a> is an Amazon Web Services STS token that grants them access to the S3 data. By default, S3 Access Grants searches for a matching grant in the instance of the Amazon Web Services account ID in the request. To also search instances shared with the caller through Amazon Web Services Resource Access Manager (RAM), set the <code>InstanceScope</code> parameter to <code>ALL</code>.</p> <p>S3 Access Grants considers every identity in a request when it matches grants. It matches grants for the IAM role used for the session, the directory user, and the user's groups. For users who sign in through IAM federation, it also matches grants for the user's attributes. A user's grants can use the user's name or IAM Identity Center ID, and S3 Access Grants matches both. A group's grants can use the group's display name or ID, and S3 Access Grants matches both. Group grants and grants that use an IAM Identity Center ID match federated users only when your IAM identity provider is configured for <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_tip_federation_configure_group_access.html">group-based access</a>.</p> <p>If more than one grant matches, S3 Access Grants returns credentials for the grant whose location most closely matches the requested target. If two grants match the target equally closely, a user grant takes priority over a group grant. A group grant takes priority over an attribute grant, and an attribute grant over an IAM grant.</p> <p>In some cases, S3 Access Grants looks up the user in IAM Identity Center. This happens when your IAM identity provider is configured for group-based access, or when your IAM Identity Center instance uses the simplified experience. If S3 Access Grants can't find the user, it denies the request. No grant applies, including grants for the IAM role. Each user needs an IAM Identity Center username that matches their subject.</p> <dl> <dt>Permissions</dt> <dd> <p>You must have the <code>s3:GetDataAccess</code> permission to use this operation. </p> </dd> <dt>Additional Permissions</dt> <dd> <p>The IAM role that S3 Access Grants assumes must have the following permissions specified in the trust policy when registering the location: <code>sts:AssumeRole</code>, for directory users or groups <code>sts:SetContext</code>, and for IAM users or roles <code>sts:SetSourceIdentity</code>. </p> </dd> </dl>

    Args:
        account_id: <p>The Amazon Web Services account ID of the S3 Access Grants instance.</p>
        target: <p>The S3 URI path of the data to which you are requesting temporary access credentials. If the requesting account has an access grant for this data, S3 Access Grants vends temporary access credentials in the response.</p>
        permission: <p>The type of permission granted to your S3 data, which can be set to one of the following values:</p> <ul> <li> <p> <code>READ</code> – Grant read-only access to the S3 data.</p> </li> <li> <p> <code>WRITE</code> – Grant write-only access to the S3 data.</p> </li> <li> <p> <code>READWRITE</code> – Grant both read and write access to the S3 data.</p> </li> </ul>
        duration_seconds: <p>The session duration, in seconds, of the temporary access credential that S3 Access Grants vends to the grantee or client application. The default value is 1 hour, but the grantee can specify a range from 900 seconds (15 minutes) up to 43200 seconds (12 hours). If the grantee requests a value higher than this maximum, the operation fails. </p>
        privilege: <p>The scope of the temporary access credential that S3 Access Grants vends to the grantee or client application. </p> <ul> <li> <p> <code>Default</code> – The scope of the returned temporary access token is the scope of the grant that is closest to the target scope.</p> </li> <li> <p> <code>Minimal</code> – The scope of the returned temporary access token is the same as the requested target scope as long as the requested scope is the same as or a subset of the grant scope. </p> </li> </ul>
        target_type: <p>The type of <code>Target</code>. The only possible value is <code>Object</code>. Pass this value if the target data that you would like to access is a path to an object. Do not pass this value if the target data is a bucket or a bucket and a prefix. </p>
        audit_context: <p>The context to identify the job or query associated with the credential request. This information will be displayed in CloudTrail log in your account.</p>
        instance_scope: <p>The scope of S3 Access Grants instances to search for a grant matching the requested S3 URI path.</p> <ul> <li> <p> <code>SELF</code> – Searches only the instance of the Amazon Web Services account ID in the request.</p> </li> <li> <p> <code>ALL</code> – Searches the instance of the Amazon Web Services account ID in the request and all instances shared with the caller's account through Amazon Web Services Resource Access Manager (RAM).</p> </li> </ul>

    Raises:
        capo_s3_control.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_s3_control.types.get_data_access_request.GetDataAccessRequest]",
    ) -> OperationResponse[
        "capo_s3_control.types.get_data_access_result.GetDataAccessResult"
    ]:
        import capo_s3_control._operations.awss3_control_service_v20180820.get_data_access

        output, http_response = (
            capo_s3_control._operations.awss3_control_service_v20180820.get_data_access.get_data_access(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_s3_control.types.get_data_access_result.GetDataAccessResult",
    ) -> dict[str, Any]:
        import capo_s3_control.types.get_data_access_result

        return capo_s3_control.types.get_data_access_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetDataAccess", redact_output=_redact_output),
    )
    input_: capo_s3_control.types.get_data_access_request.GetDataAccessRequest = {
        "account_id": account_id,
        "target": target,
        "permission": permission,
    }
    if duration_seconds is not None:
        input_["duration_seconds"] = duration_seconds
    if privilege is not None:
        input_["privilege"] = privilege
    if target_type is not None:
        input_["target_type"] = target_type
    if audit_context is not None:
        input_["audit_context"] = audit_context
    if instance_scope is not None:
        input_["instance_scope"] = instance_scope

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output