Prerequisites
- An AWS account where you can create an S3 bucket, an IAM policy, and S3 Lifecycle rules
- Access to the environment variables of your Infisical instances
Step 1: Create the bucket
Create a general purpose S3 bucket for session logs. Directory buckets don’t work. Keep Block all public access turned on, because browsers download session logs through signed links that don’t need public access.Step 2: Add a CORS rule
Browsers download session logs directly from the bucket, so the bucket has to accept requests from your Infisical URL.1
In the Amazon S3 console, open the bucket, go to Permissions, and select Edit under Cross-origin resource sharing (CORS).
2
Paste this rule with your instance’s URL in
AllowedOrigins, then select Save changes:Step 3: Add lifecycle rules
Infisical tags each session log with the retention period of the organization’s plan, asretention=<days>d. The retention period is 30 days unless your license sets a different one. Infisical doesn’t delete files itself: an S3 Lifecycle rule for each tag deletes them.
Add one rule for retention=30d, and one more rule for each other retention period your license uses. If no rule matches a tag, the files with that tag are never deleted.
1
In the Amazon S3 console, open the bucket, go to Management, and select Create lifecycle rule.
2
Enter a Lifecycle rule name, such as
session-logs-30d, and select Limit the scope of this rule using one or more filters.3
Under Object tags, select Add tag, and enter
retention as the key and 30d as the value.4
Under Lifecycle rule actions, select Expire current versions of objects, and enter
30 in Days after object creation.If the bucket has versioning turned on, also select Permanently delete noncurrent versions of objects, or expired session logs stay in the bucket as noncurrent versions.5
Select Create rule.
Step 4: Give Infisical access to the bucket
Infisical stores session logs under<prefix>/ in the bucket, where <prefix> is the optional OBJECT_STORAGE_S3_PREFIX you set in Step 5. Create this IAM policy, with your bucket and prefix in place of the placeholders:
<prefix>/ in both places. Infisical needs s3:PutObjectTagging to add the retention tag to each upload.
Attach the policy to the identity Infisical uses for default storage:
- The role your Infisical instances already run as, such as an EC2 instance profile or an EKS service account role
- An IAM user whose access key you set in Step 5
Step 5: Configure Infisical
Set these environment variables on every Infisical instance, then restart the instances:If your instance runs in FIPS mode, Infisical reaches the bucket through the S3 FIPS endpoint of the bucket’s region, so choose a region that has one.
Check default storage
In an organization on your instance, go to Agent Vault, then Administration > Settings. The Session Logs card shows that session logs are on in default storage. When Infisical starts, it checks that it can list the bucket, write a tagged test file under<prefix>/ and read it back, and that the bucket’s CORS rule allows downloads from your SITE_URL. If a check fails, Infisical logs an error that names the step, such as a missing s3:PutObjectTagging, a missing s3:GetObject or a missing CORS rule. Organizations don’t see this error, so check the Infisical logs after you set up the bucket.