|
|
(44 intermediate revisions by the same user not shown) |
Line 3: |
Line 3: |
|
| |
|
| = Credential pair = | | = Credential pair = |
| | {{Note|title=Information|content=Unfortunately, ec2 credentials can not be managed via the graphical OpenStack dashboard as of this moment.}} |
| | |
| In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service. | | In order to use the S3 API you have to create EC2 (Amazon Elastic Compute Cloud) credentials using the OpenStack Keystone service. |
|
| |
|
Line 8: |
Line 10: |
|
| |
|
| == Credential pair - Create == | | == Credential pair - Create == |
|
| |
| Create new EC2 credentials in OpenStack using the OpenStack-CLI: | | Create new EC2 credentials in OpenStack using the OpenStack-CLI: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
Line 195: |
Line 196: |
| <tabber> | | <tabber> |
| |-| Aws-cli = | | |-| Aws-cli = |
| To disable versioning of a s3-bucket using the aws-cli, use the following command: | | To create a new s3-bucket using the aws-cli, use the following command: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} | | aws --endpoint-url ${endpoint_url} s3api create-bucket --bucket ${bucket_name} |
Line 215: |
Line 216: |
|
| |
|
| |-| S3cmd = | | |-| S3cmd = |
| To enable versioning of a s3-bucket using s3cmd, use the following command: | | To create a new s3-bucket using s3cmd, use the following command: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| s3cmd mb s3://${bucket_name} | | s3cmd mb s3://${bucket_name} |
Line 226: |
Line 227: |
| Bucket 's3://test76/' created | | Bucket 's3://test76/' created |
| </syntaxhighlight> | | </syntaxhighlight> |
| | |
| | |-| OpenStack Dashboard = |
| | To create a new s3-bucket using the OpenStack dashboard, follow this section. |
| | |
| | First go to <code>Object Store -> Containers</code> and press <code>+ Container</code>: <br> |
| | |
| | [[File:S3-buckets_-_Lifecycle_Create_bucket_01.png|1000px]] |
| | |
| | <br> |
| | After doing that, enter a name that isn't taken yet, press <code>Public</code> or <code>Not public</code> and submit. <br> |
| | |
| | [[File:S3-buckets_-_Lifecycle_Create_bucket_02.png|1000px]] |
| | |
| | <br> |
| | The s3-bucket has been created successfully if it shows up in the list of s3-buckets. <br> |
| | |
| | [[File:S3-buckets_-_Lifecycle_Create_bucket_03.png|1000px]] |
| | |
| | <br> |
| | There you also have the possibility to create new folders and upload files within that s3-bucket. |
|
| |
|
| </tabber> | | </tabber> |
Line 253: |
Line 274: |
|
| |
|
| |-| S3cmd = | | |-| S3cmd = |
| To enable versioning of a s3-bucket using s3cmd, use the following command:
| | s3cmd doesn't support object-locks. |
| <syntaxhighlight lang="bash">
| |
| s3cmd setversioning s3://newfreshs3 disable
| |
| </syntaxhighlight>
| |
| | |
| '''Output:''' | |
| | |
| s3cmd should return the following response:
| |
| <syntaxhighlight lang="bash">
| |
| s3://newfreshs3/: Versioning status updated
| |
| </syntaxhighlight>
| |
| | |
| </tabber> | | </tabber> |
|
| |
|
Line 309: |
Line 319: |
|
| |
|
| If you haven't configured versioning for that particular bucket yet, s3cmd will return the following information: | | If you haven't configured versioning for that particular bucket yet, s3cmd will return the following information: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="text" highlight=5> |
| s3://newfreshs3/ (bucket): | | s3://test77/ (bucket): |
| [...] | | Location: location |
| | Payer: BucketOwner |
| | Ownership: none |
| Versioning:none | | Versioning:none |
| [...] | | Expiration rule: none |
| | Block Public Access: none |
| | Policy: none |
| | CORS: none |
| | ACL: x: FULL_CONTROL |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
| If you have versioning disabled, it will look similar to this: | | If you have versioning disabled, it will look similar to this: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang=text highlight=5> |
| s3://newfreshs3/ (bucket): | | s3://test77/ (bucket): |
| [...] | | Location: location |
| | Payer: BucketOwner |
| | Ownership: none |
| Versioning:Suspended | | Versioning:Suspended |
| [...] | | Expiration rule: none |
| | Block Public Access: none |
| | Policy: none |
| | CORS: none |
| | ACL: x: FULL_CONTROL |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
| If you have versioning configured, it should look similar to this: | | If you have versioning configured, it should look similar to this: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="text" highlight=5> |
| s3://newfreshs3/ (bucket): | | s3://test77/ (bucket): |
| [...] | | Location: location |
| | Payer: BucketOwner |
| | Ownership: none |
| Versioning:Enabled | | Versioning:Enabled |
| [...] | | Expiration rule: none |
| | Block Public Access: none |
| | Policy: none |
| | CORS: none |
| | ACL: x: FULL_CONTROL |
| </syntaxhighlight> | | </syntaxhighlight> |
| </tabber> | | </tabber> |
Line 347: |
Line 374: |
| If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0). | | If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0). |
|
| |
|
| 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: | | 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: |
| <syntaxhighlight lang="json"> | | <syntaxhighlight lang="json"> |
| { | | { |
Line 366: |
Line 393: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| s3://newfreshs3/: Versioning status updated | | s3://newfreshs3/: Versioning status updated |
| | </syntaxhighlight> |
| | |
| | If you then run the [[#Lifecycle_-_Versioning_-_Get_status|Get status]] command you will get an output like this: |
| | <syntaxhighlight lang="text" highlight=5> |
| | s3://test77/ (bucket): |
| | Location: location |
| | Payer: BucketOwner |
| | Ownership: none |
| | Versioning:Enabled |
| | Expiration rule: none |
| | Block Public Access: none |
| | Policy: none |
| | CORS: none |
| | ACL: x: FULL_CONTROL |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
Line 384: |
Line 425: |
| If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0). | | If the aws-cli command ran through successfully, you will get no response (apart from the exit code 0). |
|
| |
|
| 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: | | 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: |
| <syntaxhighlight lang="json"> | | <syntaxhighlight lang="json"> |
| { | | { |
Line 407: |
Line 448: |
| </tabber> | | </tabber> |
|
| |
|
| == Lifecycle - Retention policy == | | == Lifecycle - Object lock == |
| This section explains how to add a retention policy to a s3 bucket. | | This section covers how to manage object locks and set retention policies. |
|
| |
|
| === Lifecycle - Retention policy - Get status === | | === Lifecycle - Object lock - Get retention policy === |
| | Use the following commands to retrieve the current retention policy of a s3-bucket. |
| | |
| | <tabber> |
| | |-| Aws-cli = |
| | To get the retention policy of a s3-bucket using the aws-cli, use the following command: |
| | <syntaxhighlight lang="bash"> |
| | aws --endpoint-url ${endpoint_url} s3api get-object-lock-configuration --bucket ${bucket_name} |
| | </syntaxhighlight> |
| | |
| | '''Output:''' |
| | |
| | The output should look like this: |
| | <syntaxhighlight lang="json"> |
| | { |
| | "ObjectLockConfiguration": { |
| | "ObjectLockEnabled": "Enabled" |
| | } |
| | } |
| | </syntaxhighlight> |
| | |
| | If it looks like this instead, then you created the s3-bucket without the '--object-lock-enabled-for-bucket'-flag ([[#Lifecycle_-_Create_bucket_with_object_locking|Create bucket with object lock enabled]]). |
| | <syntaxhighlight lang="text"> |
| | An error occurred (ObjectLockConfigurationNotFoundError) when calling the GetObjectLockConfiguration operation: Unknown |
| | </syntaxhighlight> |
| | |
| | If you already have a retention policy set, then the output might look something like this: |
| | <syntaxhighlight lang="json"> |
| | { |
| | "ObjectLockConfiguration": { |
| | "ObjectLockEnabled": "Enabled", |
| | "Rule": { |
| | "DefaultRetention": { |
| | "Mode": "COMPLIANCE", |
| | "Days": 3 |
| | } |
| | } |
| | } |
| | } |
| | </syntaxhighlight> |
| | |
| | |-| S3cmd = |
| | Not supported by s3cmd. |
| | </tabber> |
| | |
| | === Lifecycle - Object lock - Set retention policy === |
| | Use the following commands to set the retention policy of a s3-bucket. |
| | |
| | <tabber> |
| | |-| Aws-cli = |
| | To set the retention time of a s3-bucket to a certain amount of days, use the following command: |
| | <syntaxhighlight lang="bash"> |
| | aws --endpoint-url ${endpoint_url} s3api put-object-lock-configuration --bucket ${bucket_name} --object-lock-configuration 'ObjectLockEnabled=Enabled,Rule={DefaultRetention={Mode=COMPLIANCE,Days=3}}' |
| | </syntaxhighlight> |
| | |
| | '''Output:''' |
| | |
| | The command will give you no output (apart from the status code 0). |
| | |
| | To check the retention policy of the s3-bucket, use the [[#Lifecycle_-_Object_lock_-_Get_retention_policy|get-object-lock-configuration command]]. |
| | The output should then look like this: |
| | <syntaxhighlight lang="json"> |
| | { |
| | "ObjectLockConfiguration": { |
| | "ObjectLockEnabled": "Enabled", |
| | "Rule": { |
| | "DefaultRetention": { |
| | "Mode": "COMPLIANCE", |
| | "Days": 3 |
| | } |
| | } |
| | } |
| | } |
| | </syntaxhighlight> |
| | |
| | |-| S3cmd = |
| | Not supported by s3cmd. |
| | </tabber> |
| | |
| | == Lifecycle - Policy == |
| | This section explains how to add a policy to a s3 bucket. |
| | |
| | === Lifecycle - Policy - Get status === |
| To get the bucket policy, run the following commands. | | To get the bucket policy, run the following commands. |
|
| |
|
Line 422: |
Line 545: |
| '''Output:''' | | '''Output:''' |
|
| |
|
| If the bucket has no retention policy, then the output should look something like this: | | If the bucket has no policy, then the output should look something like this: |
| <syntaxhighlight lang="text"> | | <syntaxhighlight lang="text"> |
| An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist | | An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
| if the bucket has a retention policy, then the output should look something like this: | | if the bucket has a policy, then the output should look something like this: |
| <syntaxhighlight lang="json"> | | <syntaxhighlight lang="json"> |
| { | | { |
Line 443: |
Line 566: |
| '''Output:''' | | '''Output:''' |
|
| |
|
| If the bucket has no retention policy, then the output will look something like this: | | If the bucket has no policy, then the output will look something like this: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash" highlight=8> |
| s3://newfreshs3/ (bucket): | | s3://test77/ (bucket): |
| [...] | | Location: location |
| | Payer: BucketOwner |
| | Ownership: none |
| | Versioning:Enabled |
| | Expiration rule: none |
| | Block Public Access: none |
| Policy: none | | Policy: none |
| [...] | | CORS: none |
| | ACL: x: FULL_CONTROL |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
| If the bucket has a retention policy, then the output will look something like this: | | If the bucket has a policy, then the output will look something like this: |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| s3://secondtest/ (bucket): | | s3://secondtest/ (bucket): |
Line 481: |
Line 610: |
| </tabber> | | </tabber> |
|
| |
|
| === Lifecycle - Retention policy - Set policy === | | === Lifecycle - Policy - Set policy === |
| A typical json formatted policy-file will look something like this: | | A typical json formatted policy-file will look something like this: |
| <syntaxhighlight lang="json"> | | <syntaxhighlight lang="json"> |
Line 534: |
Line 663: |
| </tabber> | | </tabber> |
|
| |
|
| === Lifecycle - Retention policy - Remove Policy === | | === Lifecycle - Policy - Remove Policy === |
| The following commands are used to remove a policy that is no longer wanted: | | The following commands are used to remove a policy that is no longer wanted: |
|
| |
|