<?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-11-30T03:09:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=AI_on_Demand:_Token_streaming&amp;diff=1310</id>
		<title>AI on Demand: Token streaming</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=AI_on_Demand:_Token_streaming&amp;diff=1310"/>
		<updated>2026-11-09T15:36:28Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: /* Usage - Inference with token-stream */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This pages describes some useful commands on how to use token streaming.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
We assume you&#039;ve received your API key from us in our usual manner.&lt;br /&gt;
&lt;br /&gt;
== Usage - Inference with token-stream ==&lt;br /&gt;
&lt;br /&gt;
Regular token streaming is difficult to read in the console.&lt;br /&gt;
&lt;br /&gt;
The expanded command processes the output into a far more digestible format on the console.&lt;br /&gt;
&lt;br /&gt;
Chat platforms like LibreChat include native mechanisms for handling token streaming or parsing the stream.&lt;br /&gt;
&lt;br /&gt;
The stream: true flag needs to be set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
#Persönlichen Key setzen&lt;br /&gt;
STONEY_KEY=&#039;sk-...&#039;&lt;br /&gt;
&lt;br /&gt;
#Modell auswählen&lt;br /&gt;
MODEL=&#039;zai-org/GLM-5.3-Flash&#039;&lt;br /&gt;
&lt;br /&gt;
#Prompt eingeben&lt;br /&gt;
PROMPT=&#039;Hallo, bitte führe meine Prompt aus&#039;&lt;br /&gt;
&lt;br /&gt;
#Tokenlimit setzen&lt;br /&gt;
MAX_TOKENS=2000&lt;br /&gt;
&lt;br /&gt;
#Inference Call&lt;br /&gt;
jq -n \&lt;br /&gt;
    --arg model &amp;quot;$MODEL&amp;quot; \&lt;br /&gt;
    --arg prompt &amp;quot;$PROMPT&amp;quot; \&lt;br /&gt;
    --argjson max_tokens &amp;quot;$MAX_TOKENS&amp;quot; &#039;{&lt;br /&gt;
      model: $model,&lt;br /&gt;
      messages: [&lt;br /&gt;
        {&lt;br /&gt;
          role: &amp;quot;user&amp;quot;,&lt;br /&gt;
          content: $prompt&lt;br /&gt;
        }&lt;br /&gt;
      ],&lt;br /&gt;
      stream: true,&lt;br /&gt;
      stream_options: {include_usage: true},&lt;br /&gt;
      max_tokens: $max_tokens&lt;br /&gt;
    }&#039; |&lt;br /&gt;
  curl --fail-with-body --no-buffer -sS \&lt;br /&gt;
    --connect-timeout 5 \&lt;br /&gt;
    --max-time 180 \&lt;br /&gt;
    https://llm.stoney-cloud.com/v1/chat/completions \&lt;br /&gt;
    -H &amp;quot;Authorization: Bearer ${STONEY_KEY:?Set your production STONEY_KEY}&amp;quot; \&lt;br /&gt;
    -H &#039;Content-Type: application/json&#039; \&lt;br /&gt;
    --data-binary @- |&lt;br /&gt;
  tee &amp;quot;$STREAM_FILE&amp;quot; |&lt;br /&gt;
  python3 -u -c &#039;&lt;br /&gt;
import json&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
section = None&lt;br /&gt;
latest_usage = None&lt;br /&gt;
done = False&lt;br /&gt;
&lt;br /&gt;
for line in sys.stdin:&lt;br /&gt;
    if not line.startswith(&amp;quot;data:&amp;quot;):&lt;br /&gt;
        continue&lt;br /&gt;
&lt;br /&gt;
    payload = line[5:].strip()&lt;br /&gt;
    if payload == &amp;quot;[DONE]&amp;quot;:&lt;br /&gt;
        done = True&lt;br /&gt;
        continue&lt;br /&gt;
&lt;br /&gt;
    try:&lt;br /&gt;
        event = json.loads(payload)&lt;br /&gt;
    except json.JSONDecodeError:&lt;br /&gt;
        continue&lt;br /&gt;
&lt;br /&gt;
    if not isinstance(event, dict):&lt;br /&gt;
        continue&lt;br /&gt;
&lt;br /&gt;
    if &amp;quot;error&amp;quot; in event:&lt;br /&gt;
        print(&amp;quot;\nAPI error:&amp;quot;, event[&amp;quot;error&amp;quot;], flush=True)&lt;br /&gt;
