Skip to content
Docs

Drain Audit Logs to S3

Audit Log Drains are available on Enterprise plans

Audit Log Drains can write team activity events directly to your Amazon S3 bucket. Use this setup when you want audit logs stored in your AWS account for security archives, compliance retention, or downstream analysis.

Vercel writes to S3 by assuming an AWS Identity and Access Management (IAM) role in your AWS account with AWS Security Token Service (AWS STS). You keep ownership of the bucket and grant Vercel write access only to the bucket path you configure.

Follow the steps below to create the IAM role, attach write permissions, configure the drain, and run a test delivery. After setup, use Configuration reference for field values, File structure for S3 object paths, and Advanced options for encryption and object ACL settings.

Before you configure the drain, make sure you have:

  • Access to create or update an S3 bucket, IAM role, and IAM policy
  • Access to view the S3 bucket default encryption and Object Ownership settings
  • Access to update the AWS Key Management Service (AWS KMS) key policy if your bucket uses a customer managed AWS KMS key
  • The full KMS key ARN, if the bucket uses SSE-KMS or DSSE-KMS with a customer managed key
  • An S3 bucket and optional prefix for audit log objects
  • The AWS region where the bucket is located
  • Your Vercel team ID
  • The Vercel S3 drain writer role ARN: arn:aws:iam::977805900156:role/vercel-drains-s3-writer

The S3 bucket and IAM role must be in the same AWS account. The KMS key can be in another AWS account.

  1. Create an IAM role in the same AWS account as the bucket. In AWS IAM, select Custom trust policy as the trusted entity type.

    Use this IAM role ARN as the roleArn value in Vercel. Attach the permissions for your S3 encryption mode to the same IAM role.

    The IAM role trust policy must allow the Vercel S3 drain writer role to call sts:AssumeRole and must require the external ID for your Vercel team.

    Replace:

    • <your-team-id> with your Vercel team ID, for example team_123
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "AWS": "arn:aws:iam::977805900156:role/vercel-drains-s3-writer"
          },
          "Action": "sts:AssumeRole",
          "Condition": {
            "StringEquals": {
              "sts:ExternalId": "vercel-team:<your-team-id>"
            }
          }
        }
      ]
    }

    The external ID ties the role to one Vercel team and helps prevent the confused deputy problem. Use the exact vercel-team:<your-team-id> value. Do not use wildcard values such as vercel-team:*, because they can allow other Vercel teams to use the role ARN.

    The setup uses two IAM role ARNs:

    RoleOwnerWhere to use it
    Vercel S3 drain writer roleVercelPrincipal in your IAM role trust policy
    Your IAM roleYour AWS accountroleArn in Vercel and identity-based permissions
  2. Attach an identity-based IAM permissions policy to your IAM role. Choose the policy that matches your bucket encryption setup.

    Both permission options use the following S3 resource mapping. Scope the S3 resource to the exact bucket or prefix in the endpoint.

    Vercel endpointIAM policy Resource
    s3://<bucket-name>arn:aws:s3:::<bucket-name>/*
    s3://<bucket-name>/audit-logsarn:aws:s3:::<bucket-name>/audit-logs/*

    Test deliveries write objects under _test/. If the endpoint is s3://<bucket-name>, your IAM role must allow s3:PutObject on arn:aws:s3:::<bucket-name>/* so test and production objects can be written.

    If you set Object ACL in Vercel, add s3:PutObjectAcl to the same S3 statement. Amazon S3 requires s3:PutObjectAcl when a PutObject request includes an ACL header.

    Use this option when the bucket uses SSE-S3, or SSE-KMS with the AWS managed aws/s3 key. For SSE-KMS with aws/s3, leave KMS key ARN empty.

    The following example allows writes to s3://<bucket-name>/audit-logs:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "AllowS3Writes",
          "Effect": "Allow",
          "Action": [
            "s3:PutObject",
            // Include when Object ACL is set in the drain configuration.
            "s3:PutObjectAcl"
          ],
          "Resource": "arn:aws:s3:::<bucket-name>/audit-logs/*"
        }
      ]
    }

    Use this option when the bucket uses SSE-KMS or DSSE-KMS with an AWS KMS key that you manage. This includes buckets whose default encryption uses a customer managed AWS KMS key. Set kmsKeyId to that key's full ARN. Without kmsKeyId, S3 encrypts objects with the AWS managed aws/s3 key, not the bucket default key.

    The identity-based IAM policy must allow s3:PutObject on the destination path and kms:GenerateDataKey on the KMS key ARN. kms:CallerAccount is the account in roleArn, not the account in the key ARN. The key can be in another AWS account.

    The following example allows writes to s3://<bucket-name>/audit-logs with a customer managed AWS KMS key in <aws-region>:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "AllowS3Writes",
          "Effect": "Allow",
          "Action": [
            "s3:PutObject",
            // Include when Object ACL is set in the drain configuration.
            "s3:PutObjectAcl"
          ],
          "Resource": "arn:aws:s3:::<bucket-name>/audit-logs/*"
        },
        {
          "Sid": "AllowKmsForS3Writes",
          "Effect": "Allow",
          "Action": "kms:GenerateDataKey",
          "Resource": "arn:aws:kms:<aws-region>:<key-account-id>:key/<kms-key-id>",
          "Condition": {
            "StringEquals": {
              "kms:CallerAccount": "<role-account-id>",
              "kms:ViaService": "s3.<aws-region>.amazonaws.com"
            }
          }
        }
      ]
    }

    Add this statement to the key policy for the key in kmsKeyId. Edit that policy in the AWS account that owns the key. That account can differ from the bucket account. kms:CallerAccount stays the account in roleArn. Keep your existing key administration statements:

    {
      "Sid": "AllowVercelDrainRoleToUseKeyViaS3",
      "Effect": "Allow",
      "Principal": {
        "AWS": "<your-iam-role-arn>"
      },
      "Action": "kms:GenerateDataKey",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "kms:CallerAccount": "<role-account-id>",
          "kms:ViaService": "s3.<aws-region>.amazonaws.com"
        }
      }
    }

    Unless you set Object ACL, Vercel does not need s3:PutObjectAcl, s3:GetObject, s3:ListBucket, s3:DeleteObject, or s3:GetBucketLocation.

  3. In Vercel, create an Audit Log drain and choose S3 Bucket as the destination.

    Enter endpoint, encoding, roleArn, and region. Keep Compression set to none unless you want gzip objects. See Compression. Leave Advanced Options off unless your bucket configuration requires extra S3 headers. Set Encryption only when the bucket default encryption is SSE-KMS or DSSE-KMS. For SSE-KMS or DSSE-KMS with a customer managed key, enter the full key ARN in KMS key ARN. Without it, S3 encrypts with the AWS managed aws/s3 key, not the bucket default key. Set Object ACL only when the bucket requires a canned ACL for object uploads. See Advanced options.

  4. Run a test delivery from the Drains page to verify the IAM role, external ID, region, and object write permissions.

    If a test delivery fails, Vercel shows the complete AWS response, including the AWS request ID when AWS returns one. Use the request ID and test timestamp to find the failed request in AWS CloudTrail and debug permission errors.

