<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.stoney-cloud.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sst-la1</id>
	<title>MediaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stoney-cloud.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sst-la1"/>
	<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/wiki/Special:Contributions/Sst-la1"/>
	<updated>2026-04-27T11:16:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=880</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=880"/>
		<updated>2025-03-06T09:01:04Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
{{Note|title=Information|content=Unfortunately, ec2 credentials can not be managed via the graphical OpenStack dashboard as of this moment.}}&lt;br /&gt;
&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=879</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=879"/>
		<updated>2025-03-06T09:00:49Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=878</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=878"/>
		<updated>2025-03-06T08:59:59Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
{{Note|title=Information|content=Unfortunately, ec2 credentials can not be created via the graphical OpenStack dashboard as of this moment.}}&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=877</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=877"/>
		<updated>2025-03-06T08:59:42Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
{{Note|title=Information|content=Unfortunately, ec2 credentials can not be created via the graphical OpenStack Dashboard as of this moment.}}&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=876</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=876"/>
		<updated>2025-03-06T08:59:33Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
{{Note|title=Information:|content=Unfortunately, ec2 credentials can not be created via the graphical OpenStack Dashboard as of this moment.}}&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=875</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=875"/>
		<updated>2025-03-06T08:59:10Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
{{Note|title=Information|content=Unfortunately, ec2 credentials can not be created via the graphical OpenStack Dashboard as of this moment.}}&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=874</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=874"/>
		<updated>2025-03-06T08:58:39Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
{{Note|title=Info|content=Unfortunately, ec2 credentials can not be created via the graphical OpenStack Dashboard as of this moment.}}&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=873</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=873"/>
		<updated>2025-03-06T08:55:51Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=872</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=872"/>
		<updated>2025-03-06T08:37:06Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Credential pair - Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Openstack-CLI =&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=852</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=852"/>
		<updated>2024-12-24T10:36:14Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=851</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=851"/>
		<updated>2024-12-24T10:35:47Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After doing that, enter a name that isn&#039;t taken yet, press &amp;lt;code&amp;gt;Public&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Not public&amp;lt;/code&amp;gt; and submit. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The s3-bucket has been created successfully if it shows up in the list of s3-buckets. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There you also have the possibility to create new folders and upload files within that s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=850</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=850"/>
		<updated>2024-12-24T10:32:36Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt; and press &amp;lt;code&amp;gt;+ Container&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=849</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=849"/>
		<updated>2024-12-24T10:31:59Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
First go to &amp;lt;code&amp;gt;Object Store -&amp;gt; Containers&amp;lt;/code&amp;gt;: &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=848</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=848"/>
		<updated>2024-12-24T10:31:02Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=847</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=847"/>
		<updated>2024-12-24T10:30:43Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=846</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=846"/>
		<updated>2024-12-24T10:30:20Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=845</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=845"/>
		<updated>2024-12-24T10:23:26Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=844</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=844"/>
		<updated>2024-12-24T10:23:10Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=843</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=843"/>
		<updated>2024-12-24T10:22:57Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
