Skip to content
Docs

This guide creates an Amazon S3 bucket from Kubernetes and gives a Pod access to it.

You describe the bucket with one manifest: S3Bucket. The platform creates the bucket, an IAM user with an access key, an IAM role and policy, and a Kubernetes ServiceAccount set up for IRSA. The access key and bucket details are stored in a Kubernetes Secret and in AWS Secrets Manager. Applications can reach the bucket either through the ServiceAccount (IRSA) or with the access key.

It is good practice to include the manifest in your application’s Helm chart, so the bucket is deployed together with the application that uses it.

S3Bucket is enabled by default. Your Infralib configuration needs:

Module Flag Default What it does
platform-apis platform-apis.s3bucket.install true Installs the S3Bucket API.
crossplane-aws global.createObservers, global.createNamespacedObservers false Installs the Secrets Manager provider that stores the credentials. The S3 and IAM providers are always installed. Set both to true.
aws/kms — — Optional. If the module exists, its data and config KMS keys are used; otherwise AWS-managed keys are used.

For the base modules every platform API needs, see Infralib Requirements.

A minimal S3Bucket needs no settings at all:

apiVersion: storage.entigo.com/v1alpha1
kind: S3Bucket
metadata:
name: example-bucket
spec: {}

This creates an IAM user and a Kubernetes ServiceAccount, both named example-bucket.

Terminal window
kubectl get s3bucket example-bucket -w
Field Default What it does
enableVersioning false Turns on versioning for the bucket.
serviceAccountName metadata.name Name of the Kubernetes ServiceAccount used for IRSA.
createServiceAccount true Creates the ServiceAccount. Set to false to grant access to a ServiceAccount you already have.

For example, to grant access to an existing ServiceAccount example-app-sa instead of creating one:

apiVersion: storage.entigo.com/v1alpha1
kind: S3Bucket
metadata:
name: example-bucket
spec:
createServiceAccount: false
serviceAccountName: example-app-sa
---
# This ServiceAccount must already exist and is not created by the S3Bucket.
apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/example-bucket # This annotation must be added manually.
name: example-app-sa

The ServiceAccount must be in the same namespace as the S3Bucket, and you must add the annotation eks.amazonaws.com/role-arn: arn:aws:iam::<aws-account-number>:role/<metadata.name> yourself.

For every field, see the S3Bucket API reference.

Run the Pod under the bucket’s ServiceAccount. No credentials are mounted:

apiVersion: v1
kind: Pod
metadata:
name: aws-cli
spec:
serviceAccountName: example-bucket
containers:
- name: aws-cli
image: amazon/aws-cli:latest
command: ['sleep', 'infinity']

The IAM access key and bucket details are stored in the Kubernetes Secret and the AWS Secrets Manager secret <metadata.name>-credentials. The Secret has the keys AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, BUCKET_NAME, BUCKET_ARN, BUCKET_REGION and credentials.json, which holds all of them as one JSON document.

Load every key as an environment variable:

apiVersion: v1
kind: Pod
metadata:
name: aws-cli
spec:
containers:
- name: aws-cli
image: amazon/aws-cli:latest
command: ['sleep', 'infinity']
envFrom:
- secretRef:
name: example-bucket-credentials

To pick individual keys, use env with valueFrom.secretKeyRef instead, for example name: example-bucket-credentials and key: BUCKET_NAME.

Or mount credentials.json as a file:

apiVersion: v1
kind: Pod
metadata:
name: aws-cli
spec:
containers:
- name: aws-cli
image: amazon/aws-cli:latest
command: ['sleep', 'infinity']
volumeMounts:
- name: credentials
mountPath: /etc/credentials
readOnly: true
volumes:
- name: credentials
secret:
secretName: example-bucket-credentials
items:
- key: credentials.json
path: credentials.json

For more information about Secrets in Kubernetes, see Kubernetes documentation.

The S3Bucket shows SYNCED and READY as True:

