Skip to content

get_data_access async

get_data_access(
    account_id: AccountId,
    target: S3Prefix,
    permission: Permission,
    *,
    config_overrides: Optional[AsyncS3ControlClientConfig] = None,
    duration_seconds: Optional[DurationSeconds] = None,
    privilege: Optional[Privilege] = None,
    target_type: Optional[S3PrefixType] = None,
    audit_context: Optional[AuditContext] = 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.

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.

Raises:

Source code in docs_src/capo_s3_control/_services/async_s3_control.py
async 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[AsyncS3ControlClientConfig] = 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,
) -> "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. </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>

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

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

        (
            output,
            http_response,
        ) = await capo_s3_control._operations.awss3_control_service_v20180820.get_data_access.async_get_data_access(
            req.options, req.input
        )
        return AsyncOperationResponse(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

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output