[[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=842</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=842"/>
		<updated>2024-12-24T10:22:27Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To create a new s3-bucket using the OpenStack dashboard, follow this section.&lt;br /&gt;
[[File:S3-buckets - Lifecycle Create bucket 01|thumb]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=841</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=841"/>
		<updated>2024-12-24T10:21:06Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To create a new s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To create a new s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=840</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=840"/>
		<updated>2024-12-24T10:19:52Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| OpenStack Dashboard =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=File:S3-buckets_-_Lifecycle_Create_bucket_03.png&amp;diff=839</id>
		<title>File:S3-buckets - Lifecycle Create bucket 03.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=File:S3-buckets_-_Lifecycle_Create_bucket_03.png&amp;diff=839"/>
		<updated>2024-12-24T10:19:14Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=File:S3-buckets_-_Lifecycle_Create_bucket_02.png&amp;diff=838</id>
		<title>File:S3-buckets - Lifecycle Create bucket 02.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=File:S3-buckets_-_Lifecycle_Create_bucket_02.png&amp;diff=838"/>
		<updated>2024-12-24T10:18:58Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=File:S3-buckets_-_Lifecycle_Create_bucket_01.png&amp;diff=837</id>
		<title>File:S3-buckets - Lifecycle Create bucket 01.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=File:S3-buckets_-_Lifecycle_Create_bucket_01.png&amp;diff=837"/>
		<updated>2024-12-24T10:18:47Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=829</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=829"/>
		<updated>2024-11-26T14:55:22Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Disable Versioning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=828</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=828"/>
		<updated>2024-11-26T14:55:05Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Enable Versioning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get status]] command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=827</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=827"/>
		<updated>2024-11-26T14:54:10Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Enable Versioning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=826</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=826"/>
		<updated>2024-11-26T14:53:34Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Enable Versioning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you then run the &#039;&#039;-command you will get an output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=825</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=825"/>
		<updated>2024-11-26T14:50:23Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Policy - Get status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; highlight=8&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=824</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=824"/>
		<updated>2024-11-26T14:48:47Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Get status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=823</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=823"/>
		<updated>2024-11-26T14:47:15Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Get status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=822</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=822"/>
		<updated>2024-11-26T14:46:29Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Get status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot; highlight=5&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=821</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=821"/>
		<updated>2024-11-26T14:46:11Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Versioning - Get status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot; highlight=4&amp;gt;&lt;br /&gt;
s3://test77/ (bucket):&lt;br /&gt;
   Location:  location&lt;br /&gt;
   Payer:     BucketOwner&lt;br /&gt;
   Ownership: none&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   Expiration rule: none&lt;br /&gt;
   Block Public Access: none&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   CORS:      none&lt;br /&gt;
   ACL:       x: FULL_CONTROL&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=820</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=820"/>
		<updated>2024-11-26T14:42:41Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Set retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=819</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=819"/>
		<updated>2024-11-26T14:42:19Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Get retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a retention policy set, then the output might look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
        &amp;quot;Rule&amp;quot;: {&lt;br /&gt;
            &amp;quot;DefaultRetention&amp;quot;: {&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;COMPLIANCE&amp;quot;,&lt;br /&gt;
                &amp;quot;Days&amp;quot;: 3&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=818</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=818"/>
		<updated>2024-11-26T14:40:10Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Set retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]].&lt;br /&gt;
The output should then look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=817</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=817"/>
		<updated>2024-11-26T14:38:36Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Set retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the retention time of a s3-bucket to a certain amount of days, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration &#039;ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The command will give you no output (apart from the status code 0).&lt;br /&gt;
&lt;br /&gt;
To check the retention policy of the s3-bucket, go to the following section&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=816</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=816"/>
		<updated>2024-11-26T14:34:11Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Set retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
Use the following commands to set the retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=815</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=815"/>
		<updated>2024-11-26T14:33:16Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Get retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=814</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=814"/>
		<updated>2024-11-26T14:32:26Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;--object-lock-enabled-for-bucket&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=813</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=813"/>
		<updated>2024-11-26T14:31:58Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock - Get retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;&#039;-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=812</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=812"/>
		<updated>2024-11-26T14:30:45Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Object lock */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
This section covers how to manage object locks and set retention policies.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
Use the following commands to retrieve the current retention policy of a s3-bucket.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the retention policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The output should look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;ObjectLockConfiguration&amp;quot;: {&lt;br /&gt;
        &amp;quot;ObjectLockEnabled&amp;quot;: &amp;quot;Enabled&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it looks like this instead, then you created the s3-bucket without the &#039;&#039;-flag (Create bucket with object lock enabled).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
Not supported by s3cmd.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=811</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=811"/>
		<updated>2024-11-26T14:26:56Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Object lock ==&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Object lock - Get retention policy ===&lt;br /&gt;
=== Lifecycle - Object lock - Set retention policy ===&lt;br /&gt;
&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name}&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=810</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=810"/>
		<updated>2024-11-26T14:24:24Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Retention policy ==&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=809</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=809"/>
		<updated>2024-11-26T14:23:48Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Retention policy ==&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a retention policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=808</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=808"/>
		<updated>2024-11-26T14:23:18Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Retention policy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Policy ==&lt;br /&gt;
This section explains how to add a retention policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=807</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=807"/>
		<updated>2024-11-26T13:52:28Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket with object locking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
s3cmd doesn&#039;t support object-locks.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Retention policy ==&lt;br /&gt;
This section explains how to add a retention policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=806</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=806"/>
		<updated>2024-11-26T13:51:36Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket with object locking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Retention policy ==&lt;br /&gt;
This section explains how to add a retention policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=805</id>
		<title>S3 buckets</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=S3_buckets&amp;diff=805"/>
		<updated>2024-11-26T13:48:35Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Lifecycle - Create bucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the creation and management of S3 buckets in our OpenStack-based stoney cloud.&lt;br /&gt;
&lt;br /&gt;
= Credential pair =&lt;br /&gt;
In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service.&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the creation process in our OpenStack-based cloud.&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Create ==&lt;br /&gt;
&lt;br /&gt;
Create new EC2 credentials in OpenStack using the OpenStack-CLI:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack ec2 credentials create&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output in the following format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Show ==&lt;br /&gt;
&lt;br /&gt;
If you ever need to look the credentials up again, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials show ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you an output formatted like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Field      | Value                                                                                                                                          |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
| access     | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
| links      | {&#039;self&#039;: &#039;https://api.os.stoney-cloud.com:5000/v3/users/tpvx3i0gk5rf4duomnr7davjxl517z9c/credentials/OS-EC2/tpvx3i0gk5rf4duomnr7davjxl517z9c&#039;} |&lt;br /&gt;
| project_id | hw3rr6x6ktyuv7erwpuyxbijihx1phdw                                                                                                               |&lt;br /&gt;
| secret     | 6lifckxv1005z60csekl7qynwxwbv3re                                                                                                               |&lt;br /&gt;
| trust_id   | None                                                                                                                                           |&lt;br /&gt;
| user_id    | tpvx3i0gk5rf4duomnr7davjxl517z9c                                                                                                               |&lt;br /&gt;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Credential pair - Delete ==&lt;br /&gt;
If you need to delete your credentials, you can so like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_id=tpvx3i0gk5rf4duomnr7davjxl517z9c&lt;br /&gt;
openstack ec2 credentials delete ${access_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When running &#039;delete&#039; you should get no response apart from the status code 0.&lt;br /&gt;
&lt;br /&gt;
= General usage =&lt;br /&gt;
When using the S3 technology, you have different possible cli-tools.&lt;br /&gt;
The most popular implementations are:&lt;br /&gt;
* aws&lt;br /&gt;
* s3cmd&lt;br /&gt;
&lt;br /&gt;
This page focuses on the usage of those two implementations.&lt;br /&gt;
&lt;br /&gt;
== General usage - Connect ==&lt;br /&gt;
=== General usage - Connect - AWS client ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the AWS-client.&lt;br /&gt;
==== General usage - Connect - AWS client - Installation ====&lt;br /&gt;
Install the awscli using your favorite package manager:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install awscli&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install awscli&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add aws-cli&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S aws-cli&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Configuration ====&lt;br /&gt;
After installing the awscli package, you can configure it like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration helper will prompt you to enter the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
AWS Access Key ID [None]: tpvx3i0gk5rf4duomnr7davjxl517z9c # access (from EC2 credentials)&lt;br /&gt;
AWS Secret Access Key [None]: 6lifckxv1005z60csekl7qynwxwbv3re # secret (from EC2 credentials)&lt;br /&gt;
Default region name [None]: # leave empty&lt;br /&gt;
Default output format [None]: json # set to json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will then create config files on your machine in the following locations:&lt;br /&gt;
* ~/.aws/config&lt;br /&gt;
* ~/.aws/credentials&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - AWS client - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-buckets&amp;lt;/syntaxhighlight&amp;gt; or &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3 ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api create-bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api delete-bucket --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api list-objects --bucket &amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;aws s3api help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General usage - Connect - S3cmd ===&lt;br /&gt;
This section explains the general usage such as configuring the connection using the S3cmd-client.&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Installation ====&lt;br /&gt;
Install the s3cmd using your favorite package manager: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora/RHEL&lt;br /&gt;
sudo dnf install s3cmd&lt;br /&gt;
# Ubuntu/Debian&lt;br /&gt;
sudo apt install s3cmd&lt;br /&gt;
# Alpine Linux&lt;br /&gt;
sudo apk add s3cmd&lt;br /&gt;
# Arch Linux&lt;br /&gt;
sudo pacman -S s3cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Configuration ====&lt;br /&gt;
To configure s3cmd, create a configuration file like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Create file&lt;br /&gt;
touch ~/.s3cfg&lt;br /&gt;
&lt;br /&gt;
# Edit file&lt;br /&gt;
vim ~/.s3cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The configuration file should include the following options:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
access_key = &amp;lt;access&amp;gt; # replace with your access key of the ec2 credential&lt;br /&gt;
secret_key = &amp;lt;secret&amp;gt; # replace with your secret key of the ec2 credential&lt;br /&gt;
host_base = api.os.stoney-cloud.com:9000&lt;br /&gt;
host_bucket = api.os.stoney-cloud.com:9000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== General usage - Connect - S3cmd - Cheatsheet ====&lt;br /&gt;
Short overview of available commands when using s3cmd:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Cheatsheet&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Command&lt;br /&gt;
|-&lt;br /&gt;
| Show available buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Create a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd mb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd rb s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show content of a bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd ls s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Put file into bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd put &amp;lt;file&amp;gt; s3://&amp;lt;bucket-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Get file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd get s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delete file from bucket || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd [del|rm] s3://&amp;lt;bucket-name&amp;gt;/&amp;lt;file-name&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show disk usage of buckets || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd du&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Show all command available || &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;s3cmd --help&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Lifecycle =&lt;br /&gt;
This section holds all sub-sections explaining the lifecycle.&lt;br /&gt;
&lt;br /&gt;
Define the following variables, as they will be used across different lifecycle operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
endpoint_url=https://api.os.stoney-cloud.com:9000&lt;br /&gt;
bucket_name=&amp;lt;bucket-name&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Create bucket ==&lt;br /&gt;
This section explains how to create a new s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket ===&lt;br /&gt;
The following commands explain how to create a normal s3-bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the follwing command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3 ls | grep ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
2024-11-26 14:46:28 test77&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd mb s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Bucket &#039;s3://test76/&#039; created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Create bucket with object locking ===&lt;br /&gt;
To create a s3-bucket with support for object-locking, use the following commands.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} --object-lock-enabled-for-bucket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Versioning ==&lt;br /&gt;
This section explains how to enable versioning for a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Get status ===&lt;br /&gt;
To get the current versioning status for a certain bucket, use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To retrieve the status of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-versioning --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, the aws-cli command should return nothing.&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To retrieve the status of a s3-bucket using the s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd info s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you haven&#039;t configured versioning for that particular bucket yet, s3cmd will return the following information:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning disabled, it will look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Suspended&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have versioning configured, it should look similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Versioning:Enabled&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Enable Versioning ===&lt;br /&gt;
To enable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To enable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Enabled&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{  &lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Enabled&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Versioning - Disable Versioning ===&lt;br /&gt;
To disable versioning use the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To disable versioning of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-versioning --bucket ${bucket_name} --versioning-configuration Status=Suspended&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
You can check if the command was successful, by running the [[#Lifecycle - Versioning - Get status|Get-status]]-command. The output should then look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Suspended&amp;quot;,&lt;br /&gt;
    &amp;quot;MFADelete&amp;quot;: &amp;quot;Disabled&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To enable versioning of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://newfreshs3 disable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
s3cmd should return the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Versioning status updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Lifecycle - Retention policy ==&lt;br /&gt;
This section explains how to add a retention policy to a s3 bucket.&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Get status ===&lt;br /&gt;
To get the bucket policy, run the following commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To get the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api get-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if the bucket has a retention policy, then the output should look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;Policy&amp;quot;: &amp;quot;{\n  \&amp;quot;Version\&amp;quot;: \&amp;quot;2012-10-17\&amp;quot;,\n  \&amp;quot;Statement\&amp;quot;: [{\n    \&amp;quot;Effect\&amp;quot;: \&amp;quot;Allow\&amp;quot;,\n    \&amp;quot;Principal\&amp;quot;: {\&amp;quot;AWS\&amp;quot;: [\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:root\&amp;quot;,\n      \&amp;quot;arn:aws:iam::tpvx3i0gk5rf4duomnr7davjxl517z9c:user/testuser\&amp;quot;\n     ]},\n    \&amp;quot;Action\&amp;quot;: [\n        \&amp;quot;s3:ListBucket\&amp;quot;,\n        \&amp;quot;s3:PutObject\&amp;quot;,\n        \&amp;quot;s3:DeleteObject\&amp;quot;,\n        \&amp;quot;s3:GetObject\&amp;quot;\n      ],\n    \&amp;quot;Resource\&amp;quot;: [\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket/*\&amp;quot;,\n      \&amp;quot;arn:aws:s3:::tpvx3i0gk5rf4duomnr7davjxl517z9c/backup-Y-bucket\&amp;quot;\n    ]\n  }]\n}\n\n&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To get the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setversioning s3://${bucket_name} enable&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the bucket has no retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    none&lt;br /&gt;
   [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the bucket has a retention policy, then the output will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://secondtest/ (bucket):&lt;br /&gt;
   [...]&lt;br /&gt;
   Policy:    {&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
   CORS:      [...]&lt;br /&gt;
   ACL:       [...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Set policy ===&lt;br /&gt;
A typical json formatted policy-file will look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;Version&amp;quot;: &amp;quot;2012-10-17&amp;quot;,&lt;br /&gt;
  &amp;quot;Statement&amp;quot;: [{&lt;br /&gt;
    &amp;quot;Effect&amp;quot;: &amp;quot;Allow&amp;quot;,&lt;br /&gt;
    &amp;quot;Principal&amp;quot;: {&amp;quot;AWS&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:root&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:iam::x:user/testuser&amp;quot;&lt;br /&gt;
     ]},&lt;br /&gt;
    &amp;quot;Action&amp;quot;: [&lt;br /&gt;
        &amp;quot;s3:ListBucket&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:PutObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:DeleteObject&amp;quot;,&lt;br /&gt;
        &amp;quot;s3:GetObject&amp;quot;&lt;br /&gt;
      ],&lt;br /&gt;
    &amp;quot;Resource&amp;quot;: [&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket/*&amp;quot;,&lt;br /&gt;
      &amp;quot;arn:aws:s3:::x/backup-Y-bucket&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
  }]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following commands are used to set the policy for a certain bucket.&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To set the bucket policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api put-bucket-policy --bucket ${bucket_name} --policy file://&amp;lt;policy_file&amp;gt;.json&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To set the bucket policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd setpolicy &amp;lt;policy_file&amp;gt;.json s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://yours3bucket/: Policy updated&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lifecycle - Retention policy - Remove Policy ===&lt;br /&gt;
The following commands are used to remove a policy that is no longer wanted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-| Aws-cli =&lt;br /&gt;
To remove the policy of a s3-bucket using the aws-cli, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
aws --endpoint-url ${endpoint_url} s3api delete-bucket-policy --bucket ${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0).&lt;br /&gt;
&lt;br /&gt;
|-| S3cmd =&lt;br /&gt;
To remove the policy of a s3-bucket using s3cmd, use the following command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3cmd delpolicy s3://${bucket_name}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Output:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you ran the s3cmd command, you should get the following response:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
s3://newfreshs3/: Policy deleted&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Object_store]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
</feed>