&lt;br /&gt;
    for choice in event.get(&amp;quot;choices&amp;quot;) or []:&lt;br /&gt;
        delta = choice.get(&amp;quot;delta&amp;quot;) or {}&lt;br /&gt;
        reasoning = delta.get(&amp;quot;reasoning&amp;quot;) or delta.get(&amp;quot;reasoning_content&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        for label, text in (&lt;br /&gt;
            (&amp;quot;Reasoning&amp;quot;, reasoning),&lt;br /&gt;
            (&amp;quot;Answer&amp;quot;, delta.get(&amp;quot;content&amp;quot;)),&lt;br /&gt;
        ):&lt;br /&gt;
            if isinstance(text, str) and text:&lt;br /&gt;
                if section != label:&lt;br /&gt;
                    print(&amp;quot;\n\n--- {} ---&amp;quot;.format(label), flush=True)&lt;br /&gt;
                    section = label&lt;br /&gt;
                print(text, end=&amp;quot;&amp;quot;, flush=True)&lt;br /&gt;
&lt;br /&gt;
        if choice.get(&amp;quot;finish_reason&amp;quot;):&lt;br /&gt;
            print(&lt;br /&gt;
                &amp;quot;\n[Finish reason: {}]&amp;quot;.format(choice[&amp;quot;finish_reason&amp;quot;]),&lt;br /&gt;
                flush=True,&lt;br /&gt;
            )&lt;br /&gt;
&lt;br /&gt;
    usage = event.get(&amp;quot;usage&amp;quot;)&lt;br /&gt;
    if isinstance(usage, dict):&lt;br /&gt;
        latest_usage = usage&lt;br /&gt;
&lt;br /&gt;
if latest_usage is not None:&lt;br /&gt;
    label = &amp;quot;Usage&amp;quot; if done else &amp;quot;Last reported usage (stream incomplete)&amp;quot;&lt;br /&gt;
    print(&amp;quot;\n\n{}:\n{}&amp;quot;.format(&lt;br /&gt;
        label, json.dumps(latest_usage, indent=2)&lt;br /&gt;
    ), flush=True)&lt;br /&gt;
&lt;br /&gt;
print(&lt;br /&gt;
    &amp;quot;\n[Stream complete]&amp;quot; if done else &amp;quot;\n[Stream ended without DONE]&amp;quot;,&lt;br /&gt;
    flush=True,&lt;br /&gt;
)&lt;br /&gt;
&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: AI on Demand]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=Security_group_rules&amp;diff=1222</id>
		<title>Security group rules</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=Security_group_rules&amp;diff=1222"/>
		<updated>2026-10-28T14:38:41Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the handling of security groups within OpenStack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-|OpenStack CLI=&lt;br /&gt;
= Managed security groups using the CLI =&lt;br /&gt;
This chapter shows guides you through the daily operations regarding security groups in stepping stone AG&#039;s OpenStack based cloud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; This guide assumes that you already have access to the OpenStack CLI and are authenticated. If you are not, follow the [[Quickstart|OpenStack quick start guide]].&lt;br /&gt;
== Managed security groups using the CLI - Create group ==&lt;br /&gt;
A new security group may be created as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;              # Provide a OpenStack project id (such as &#039;ecd2fbce789f4e70bb31613e4e189a43&#039;)&lt;br /&gt;
secgroup_name=&#039;&#039;           # Give it a descriptive name (such as &#039;HTTPS World&#039;)&lt;br /&gt;
secgroup_description=&#039;&#039;    # Describe the security group further.&lt;br /&gt;
&lt;br /&gt;
openstack security group create \&lt;br /&gt;
      --project &amp;quot;${project_id}&amp;quot; \&lt;br /&gt;
      --format value \&lt;br /&gt;
      --column id \&lt;br /&gt;
      --description &amp;quot;${secgroup_description}&amp;quot; \&lt;br /&gt;
      &amp;quot;${secgroup_name}&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon successful creation the OpenStack CLI will simply return the id of the newly created security group:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
5008898e-6307-499a-9d32-470e551d387a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Create rules ==&lt;br /&gt;
Upon creation, a new security group is empty and does not contain any rules.&lt;br /&gt;
&lt;br /&gt;
To create a rule and assign it to the security group, continue as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;              # Provide a OpenStack project id (such as &#039;ecd2fbce789f4e70bb31613e4e189a43&#039;)&lt;br /&gt;
secgroup_id=&#039;&#039;             # Provide the UUID of the newly created security group (such as &#039;5008898e-6307-499a-9d32-470e551d387a&#039;)&lt;br /&gt;
&lt;br /&gt;
openstack security group rule create \&lt;br /&gt;
    --project ${project_id} \&lt;br /&gt;
    --ingress \&lt;br /&gt;
    --ethertype IPv4 \&lt;br /&gt;
    --protocol tcp \&lt;br /&gt;
    --dst-port 443 \&lt;br /&gt;
    --remote-ip &amp;quot;0.0.0.0/0&amp;quot; \&lt;br /&gt;
    ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following paramters may be modified to further suit your situation:&lt;br /&gt;