Vercel does not manage lifecycle policies for your S3 bucket. Configure S3 lifecycle rules, retention, and storage class transitions in AWS based on your compliance and cost requirements.

The S3 destination setup accepts the following values. Advanced options are optional.

FieldDescriptionExample
endpointS3 bucket path where Vercel writes audit logss3://<bucket-name>/audit-logs
encodingObject body formatjson or ndjson
compressionObject compressionnone or gzip
roleArnIAM role ARN Vercel assumes to write objectsarn:aws:iam::<your-aws-account-id>:role/vercel-drain-writer
regionAWS region where the S3 bucket is located<aws-region>
serverSideEncryptionAdvanced option for SSE-KMS or DSSE-KMS bucketsaws:kms or aws:kms:dsse
kmsKeyIdFull KMS key ARN for SSE-KMS or DSSE-KMSarn:aws:kms:<aws-region>:<key-account-id>:key/<kms-key-id>
objectAclAdvanced option for buckets that require an ACLbucket-owner-full-control

Create or choose an S3 bucket in AWS, then decide whether Audit Log Drain objects should be written at the bucket root or under a prefix.

Use one of these endpoint formats:

s3://<bucket-name>
s3://<bucket-name>/audit-logs

Set region to the AWS region where the bucket is located. Vercel writes all Audit Log Drain objects to that bucket.

Choose json to write each audit log event as a JSON object. Choose ndjson to write each audit log event as a newline-delimited JSON object.

Audit Log drains use none by default. Vercel writes uncompressed objects.

Choose gzip to write gzip-compressed objects. Vercel adds .gz to the object key and sets Content-Encoding: gzip on the object.

If you change compression on an existing drain, new object keys change. Update S3 event notifications, lifecycle rules, and other tools that filter on .json or .jsonl.

S3 object bodies use the Audit Log Drains schema.

For encoding set to json, Vercel writes compact JSON. For encoding set to ndjson, Vercel writes newline-delimited JSON.

Vercel uses Hive-style partition paths so analytics and archive tools can query audit logs by schema, version, and event date.

With the endpoint s3://<bucket-name>/audit-logs, normal objects use this key shape:

audit-logs/schema=audit_log/version=v1/year=YYYY/month=MM/day=DD/{timestamp}_{id}.json

