Creating an access key
To use Object Storage via the S3 API you need an access key. Access keys are created in Identity and Access Management using a service account.
Getting started
-
Create a service account in your project:
kubectl create serviceaccount <service_account_name> -n <project_name> -
Assign to the service account the
storage.editorrole for access to buckets:apiVersion: iam.stackland.yandex.cloud/v1alpha1 kind: AccessBinding metadata: name: <service_account_name>-storage-access namespace: <project_name> spec: roleID: storage.editor subject: kind: ServiceAccount name: <service_account_name> namespace: <project_name>Save the manifest to a file named
access-binding.yamland apply it:kubectl apply -f access-binding.yaml -
Create a static access key for the service account:
apiVersion: iam.stackland.yandex.cloud/v1alpha1 kind: APIKey metadata: name: <service_account_name>-s3-key namespace: <project_name> spec: serviceAccountRef: name: <service_account_name> secretName: <service_account_name>-s3-credentialsSave the manifest to a file named
api-key.yamland apply it:kubectl apply -f api-key.yaml -
Get the access key and secret key from the secret you created:
export AWS_ACCESS_KEY_ID=$(kubectl get secret -n <project_name> <service_account_name>-s3-credentials -o jsonpath='{.data.accessKeyId}' | base64 -d) export AWS_SECRET_ACCESS_KEY=$(kubectl get secret -n <project_name> <service_account_name>-s3-credentials -o jsonpath='{.data.secretAccessKey}' | base64 -d) -
Check your connection to Object Storage:
export CLUSTER_DOMAIN=$(kubectl get platformenvironments main -o jsonpath='{.status.clusterDomain}') aws --endpoint-url=https://storage.sys.$CLUSTER_DOMAIN s3 ls
-
If you have not opened a project yet, select one.
-
In the left-hand menu, select Service accounts.
-
Click Create service account.
-
Enter a name for the service account and click Create.
-
Select the new service account.
-
Go to the Access keys tab.
-
Click Create key.
-
Save the Access Key ID and Secret Access Key.
Warning
The secret key is only displayed once. Save it to a secure location.
-
Assign the
storage.editorrole to the service account:- Go to the Access permissions section of your project.
- Click Assign role.
- Select the
storage.editorrole. - Select the new service account as the subject.
- Click Assign.
Available roles
storage.viewer: Allows you to read objects and get a bucket list.storage.editor: Allows you to read, create, edit, and delete objects.storage.admin: Full access to Object Storage, including bucket settings management.
What's next
- Learn more about access management in Object Storage.
- Check out the Identity and Access Management guides.