* &#039;&#039;&#039;ingress:&#039;&#039;&#039; The rule may be either a &amp;lt;code&amp;gt;ingress&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;egress&amp;lt;/code&amp;gt; rule.&lt;br /&gt;
* &#039;&#039;&#039;ethertype:&#039;&#039;&#039; May be either &amp;lt;code&amp;gt;IPv4&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;IPv6&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;protocol:&#039;&#039;&#039; May be either &amp;lt;code&amp;gt;tcp&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;udp&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;dst-port:&#039;&#039;&#039; May be any port between &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;65535&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;remote-ip:&#039;&#039;&#039; May be an ip range such as &amp;lt;code&amp;gt;192.168.1.0/24&amp;lt;/code&amp;gt; or a single ip such as &amp;lt;code&amp;gt;192.168.1.100/32&amp;lt;/code&amp;gt;. To allow traffic from anywhere,  use &amp;lt;code&amp;gt;0.0.0.0/0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Upon successful creation, the OpenStack CLI should return an output similar to 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;
| created_at        | 2026-10-28T14:15:12Z                                                                                                                                                                         |&lt;br /&gt;
| description       |                                                                                                                                                                                              |&lt;br /&gt;
| direction         | ingress                                                                                                                                                                                      |&lt;br /&gt;
| ether_type        | IPv4                                                                                                                                                                                         |&lt;br /&gt;
| id                | 2b2c8a6b-6110-4eee-9802-480f1ec12e20                                                                                                                                                         |&lt;br /&gt;
| location          | Munch({&#039;cloud&#039;: &#039;&#039;, &#039;region_name&#039;: &#039;duedingen-test&#039;, &#039;zone&#039;: None, &#039;project&#039;: Munch({&#039;id&#039;: &#039;c2ebdf6ceea9464ea07922ebf8d2f857&#039;, &#039;name&#039;: None, &#039;domain_id&#039;: &#039;default&#039;, &#039;domain_name&#039;: None})}) |&lt;br /&gt;
| name              | None                                                                                                                                                                                         |&lt;br /&gt;
| port_range_max    | 443                                                                                                                                                                                          |&lt;br /&gt;
| port_range_min    | 443                                                                                                                                                                                          |&lt;br /&gt;
| project_id        | ecd2fbce789f4e70bb31613e4e189a43                                                                                                                                                             |&lt;br /&gt;
| protocol          | tcp                                                                                                                                                                                          |&lt;br /&gt;
| remote_group_id   | None                                                                                                                                                                                         |&lt;br /&gt;
| remote_ip_prefix  | 0.0.0.0/0                                                                                                                                                                                    |&lt;br /&gt;
| revision_number   | 0                                                                                                                                                                                            |&lt;br /&gt;
| security_group_id | 5008898e-6307-499a-9d32-470e551d387a                                                                                                                                                         |&lt;br /&gt;
| tags              | []                                                                                                                                                                                           |&lt;br /&gt;
| updated_at        | 2026-10-28T14:15:12Z                                                                                                                                                                         |&lt;br /&gt;
+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Assign to server ==&lt;br /&gt;
To assign a security group to a server, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
server_id=&#039;&#039;            # Provide the UUID of a server (Such as &#039;ddad0639-013e-4ec1-b06e-846de3126b81&#039;)&lt;br /&gt;
secgroup_id=&#039;&#039;          # Provide the UUID of a security group (such as &#039;5008898e-6307-499a-9d32-470e551d387a&#039;)&lt;br /&gt;
&lt;br /&gt;
openstack server add security group ${server_id} ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon successful assignment, the OpenStack CLI returns an empty response and the return code &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - List ==&lt;br /&gt;
To list all security groups, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack security group list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will return an output similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+--------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+----------------------------------+------+&lt;br /&gt;
| ID                                   | Name                                                                                                                 | Description                                                                                                                     | Project                          | Tags |&lt;br /&gt;
+--------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+----------------------------------+------+&lt;br /&gt;
| fca535cd-9b5a-451f-b09b-0a336bbd4787 | Security Group 1                                                                                                     | Do some stuff in security group 1.                                                                                              | 6a7408fea29a4412b8fb62e32e0e9535 | []   |&lt;br /&gt;
| e6e73ec5-97a3-4742-956c-6cbefd2c0b9c | Security Group 2                                                                                                     | Do some stuff in security group 2.                                                                                              | 6a7408fea29a4412b8fb62e32e0e9535 | []   |&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Beware:&#039;&#039;&#039; This will list all the security groups of all the projects you have access to.&lt;br /&gt;
&lt;br /&gt;
To list all security groups only for a certain project, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;            # Provide the UUID of a project (Such as &#039;ddad0639013e4ec1b06e846de3126b81&#039;) &lt;br /&gt;
&lt;br /&gt;
openstack security group list --project ${project_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Show ==&lt;br /&gt;
To show all the available data for a security group, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
secgroup_id=&#039;&#039;            # Provide the UUID of a security group (Such as &#039;fca535cd-9b5a-451f-b09b-0a336bbd4787&#039;) &lt;br /&gt;
&lt;br /&gt;
openstack security group show ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The returned output should be similar to 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;
| created_at      | 2022-12-07T16:02:48Z                                                                                                                                                                                                                                                                                                       |&lt;br /&gt;
| description     | Allow TFTP traffic from 0.0.0.0/0 on UDP port 69.                                                                                                                                                                                                                                                                          |&lt;br /&gt;
| id              | fca535cd-9b5a-451f-b09b-0a336bbd4787                                                                                                                                                                                                                                                                                       |&lt;br /&gt;
| location        | cloud=&#039;&#039;, project.domain_id=&#039;default&#039;, project.domain_name=, project.id=&#039;ddad0639013e4ec1b06e846de3126b81&#039;, project.name=, region_name=&#039;duedingen-production&#039;, zone=                                                                                                                                                       |&lt;br /&gt;
| name            | TFTP World                                                                                                                                                                                                                                                                                                                 |&lt;br /&gt;
| project_id      | ddad0639013e4ec1b06e846de3126b81                                                                                                                                                                                                                                                                                           |&lt;br /&gt;
| revision_number | 6                                                                                                                                                                                                                                                                                                                          |&lt;br /&gt;
| rules           | created_at=&#039;2022-12-08T10:34:08Z&#039;, direction=&#039;ingress&#039;, ethertype=&#039;IPv4&#039;, id=&#039;89c46a1c-9651-46b2-98e1-fc3412e8c36b&#039;, normalized_cidr=&#039;0.0.0.0/0&#039;, port_range_max=&#039;69&#039;, port_range_min=&#039;69&#039;, protocol=&#039;udp&#039;, remote_ip_prefix=&#039;0.0.0.0/0&#039;, revision_number=&#039;1&#039;, standard_attr_id=&#039;49999&#039;, updated_at=&#039;2022-12-08T10:34:08Z&#039; |&lt;br /&gt;
| tags            | []                                                                                                                                                                                                                                                                                                                         |&lt;br /&gt;
| updated_at      | 2022-12-08T10:34:08Z                                                                                                                                                                                                                                                                                                       |&lt;br /&gt;
+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Managed security groups using the CLI - Delete ==&lt;br /&gt;
To delete a security group using the OpenStack CLI, the following steps may be consulted:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
secgroup_id=&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
openstack security group delete ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon successful deletion the OpenStack CLI will return an empty response and the status code &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|-|OpenStack Dashboard=&lt;br /&gt;
To be documented in the future.&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Network]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=Security_group_rules&amp;diff=1221</id>
		<title>Security group rules</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=Security_group_rules&amp;diff=1221"/>
		<updated>2026-10-28T14:31:26Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the handling of security groups within OpenStack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-|OpenStack CLI=&lt;br /&gt;
= Managed security groups using the CLI =&lt;br /&gt;
This chapter shows guides you through the daily operations regarding security groups in stepping stone AG&#039;s OpenStack based cloud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; This guide assumes that you already have access to the OpenStack CLI and are authenticated. If you are not, follow the [[Quickstart|OpenStack quick start guide]].&lt;br /&gt;
== Managed security groups using the CLI - Create group ==&lt;br /&gt;
A new security group may be created as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;              # Provide a OpenStack project id (such as &#039;ecd2fbce789f4e70bb31613e4e189a43&#039;)&lt;br /&gt;
secgroup_name=&#039;&#039;           # Give it a descriptive name (such as &#039;HTTPS World&#039;)&lt;br /&gt;
secgroup_description=&#039;&#039;    # Describe the security group further.&lt;br /&gt;
&lt;br /&gt;
openstack security group create \&lt;br /&gt;
      --project &amp;quot;${project_id}&amp;quot; \&lt;br /&gt;
      --format value \&lt;br /&gt;
      --column id \&lt;br /&gt;
      --description &amp;quot;${secgroup_description}&amp;quot; \&lt;br /&gt;
      &amp;quot;${secgroup_name}&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon successful creation the OpenStack CLI will simply return the id of the newly created security group:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
5008898e-6307-499a-9d32-470e551d387a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Create rules ==&lt;br /&gt;
Upon creation, a new security group is empty and does not contain any rules.&lt;br /&gt;
&lt;br /&gt;
To create a rule and assign it to the security group, continue as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;              # Provide a OpenStack project id (such as &#039;ecd2fbce789f4e70bb31613e4e189a43&#039;)&lt;br /&gt;
secgroup_id=&#039;&#039;             # Provide the UUID of the newly created security group (such as &#039;5008898e-6307-499a-9d32-470e551d387a&#039;)&lt;br /&gt;
&lt;br /&gt;
openstack security group rule create \&lt;br /&gt;
    --project ${project_id} \&lt;br /&gt;
    --ingress \&lt;br /&gt;
    --ethertype IPv4 \&lt;br /&gt;
    --protocol tcp \&lt;br /&gt;
    --dst-port 443 \&lt;br /&gt;
    --remote-ip &amp;quot;0.0.0.0/0&amp;quot; \&lt;br /&gt;
    ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following paramters may be modified to further suit your situation:&lt;br /&gt;
* &#039;&#039;&#039;ingress:&#039;&#039;&#039; The rule may be either a &amp;lt;code&amp;gt;ingress&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;egress&amp;lt;/code&amp;gt; rule.&lt;br /&gt;
* &#039;&#039;&#039;ethertype:&#039;&#039;&#039; May be either &amp;lt;code&amp;gt;IPv4&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;IPv6&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;protocol:&#039;&#039;&#039; May be either &amp;lt;code&amp;gt;tcp&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;udp&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;dst-port:&#039;&#039;&#039; May be any port between &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;65535&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;remote-ip:&#039;&#039;&#039; May be an ip range such as &amp;lt;code&amp;gt;192.168.1.0/24&amp;lt;/code&amp;gt; or a single ip such as &amp;lt;code&amp;gt;192.168.1.100/32&amp;lt;/code&amp;gt;. To allow traffic from anywhere,  use &amp;lt;code&amp;gt;0.0.0.0/0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Upon successful creation, the OpenStack CLI should return an output similar to 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;
| created_at        | 2026-10-28T14:15:12Z                                                                                                                                                                         |&lt;br /&gt;
| description       |                                                                                                                                                                                              |&lt;br /&gt;
| direction         | ingress                                                                                                                                                                                      |&lt;br /&gt;
| ether_type        | IPv4                                                                                                                                                                                         |&lt;br /&gt;
| id                | 2b2c8a6b-6110-4eee-9802-480f1ec12e20                                                                                                                                                         |&lt;br /&gt;
| location          | Munch({&#039;cloud&#039;: &#039;&#039;, &#039;region_name&#039;: &#039;duedingen-test&#039;, &#039;zone&#039;: None, &#039;project&#039;: Munch({&#039;id&#039;: &#039;c2ebdf6ceea9464ea07922ebf8d2f857&#039;, &#039;name&#039;: None, &#039;domain_id&#039;: &#039;default&#039;, &#039;domain_name&#039;: None})}) |&lt;br /&gt;
| name              | None                                                                                                                                                                                         |&lt;br /&gt;
| port_range_max    | 443                                                                                                                                                                                          |&lt;br /&gt;
| port_range_min    | 443                                                                                                                                                                                          |&lt;br /&gt;
| project_id        | ecd2fbce789f4e70bb31613e4e189a43                                                                                                                                                             |&lt;br /&gt;
| protocol          | tcp                                                                                                                                                                                          |&lt;br /&gt;
| remote_group_id   | None                                                                                                                                                                                         |&lt;br /&gt;
| remote_ip_prefix  | 0.0.0.0/0                                                                                                                                                                                    |&lt;br /&gt;
| revision_number   | 0                                                                                                                                                                                            |&lt;br /&gt;
| security_group_id | 5008898e-6307-499a-9d32-470e551d387a                                                                                                                                                         |&lt;br /&gt;
| tags              | []                                                                                                                                                                                           |&lt;br /&gt;
| updated_at        | 2026-10-28T14:15:12Z                                                                                                                                                                         |&lt;br /&gt;
+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Assign to server ==&lt;br /&gt;
To assign a security group to a server, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
server_id=&#039;&#039;            # Provide the UUID of a server (Such as &#039;ddad0639-013e-4ec1-b06e-846de3126b81&#039;)&lt;br /&gt;
secgroup_id=&#039;&#039;          # Provide the UUID of a security group (such as &#039;5008898e-6307-499a-9d32-470e551d387a&#039;)&lt;br /&gt;
&lt;br /&gt;
openstack server add security group ${server_id} ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon successful assignment, the OpenStack CLI returns an empty response and the return code &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - List ==&lt;br /&gt;
To list all security groups, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openstack security group list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will return an output similar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+--------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+----------------------------------+------+&lt;br /&gt;
| ID                                   | Name                                                                                                                 | Description                                                                                                                     | Project                          | Tags |&lt;br /&gt;
+--------------------------------------+----------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+----------------------------------+------+&lt;br /&gt;
| fca535cd-9b5a-451f-b09b-0a336bbd4787 | Security Group 1                                                                                                     | Do some stuff in security group 1.                                                                                              | 6a7408fea29a4412b8fb62e32e0e9535 | []   |&lt;br /&gt;
| e6e73ec5-97a3-4742-956c-6cbefd2c0b9c | Security Group 2                                                                                                     | Do some stuff in security group 2.                                                                                              | 6a7408fea29a4412b8fb62e32e0e9535 | []   |&lt;br /&gt;
[...]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Beware:&#039;&#039;&#039; This will list all the security groups of all the projects you have access to.&lt;br /&gt;
&lt;br /&gt;
To list all security groups only for a certain project, follow the provided steps:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;            # Provide the UUID of a project (Such as &#039;ddad0639013e4ec1b06e846de3126b81&#039;) &lt;br /&gt;
&lt;br /&gt;
openstack security group list --project ${project_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Show ==&lt;br /&gt;
== Managed security groups using the CLI - Delete ==&lt;br /&gt;
|-|OpenStack Dashboard=&lt;br /&gt;
= Managed security groups using the Dashboard =&lt;br /&gt;
This chapter shows guides you through the daily operations regarding security groups in stepping stone AG&#039;s OpenStack based cloud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; This guide assumes that you already have access to the OpenStack dashboard and are authenticated. If you are not, follow the [[Quickstart|OpenStack quick start guide]].&lt;br /&gt;
== Managed security groups using the Dashboard - Create ==&lt;br /&gt;
== Managed security groups using the Dashboard - Assign to server ==&lt;br /&gt;
== Managed security groups using the Dashboard - List ==&lt;br /&gt;
== Managed security groups using the Dashboard - Show ==&lt;br /&gt;
== Managed security groups using the Dashboard - Delete ==&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Network]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=Security_group_rules&amp;diff=1220</id>
		<title>Security group rules</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=Security_group_rules&amp;diff=1220"/>
		<updated>2026-10-28T14:16:24Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page describes the handling of security groups within OpenStack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-|OpenStack CLI=&lt;br /&gt;
= Managed security groups using the CLI =&lt;br /&gt;
This chapter shows guides you through the daily operations regarding security groups in stepping stone AG&#039;s OpenStack based cloud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; This guide assumes that you already have access to the OpenStack CLI and are authenticated. If you are not, follow the [[Quickstart|OpenStack quick start guide]].&lt;br /&gt;
== Managed security groups using the CLI - Create group ==&lt;br /&gt;
A new security group may be created as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;              # Provide a OpenStack project id (such as &#039;ecd2fbce789f4e70bb31613e4e189a43&#039;)&lt;br /&gt;
secgroup_name=&#039;&#039;           # Give it a descriptive name (such as &#039;HTTPS World&#039;)&lt;br /&gt;
secgroup_description=&#039;&#039;    # Describe the security group further.&lt;br /&gt;
&lt;br /&gt;
openstack security group create \&lt;br /&gt;
      --project &amp;quot;${project_id}&amp;quot; \&lt;br /&gt;
      --format value \&lt;br /&gt;
      --column id \&lt;br /&gt;
      --description &amp;quot;${secgroup_description}&amp;quot; \&lt;br /&gt;
      &amp;quot;${secgroup_name}&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon successful creation the OpenStack CLI will simply return the id of the newly created security group:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
5008898e-6307-499a-9d32-470e551d387a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Create rules ==&lt;br /&gt;
Upon creation, a new security group is empty and does not contain any rules.&lt;br /&gt;
&lt;br /&gt;
To create a rule and assign it to the security group, continue as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
project_id=&#039;&#039;              # Provide a OpenStack project id (such as &#039;ecd2fbce789f4e70bb31613e4e189a43&#039;)&lt;br /&gt;
secgroup_id=&#039;&#039;             # Provide the UUID of the newly created security group (such as &#039;5008898e-6307-499a-9d32-470e551d387a&#039;)&lt;br /&gt;
&lt;br /&gt;
openstack security group rule create \&lt;br /&gt;
    --project ${project_id} \&lt;br /&gt;
    --ingress \&lt;br /&gt;
    --ethertype IPv4 \&lt;br /&gt;
    --protocol tcp \&lt;br /&gt;
    --dst-port 443 \&lt;br /&gt;
    --remote-ip &amp;quot;0.0.0.0/0&amp;quot; \&lt;br /&gt;
    ${secgroup_id}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following paramters may be modified to further suit your situation:&lt;br /&gt;
* &#039;&#039;&#039;ingress:&#039;&#039;&#039; The rule may be either a &amp;lt;code&amp;gt;ingress&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;egress&amp;lt;/code&amp;gt; rule.&lt;br /&gt;
* &#039;&#039;&#039;ethertype:&#039;&#039;&#039; May be either &amp;lt;code&amp;gt;IPv4&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;IPv6&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;protocol:&#039;&#039;&#039; May be either &amp;lt;code&amp;gt;tcp&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;udp&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;dst-port:&#039;&#039;&#039; May be any port between &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;65535&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;remote-ip:&#039;&#039;&#039; May be an ip range such as &amp;lt;code&amp;gt;192.168.1.0/24&amp;lt;/code&amp;gt; or a single ip such as &amp;lt;code&amp;gt;192.168.1.100/32&amp;lt;/code&amp;gt;. To allow traffic from anywhere,  use &amp;lt;code&amp;gt;0.0.0.0/0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Upon successful creation, the OpenStack CLI should return an output similar to 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;
| created_at        | 2026-10-28T14:15:12Z                                                                                                                                                                         |&lt;br /&gt;
| description       |                                                                                                                                                                                              |&lt;br /&gt;
| direction         | ingress                                                                                                                                                                                      |&lt;br /&gt;
| ether_type        | IPv4                                                                                                                                                                                         |&lt;br /&gt;
| id                | 2b2c8a6b-6110-4eee-9802-480f1ec12e20                                                                                                                                                         |&lt;br /&gt;
| location          | Munch({&#039;cloud&#039;: &#039;&#039;, &#039;region_name&#039;: &#039;duedingen-test&#039;, &#039;zone&#039;: None, &#039;project&#039;: Munch({&#039;id&#039;: &#039;c2ebdf6ceea9464ea07922ebf8d2f857&#039;, &#039;name&#039;: None, &#039;domain_id&#039;: &#039;default&#039;, &#039;domain_name&#039;: None})}) |&lt;br /&gt;
| name              | None                                                                                                                                                                                         |&lt;br /&gt;
| port_range_max    | 443                                                                                                                                                                                          |&lt;br /&gt;
| port_range_min    | 443                                                                                                                                                                                          |&lt;br /&gt;
| project_id        | ecd2fbce789f4e70bb31613e4e189a43                                                                                                                                                             |&lt;br /&gt;
| protocol          | tcp                                                                                                                                                                                          |&lt;br /&gt;
| remote_group_id   | None                                                                                                                                                                                         |&lt;br /&gt;
| remote_ip_prefix  | 0.0.0.0/0                                                                                                                                                                                    |&lt;br /&gt;
| revision_number   | 0                                                                                                                                                                                            |&lt;br /&gt;
| security_group_id | 5008898e-6307-499a-9d32-470e551d387a                                                                                                                                                         |&lt;br /&gt;
| tags              | []                                                                                                                                                                                           |&lt;br /&gt;
| updated_at        | 2026-10-28T14:15:12Z                                                                                                                                                                         |&lt;br /&gt;
+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - Assign to server ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Managed security groups using the CLI - List ==&lt;br /&gt;
== Managed security groups using the CLI - Show ==&lt;br /&gt;
== Managed security groups using the CLI - Delete ==&lt;br /&gt;
|-|OpenStack Dashboard=&lt;br /&gt;
= Managed security groups using the Dashboard =&lt;br /&gt;
This chapter shows guides you through the daily operations regarding security groups in stepping stone AG&#039;s OpenStack based cloud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; This guide assumes that you already have access to the OpenStack dashboard and are authenticated. If you are not, follow the [[Quickstart|OpenStack quick start guide]].&lt;br /&gt;
== Managed security groups using the Dashboard - Create ==&lt;br /&gt;
== Managed security groups using the Dashboard - Assign to server ==&lt;br /&gt;
== Managed security groups using the Dashboard - List ==&lt;br /&gt;
== Managed security groups using the Dashboard - Show ==&lt;br /&gt;
== Managed security groups using the Dashboard - Delete ==&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Network]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=Quickstart&amp;diff=1219</id>
		<title>Quickstart</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=Quickstart&amp;diff=1219"/>
		<updated>2026-10-28T13:49:26Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page holds a short and concise guide to quickly get started within our OpenStack based cloud with either the [https://dashboard.stoney-cloud.com dashboard] or the command line interface (CLI).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-|OpenStack CLI=&lt;br /&gt;
= OpenStack CLI Installation =&lt;br /&gt;
To use OpenStack CLI, you need to install the OpenStack CLI Client for your OS:&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora&lt;br /&gt;
dnf install python3-openstackclient&lt;br /&gt;
# Debian / Ubuntu&lt;br /&gt;
apt install python3-openstackclient&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The official installaton guide can be found on [https://docs.openstack.org/mitaka/user-guide/common/cli_install_openstack_command_line_clients.html docs.openstack.org].&lt;br /&gt;
&lt;br /&gt;
= OpenStack client environment script (OpenRC file) =&lt;br /&gt;
To increase efficiency of client operations, OpenStack supports simple client environment scripts also known as OpenRC files. These scripts typically contain common options for all clients, but also support unique options.&lt;br /&gt;
&lt;br /&gt;
You may download such an OpenRC file from the [https://dashboard.stoney-cloud.com/ dashboard].&lt;br /&gt;
&lt;br /&gt;
After logging into the [https://dashboard.stoney-cloud.com/ dashboard], click on your user name in the upper right corner and choose the menu option «OpenStack RC File v3» and save it the desired location on your local machine. As you can have multiple OpenRC files, we recommend to use a sub directory. For example &amp;lt;code&amp;gt;openrc&amp;lt;/code&amp;gt; in your home directory.&lt;br /&gt;
&lt;br /&gt;
[[Image:OpenStack_RC_File_v3.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Source the OpenRC file specific to this project (use single quotation marks to avoid problems with spaces in the file name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;bash&#039;&amp;gt;&lt;br /&gt;
source ${HOME}/openrc/&#039;Project Name-openrc.sh&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you sourced the file, you need to enter a password:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Please enter your OpenStack Password for project Project Name as user user: &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check if you have access to the OpenStack API by listing the API endpoints:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;bash&#039;&amp;gt;&lt;br /&gt;
openstack catalog list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;text&#039;&amp;gt;&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Name       | Type      | Endpoints                                                                                        |&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
| glance     | image     | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   internal: https://glance.ctrl-int.os.stoney-cloud.com:9292                                     |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   public: https://api.os.stoney-cloud.com:9292                                                   |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   admin: https://glance.ctrl-int.os.stoney-cloud.com:9292                                        |&lt;br /&gt;
[...]&lt;br /&gt;
| cinderv2   | volumev2  | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   internal: https://cinder.ctrl-int.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187 |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   admin: https://cinder.ctrl-int.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187    |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   public: https://api.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187               |&lt;br /&gt;
|            |           |                                                                                                  |&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Next steps ==&lt;br /&gt;
After gaining initial access using the OpenStack CLI you may continue by using stepping stone AG&#039;s OpenStack based cloud to the fullest:&lt;br /&gt;
&lt;br /&gt;
[[:Category:Instances|Instances]]&lt;br /&gt;
* [[VM creation (Linux)]]&lt;br /&gt;
* [[VM creation (Windows)]]&lt;br /&gt;
* [[VM resize (Linux)]]&lt;br /&gt;
* [[VM resize (Windows)]]&lt;br /&gt;
* [[Flavor explanation]]&lt;br /&gt;
[[:Category:Volumes|Volumes]]&lt;br /&gt;
* [[Quota]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Images|Images]]&lt;br /&gt;
* [[Image creation]]&lt;br /&gt;
[[:Category:Network|Network]]&lt;br /&gt;
* [[Security group rules]]&lt;br /&gt;
* [[IP usage]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Object store|Object store]]&lt;br /&gt;
* [[S3 buckets]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Kubernetes|Kubernetes]]&lt;br /&gt;
* [[Kubernetes management]]&lt;br /&gt;
* [[Kubernetes usage]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Troubleshooting|Troubleshooting]]&lt;br /&gt;
* [[PCI workaround]]&lt;br /&gt;
* [[Change user password]] &lt;br /&gt;
&lt;br /&gt;
|-|OpenStack Dashboard=&lt;br /&gt;
&lt;br /&gt;
= Login via Dashboard =&lt;br /&gt;
Log in to the stoney cloud [https://dashboard.stoney-cloud.com/dashboard dashboard] with the credentials you have received from us. &lt;br /&gt;
&lt;br /&gt;
[[File:Debian VM Creation Dashboard manual 01.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Next steps ==&lt;br /&gt;
After gaining initial access to the OpenStack dashboard you may continue by using stepping stone AG&#039;s OpenStack based cloud to the fullest:&lt;br /&gt;
&lt;br /&gt;
[[:Category:Instances|Instances]]&lt;br /&gt;
* [[VM creation (Linux)]]&lt;br /&gt;
* [[VM creation (Windows)]]&lt;br /&gt;
* [[VM resize (Linux)]]&lt;br /&gt;
* [[VM resize (Windows)]]&lt;br /&gt;
* [[Flavor explanation]]&lt;br /&gt;
[[:Category:Volumes|Volumes]]&lt;br /&gt;
* [[Quota]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Images|Images]]&lt;br /&gt;
* [[Image creation]]&lt;br /&gt;
[[:Category:Network|Network]]&lt;br /&gt;
* [[Security group rules]]&lt;br /&gt;
* [[IP usage]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Object store|Object store]]&lt;br /&gt;
* [[S3 buckets]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Kubernetes|Kubernetes]]&lt;br /&gt;
* [[Kubernetes management]]&lt;br /&gt;
* [[Kubernetes usage]]&lt;br /&gt;
&lt;br /&gt;
[[:Category:Troubleshooting|Troubleshooting]]&lt;br /&gt;
* [[PCI workaround]]&lt;br /&gt;
* [[Change user password]] &lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Dashboard]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=Quickstart&amp;diff=1218</id>
		<title>Quickstart</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=Quickstart&amp;diff=1218"/>
		<updated>2026-10-28T13:45:40Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page holds a short and concise guide to quickly get started within our OpenStack based cloud with either the [https://dashboard.stoney-cloud.com dashboard] or the command line interface (CLI).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-|OpenStack CLI=&lt;br /&gt;
= OpenStack CLI Installation =&lt;br /&gt;
To use OpenStack CLI, you need to install the OpenStack CLI Client for your OS:&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora&lt;br /&gt;
dnf install python3-openstackclient&lt;br /&gt;
# Debian / Ubuntu&lt;br /&gt;
apt install python3-openstackclient&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The official installaton guide can be found on [https://docs.openstack.org/mitaka/user-guide/common/cli_install_openstack_command_line_clients.html docs.openstack.org].&lt;br /&gt;
&lt;br /&gt;
= OpenStack client environment script (OpenRC file) =&lt;br /&gt;
To increase efficiency of client operations, OpenStack supports simple client environment scripts also known as OpenRC files. These scripts typically contain common options for all clients, but also support unique options.&lt;br /&gt;
&lt;br /&gt;
You may download such an OpenRC file from the [https://dashboard.stoney-cloud.com/ dashboard].&lt;br /&gt;
&lt;br /&gt;
After logging into the [https://dashboard.stoney-cloud.com/ dashboard], click on your user name in the upper right corner and choose the menu option «OpenStack RC File v3» and save it the desired location on your local machine. As you can have multiple OpenRC files, we recommend to use a sub directory. For example &amp;lt;code&amp;gt;openrc&amp;lt;/code&amp;gt; in your home directory.&lt;br /&gt;
&lt;br /&gt;
[[Image:OpenStack_RC_File_v3.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Source the OpenRC file specific to this project (use single quotation marks to avoid problems with spaces in the file name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;bash&#039;&amp;gt;&lt;br /&gt;
source ${HOME}/openrc/&#039;Project Name-openrc.sh&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you sourced the file, you need to enter a password:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Please enter your OpenStack Password for project Project Name as user user: &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check if you have access to the OpenStack API by listing the API endpoints:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;bash&#039;&amp;gt;&lt;br /&gt;
openstack catalog list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;text&#039;&amp;gt;&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Name       | Type      | Endpoints                                                                                        |&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
| glance     | image     | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   internal: https://glance.ctrl-int.os.stoney-cloud.com:9292                                     |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   public: https://api.os.stoney-cloud.com:9292                                                   |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   admin: https://glance.ctrl-int.os.stoney-cloud.com:9292                                        |&lt;br /&gt;
[...]&lt;br /&gt;
| cinderv2   | volumev2  | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   internal: https://cinder.ctrl-int.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187 |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   admin: https://cinder.ctrl-int.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187    |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   public: https://api.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187               |&lt;br /&gt;
|            |           |                                                                                                  |&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-|OpenStack Dashboard=&lt;br /&gt;
&lt;br /&gt;
= Login via Dashboard =&lt;br /&gt;
Log in to the stoney cloud [https://dashboard.stoney-cloud.com/dashboard dashboard] with the credentials you have received from us. &lt;br /&gt;
&lt;br /&gt;
[[File:Debian VM Creation Dashboard manual 01.png|600px]]&lt;br /&gt;
&amp;lt;/tabber&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Dashboard]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=Quickstart&amp;diff=1217</id>
		<title>Quickstart</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=Quickstart&amp;diff=1217"/>
		<updated>2026-10-28T13:41:38Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This page holds a short and concise guide to quickly get started within our OpenStack based cloud with either the [https://dashboard.stoney-cloud.com dashboard] or the command line interface (CLI).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabber&amp;gt;&lt;br /&gt;
|-|VM creation CLI=&lt;br /&gt;
= OpenStack CLI Installation =&lt;br /&gt;
To use OpenStack CLI, you need to install the OpenStack CLI Client for your OS:&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Fedora&lt;br /&gt;
dnf install python3-openstackclient&lt;br /&gt;
# Debian / Ubuntu&lt;br /&gt;
apt install python3-openstackclient&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The official installaton guide can be found on [https://docs.openstack.org/mitaka/user-guide/common/cli_install_openstack_command_line_clients.html docs.openstack.org].&lt;br /&gt;
&lt;br /&gt;
= OpenStack client environment script (OpenRC file) =&lt;br /&gt;
To increase efficiency of client operations, OpenStack supports simple client environment scripts also known as OpenRC files. These scripts typically contain common options for all clients, but also support unique options.&lt;br /&gt;
&lt;br /&gt;
You may download such an OpenRC file from the [https://dashboard.stoney-cloud.com/ dashboard].&lt;br /&gt;
&lt;br /&gt;
After logging into the [https://dashboard.stoney-cloud.com/ dashboard], click on your user name in the upper right corner and choose the menu option «OpenStack RC File v3» and save it the desired location on your local machine. As you can have multiple OpenRC files, we recommend to use a sub directory. For example &amp;lt;code&amp;gt;openrc&amp;lt;/code&amp;gt; in your home directory.&lt;br /&gt;
&lt;br /&gt;
[[Image:OpenStack_RC_File_v3.png|600px]]&lt;br /&gt;
&lt;br /&gt;
Source the OpenRC file specific to this project (use single quotation marks to avoid problems with spaces in the file name):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;bash&#039;&amp;gt;&lt;br /&gt;
source ${HOME}/openrc/&#039;Project Name-openrc.sh&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you sourced the file, you need to enter a password:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Please enter your OpenStack Password for project Project Name as user user: &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check if you have access to the OpenStack API by listing the API endpoints:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;bash&#039;&amp;gt;&lt;br /&gt;
openstack catalog list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected output:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;text&#039;&amp;gt;&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
| Name       | Type      | Endpoints                                                                                        |&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
| glance     | image     | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   internal: https://glance.ctrl-int.os.stoney-cloud.com:9292                                     |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   public: https://api.os.stoney-cloud.com:9292                                                   |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   admin: https://glance.ctrl-int.os.stoney-cloud.com:9292                                        |&lt;br /&gt;
[...]&lt;br /&gt;
| cinderv2   | volumev2  | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   internal: https://cinder.ctrl-int.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187 |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   admin: https://cinder.ctrl-int.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187    |&lt;br /&gt;
|            |           | duedingen-production                                                                             |&lt;br /&gt;
|            |           |   public: https://api.os.stoney-cloud.com:8776/v2/616812eda14e44de89138f3377841187               |&lt;br /&gt;
|            |           |                                                                                                  |&lt;br /&gt;
+------------+-----------+--------------------------------------------------------------------------------------------------+&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: CLI]]&lt;br /&gt;
[[Category: Dashboard]]&lt;/div&gt;</summary>
		<author><name>Sst-la1</name></author>
	</entry>
	<entry>
		<id>https://wiki.stoney-cloud.com/w/index.php?title=AI_on_demand:_apertus-ai/Apertus-v1.5-8B&amp;diff=1104</id>
		<title>AI on demand: apertus-ai/Apertus-v1.5-8B</title>
		<link rel="alternate" type="text/html" href="https://wiki.stoney-cloud.com/w/index.php?title=AI_on_demand:_apertus-ai/Apertus-v1.5-8B&amp;diff=1104"/>
		<updated>2026-07-15T08:58:15Z</updated>

		<summary type="html">&lt;p&gt;Sst-la1: Redirected page to AI on demand: apertus-ai/Apertus-v1.5-8B-Prerelease-2607&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[AI on demand: apertus-ai/Apertus-v1.5-8B-Prerelease-2607]]&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=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>
</feed>