Access control
On chili you decide exactly which application may perform which actions on which bucket. The main tool for this is IAM users with policies, which you manage in the chili Console. For special cases, bucket policies and presigned URLs are available through the S3 API.
The building blocks
Building block | Purpose | Managed in |
|---|---|---|
IAM user | identity of an application, a script or a person | Console, |
Access key | access key and secret key an IAM user signs in with | Console, on the IAM user |
Groups | bundle users with the same tasks | Console, |
Policies | allow or deny S3 actions, in AWS IAM syntax | Console, |
Bucket policy | rules attached to the bucket, for all access to it | S3 API |
ACLs | older way of granting permissions per bucket or object | S3 API |
Presigned URL | time-limited link to a single object | generated locally with an access key |
IAM users are not the people who sign in to the Console. You manage those under Organisation.
Principles
- One IAM user per application: for example
svc-veeamfor Veeam andsvc-nasfor the NAS. If a key is compromised, you block exactly that key without affecting other applications. - Least privilege: each application gets only the actions on the buckets it needs. A new IAM user can do nothing until you assign a policy.
- Deny wins: if a policy denies an action, no allow in another policy overrides it. Use this to set hard limits such as "never delete".
- No delete where it is not needed: for applications that only write, choose the
Read and writelevel. - Keep Object Lock from being bypassed: never give applications the
s3:BypassGovernanceRetentionpermission. See Object Lock.
Access levels in the Console
When you set up access, you choose an access level in the wizard. The Console creates the matching policy.
Level | Permissions | Suited for |
|---|---|---|
Read only | list and download objects | reporting, restore servers, auditors |
Read and write | also upload and overwrite, but not delete | your own applications that only store data |
Read, write and delete | compatible with most applications | NAS systems, rclone, file managers |
Software with Object Lock | write, set retention, delete after the period ends | Veeam and other backup software |
If no level fits, upload a policy in AWS format under Own policy.
Own policy
Policies are JSON documents in AWS IAM syntax. This policy lets an application list, read and write in the bucket reports, but not delete anything:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListBucket",
"Effect": "Allow",
"Action": ["s3:ListBucket", "s3:GetBucketLocation"],
"Resource": "arn:aws:s3:::reports"
},
{
"Sid": "ReadWriteObjects",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::reports/*"
}
]
}Bucket actions such as s3:ListBucket refer to the bucket (arn:aws:s3:::reports), object actions such as s3:GetObject to the objects in it (arn:aws:s3:::reports/*). Assign the policy to an IAM user or a group.
Access keys
- The secret key is shown once: right after it is created. Save it immediately in your password manager or secret store. After that it cannot be retrieved in the Console.
- At most two keys per IAM user: this lets you rotate a key without interruption.
- Never store keys in code: keys do not belong in Git repositories, scripts or tickets. Use environment variables, AWS CLI profiles or a secret store.
- Lost or compromised: delete the key on the IAM user and create a new one.
Rotating a key without interruption
- In the Console, create a second access key on the IAM user.
- Enter the new key in the application.
- Check that the application works with the new key, for example with a test run or a look at its log.
- Delete the old key in the Console.
Rotate keys regularly, and always when a person with access to the keys leaves the team.
Bucket policies
A bucket policy is attached to the bucket and applies to every access to it, regardless of which IAM user makes the request. For most cases, the policies on IAM users are enough. Bucket policies are suited for hard rules that must apply to everyone.
This bucket policy denies everyone the deletion of objects and object versions under the prefix finance/:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NoDeleteFinance",
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:DeleteObject", "s3:DeleteObjectVersion"],
"Resource": "arn:aws:s3:::my-bucket/finance/*"
}
]
}Set, check and remove the bucket policy:
aws s3api put-bucket-policy \
--bucket my-bucket \
--policy file://bucket-policy.json \
--endpoint-url https://s3-ch-east.chilistorage.com
aws s3api get-bucket-policy \
--bucket my-bucket \
--endpoint-url https://s3-ch-east.chilistorage.com
aws s3api delete-bucket-policy \
--bucket my-bucket \
--endpoint-url https://s3-ch-east.chilistorage.comA deny with "Principal": "*" also applies to your own administrator keys. To be able to delete again, remove the bucket policy. If data must be reliably protected from deletion, use Object Lock.
ACLs
Access control lists (ACLs) are the older way of granting permissions in S3, per bucket or per object. chili supports them for applications that depend on them. For new setups, use policies: they are easier to read, can be managed centrally and support an explicit deny.
Presigned URLs: share objects for a limited time
A presigned URL shares a single object for a limited time without handing out access keys. Anyone with the link can download the object until it expires. The URL is signed locally with your access key and carries the same permissions as that key.
aws s3 presign s3://my-bucket/reports/annual-report.pdf \
--expires-in 86400 \
--region ch-east \
--endpoint-url https://s3-ch-east.chilistorage.com--expires-in sets the validity in seconds, here 24 hours. With AWS Signature Version 4, the maximum is 7 days (604800 seconds). Generate presigned URLs with a key that can only read. If you delete the key, every URL generated with it stops working.
Common pitfalls
- `AccessDenied` despite an allow: check whether a deny applies anywhere, including in a bucket policy. Also check the resource:
arn:aws:s3:::bucketfor bucket actions,arn:aws:s3:::bucket/*for objects. - New IAM user cannot do anything: without an assigned policy, an IAM user has no permissions.
- One key for everything: if several applications share a key, you have to switch all of them at once when you rotate it. Create one IAM user per application.
- Presigned URL does not work: check the endpoint, the region
ch-eastand the clock of the machine that generated the URL.
Next
- chili Console: set up IAM users, groups and policies
- S3 API: access: bucket policies, ACLs and presigned URLs in detail
- Security and data location: protective measures at a glance