

# Identity propagation with DuckDB

When you submit a query with `StartQueryExecution` on DuckDB, Amazon Athena authenticates and authorizes the request with your credentials and your IAM permissions. Athena then carries your identity with the query so that the engine can run it on your behalf. This topic explains how your identity is carried with a query and what you can audit in AWS CloudTrail for the work that the engine performs.

During preview, Amazon Athena, powered by DuckDB does not support tables whose Amazon S3 location is registered with AWS Lake Formation, whether the principal has full-table or fine-grained access. Because it does not support fine-grained access control, you can't use your identity to make row-level, column-level, or cell-level access decisions. For more information, see [Considerations and limitations](duckdb-considerations-limitations.md).

## How your identity is carried with a query
<a name="security-duck-identity-propagation-how"></a>

When you run a query on DuckDB, your identity is carried from your request to the calls that the engine makes to other services:

1. You submit a query with `StartQueryExecution` using your credentials. Athena authenticates and authorizes the request with those credentials and your IAM permissions.

1. Athena carries your identity context with the query so that the engine can act on your behalf.

1. The calls that the engine makes on your behalf carry that identity context, such as reading table metadata from the AWS Glue Data Catalog, reading and writing data and results in Amazon S3, and decrypting with an AWS KMS key.

## What you can audit in AWS CloudTrail
<a name="security-duck-identity-propagation-audit"></a>

AWS CloudTrail can record trusted identity propagation (TIP) context for AWS Glue, Amazon S3, AWS KMS, and Athena. For more information, see [AWS services that support TIP](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_tip_services.html) in the *IAM User Guide*.

When your credentials carry an identity context, the calls that the engine makes on your behalf are recorded in CloudTrail with your identity in the `userIdentity.onBehalfOf` element. This includes the engine's calls to the AWS Glue Data Catalog to read table metadata, to Amazon S3 to read and write data and results, and to AWS KMS to decrypt.

The following example shows the engine's AWS Glue `GetTable` call for a user who signs in through IAM Identity Center. In this event, the role session is the principal, Athena is in the `invokedBy` field, and your identity is in the `onBehalfOf` element.

```json
{
  "eventSource": "glue.amazonaws.com",
  "eventName": "GetTable",
  "userIdentity": {
    "type": "AssumedRole",
    "arn": "arn:aws:sts::111122223333:assumed-role/ExampleRole/example-user-session",
    "accountId": "111122223333",
    "sessionContext": {
      "sessionIssuer": {
        "type": "Role",
        "arn": "arn:aws:iam::111122223333:role/ExampleRole",
        "userName": "ExampleRole"
      }
    },
    "invokedBy": "athena.amazonaws.com",
    "onBehalfOf": {
      "userId": "EXAMPLE-USER-ID",
      "identityStoreArn": "arn:aws:identitystore::111122223333:identitystore/d-1234567890",
      "identityCenterInstanceArn": "arn:aws:sso:::instance/ssoins-1234567890abcdef",
      "subject": "example-user",
      "subjectType": "user",
      "issuer": "arn:aws:sso:::instance/ssoins-1234567890abcdef"
    }
  },
  "requestParameters": {
    "catalogId": "111122223333",
    "databaseName": "example_db",
    "name": "example_table"
  }
}
```

The same call made with a credential that carries no identity context, for example a plain role session, has no `onBehalfOf` element.

The identity context fields that CloudTrail records depend on the identity source. For more information, see [Logging TIP activity with AWS CloudTrail](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_tip_cloudtrail.html) in the *IAM User Guide*.

**Note**  
CloudTrail records Amazon S3 object reads (the `GetObject` action) only if you enable Amazon S3 data events. CloudTrail does not record every action that the engine performs by default.

## Identity sources
<a name="security-duck-identity-propagation-identity-sources"></a>

DuckDB carries the identity context that your credentials already hold, from either identity source: IAM federation (SAML or OIDC) or IAM Identity Center. For more information, see [Trusted identity propagation for IAM federation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_tip_federation.html) in the *IAM User Guide* and [Trusted identity propagation overview](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overview.html) in the *AWS IAM Identity Center User Guide*.

## Considerations and limitations
<a name="security-duck-identity-propagation-considerations"></a>

For the considerations and limitations of DuckDB, see [Considerations and limitations](duckdb-considerations-limitations.md).

## Related topics
<a name="security-duck-identity-propagation-related"></a>
+ [Log Amazon Athena API calls with AWS CloudTrail](monitor-with-cloudtrail.md)