$ kubectl get s3bucket
NAME SYNCED READY COMPOSITION AGE
example-bucket True True s3buckets.storage.entigo.com 1h27m

The bucket appears in the AWS Console:

$ kubectl get secret
NAME TYPE DATA AGE
example-bucket-credentials Opaque 6 1h20m
$ kubectl get secret example-bucket-credentials -o yaml
apiVersion: v1
kind: Secret
metadata:
annotations:
crossplane.io/composition-resource-name: credentials
labels:
crossplane.io/composite: example-bucket
name: example-bucket-credentials
namespace: <namespace>
type: Opaque
data:
AWS_ACCESS_KEY_ID: <base64-encoded-access-key>
AWS_SECRET_ACCESS_KEY: <base64-encoded-secret-access-key>
BUCKET_ARN: <base64-encoded-bucket-arn>
BUCKET_NAME: <base64-encoded-bucket-name>
BUCKET_REGION: <base64-encoded-bucket-region>
credentials.json: <base64-encoded-credentials>

The same credentials are in AWS Secrets Manager:

Terminal window
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
aws-cli 1/1 Running 0 3s
$ kubectl exec -it aws-cli -- sh
/ touch file.txt
/ aws s3 cp file.txt s3://example-bucket/
upload: ./file.txt to s3://example-bucket/file.txt
/ aws s3 ls s3://example-bucket/
2025-12-03 08:42:06 0 file.txt
/ aws s3 cp s3://example-bucket/file.txt downloaded-file.txt
download: s3://example-bucket/file.txt to ./downloaded-file.txt

The Pod can use the bucket with the access key

Section titled “The Pod can use the bucket with the access key”

With the environment variables:

Terminal window
$ kubectl exec -it aws-cli -- sh
/ env
AWS_ACCESS_KEY_ID=AKIAXXXXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BUCKET_ARN=arn:aws:s3:::example-bucket
BUCKET_NAME=example-bucket
BUCKET_REGION=eu-north-1
/ aws s3 cp file.txt s3://example-bucket/
upload: ./file.txt to s3://example-bucket/file.txt
/ aws s3 ls s3://example-bucket/
2025-12-03 08:42:06 0 file.txt
/ aws s3 cp s3://example-bucket/file.txt downloaded-file.txt
download: s3://example-bucket/file.txt to ./downloaded-file.txt

With the mounted file:

Terminal window
$ cat /etc/credentials/credentials.json
{"AWS_ACCESS_KEY_ID": "AKIAXXXXXXXXXXXXXXX", "AWS_SECRET_ACCESS_KEY": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "BUCKET_REGION": "eu-north-1", "BUCKET_ARN": "arn:aws:s3:::example-bucket", "BUCKET_NAME": "example-bucket"}
Symptom Cause / fix
no matches for kind "S3Bucket" The API is not installed. Check the Prerequisites.
SYNCED is False The platform could not create a cloud resource. kubectl describe s3bucket <name> shows the error under Conditions and Events.
The credentials are not in AWS Secrets Manager createObservers and createNamespacedObservers are off on crossplane-aws, so the Secrets Manager provider is not installed. See Prerequisites.
The Pod gets access denied with an existing ServiceAccount With createServiceAccount: false the ServiceAccount must be in the same namespace as the S3Bucket and carry the eks.amazonaws.com/role-arn annotation.

There are no S3-specific defaults for developers to worry about. The one cluster-wide setting that affects buckets is tagging.

Setting Default What it does
tags {} Cloud tags added to every bucket and its IAM resources. See Resource Tagging.
steps:
...
- name: apps
type: argocd-apps
modules:
...
- name: crossplane-aws
source: crossplane-aws
inputs:
global:
createObservers: true
createNamespacedObservers: true
...
- name: platform-apis
source: platform-apis
inputs:
platform-apis:
storage:
environmentConfig:
tags:
cost-center: CC-12345