Test objects use this key shape:

audit-logs/_test/schema=audit_log/version=v1/year=YYYY/month=MM/day=DD/{timestamp}_{id}.json

Test deliveries use a separate _test/ directory so validation files stay separate from delivered audit log events. You can identify and delete test files without changing the production endpoint or IAM permissions.

Amazon Athena, Apache Hive, Trino, and Apache Spark skip directories that start with an underscore when they read a table location. A table located at the endpoint path doesn't return test objects in these query engines. AWS doesn't document this behavior for AWS Glue crawlers. If an AWS Glue crawler includes the endpoint path, add the exclude pattern _test/** to the crawler.

Test deliveries previously wrote objects under test/. Vercel can't delete objects in your bucket, so delete the test/ directory when you no longer need it. If an IAM policy or S3 lifecycle rule names test/, update it to _test/.

year, month, day, and {timestamp} are UTC values from the event timestamp. {id} is the audit log event ID. NDJSON objects use the .jsonl extension. With compression set to gzip, keys end in .json.gz or .jsonl.gz.

Advanced options map to optional Amazon S3 PutObject headers. Leave them unset unless your bucket configuration requires Vercel to send those headers.

Amazon S3 encrypts new objects with SSE-S3 by default. For more information, see Amazon S3 default encryption.

For buckets that use the default SSE-S3 encryption, don't set Encryption. Set Encryption only when the bucket uses SSE-KMS or DSSE-KMS.

Choose the serverSideEncryption value that matches the bucket default encryption:

S3 bucket default encryptionVercel serverSideEncryption
Server-side encryption with Amazon S3 managed keys (SSE-S3)AES256
Server-side encryption with AWS KMS keys (SSE-KMS)aws:kms
Dual-layer server-side encryption with AWS KMS keys (DSSE-KMS)aws:kms:dsse

For SSE-KMS or DSSE-KMS with a customer managed key, set kmsKeyId to the full KMS key ARN, such as arn:aws:kms:<aws-region>:<key-account-id>:key/1234abcd-12ab-34cd-56ef-1234567890ab. The key ID at the end of the ARN is either a UUID or a multi-Region key ID that starts with mrk-. Alias ARNs (alias/<alias-name>) and bare key IDs aren't accepted. Match the key region to region, and match the key partition to roleArn. The key account can differ from the role account. Without kmsKeyId, S3 encrypts objects with the AWS managed aws/s3 key, not the bucket default key. Add the IAM and key policy permissions above when the key is customer managed.

S3 Bucket Keys are not supported for DSSE-KMS. DSSE-KMS can also increase AWS KMS request costs compared to SSE-KMS.

For buckets that use the default Object Ownership setting, leave Object ACL set to None. Amazon S3 disables ACLs by default for new buckets and uses policies for access control. For more information, see Amazon S3 Object Ownership.

Set Object ACL only when your bucket configuration requires a canned ACL on object uploads. If you set Object ACL, add s3:PutObjectAcl to the IAM permissions policy for the same S3 resource.

If the drain test fails with an STS error, check that your IAM role trust policy uses the Vercel S3 drain writer role ARN arn:aws:iam::977805900156:role/vercel-drains-s3-writer and the sts:ExternalId value vercel-team:<your-team-id>.

If the drain test fails with an S3 AccessDenied error that says no identity-based policy allows s3:PutObject, check that the S3 permissions policy is attached to the same IAM role used as roleArn in Vercel. Also check that the policy resource matches the configured endpoint.

If the drain test fails for an endpoint without a prefix, such as s3://<bucket-name>, check that the S3 permissions policy allows arn:aws:s3:::<bucket-name>/*. Test deliveries write under _test/, so policies scoped only to another prefix won't match test objects.

If objects are encrypted with the AWS managed aws/s3 key, set kmsKeyId. S3 uses aws/s3 when the drain sends SSE-KMS or DSSE-KMS without a key ARN. S3 does not use the bucket default key in that case.

If saving or testing the drain fails with S3 delivery KMS key ID requires aws:kms or aws:kms:dsse encryption, set Encryption to SSE-KMS or DSSE-KMS. Vercel treats a kmsKeyId sent without serverSideEncryption as SSE-S3, which doesn't use a KMS key.

If saving or testing the drain fails with Invalid S3 delivery KMS key ID, check that kmsKeyId is a full KMS key ARN with a UUID or mrk- key ID. Also check that the key region matches region and the key partition matches roleArn.

If the drain test fails with an AWS KMS error for a customer managed AWS KMS key, check kmsKeyId, the IAM role policy, and the key policy. Resource in the IAM policy must be the key ARN. kms:CallerAccount must be the role account. If the key is in another account, add the key policy statement in that account.

Last updated June 29, 2026

Was this helpful?

supported.