AWS CLI
IONOS S3 Object Storage supports using Amazon's AWS Command Line Interface (AWS CLI) for Windows, macOS, and Linux.
For the installation instructions, see Installing or updating the latest version of the AWS CLI.
Configuration
Run the following command in a terminal:
aws configure.AWS Access Key ID [None]: Insert the Access Key. To get it, log in to the DCD, go to Menu > Storage > IONOS S3 Object Storage > Key management.
AWS Secret Access Key [None]: Paste the Secret Key. It can be found in the Data Center Designer by selecting Storage > S3 Key Management.
Default region name [None]:
de.Default output format [None]:
json.
Using AWS CLI with IONOS S3 Object Storage
For each command, be sure to include one of the endpoints in the endpoint-url parameter:
--endpoint-url https://s3-eu-central-2.ionoscloud.comThere are 2 sets of commands:
s3: Offers high-level commands for managing S3 buckets and for moving, copying, and synchronizing objects.
s3api: Allows you to work with specific features such as ACL, CORS, and Versioning.
Sample Usage
List buckets:
Option 1: Using s3 set of commands
aws s3 ls s3://my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.comOption 2: Using s3api set of commands
aws s3api list-buckets --endpoint-url https://s3-eu-central-2.ionoscloud.com
Create a bucket in the
eu-central-2region (Berlin, Germany):Option 1: Using s3 set of commands
aws s3 mb s3://my-bucket --region eu-central-2 --endpoint-url https://s3-eu-central-2.ionoscloud.comOption 2: Using s3api set of commands
aws s3api create-bucket --bucket my-bucket --region=eu-central-2 --create-bucket-configuration LocationConstraint=eu-central-2 --endpoint-url https://s3-eu-central-2.ionoscloud.com
Create a bucket in the
deregion (Frankfurt, Germany) with Object Lock enabled:aws s3api create-bucket --bucket my-bucket --object-lock-enabled-for-bucket --region=de --create-bucket-configuration LocationConstraint=de --endpoint-url https://s3-eu-central-1.ionoscloud.comUpload an object from the current directory to a bucket:
aws s3 cp filename.txt s3://my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.comCopy the object to the bucket:
aws s3 cp my-dir s3://my-bucket/ --recursive --endpoint-url https://s3-eu-central-2.ionoscloud.comCopy the contents of the local directory
my-dirto the bucketmy-bucket:aws s3 cp my-dir s3://my-bucket/ --recursive --endpoint-url https://s3-eu-central-2.ionoscloud.comFor more information, see cp command reference.
Copy all objects from
my-source-buckettomy-dest-bucketexcluding .zip files. The command doesn’t support cross-region copying for IONOS S3 Object Storage:aws s3 cp s3://my-source-bucket/ s3://my-dest-bucket/ --recursive --exclude "*.zip" --endpoint-url https://s3-eu-central-2.ionoscloud.com`Download all the objects from the
my-bucketbucket to the local directorymy-dir:aws s3 cp s3://my-bucket my-dir --recursive --endpoint-url https://s3-eu-central-2.ionoscloud.comSync the bucket
my-bucketwith the contents of the local directorymy-dir:aws s3 sync my-dir s3://my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.comFor more information, see sync command reference.
Get Cross-Origin Resource Sharing (CORS) configuration:
aws s3api get-bucket-cors --bucket my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.comSet up Cross-Origin Resource Sharing (CORS) configuration:
aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.json --endpoint-url https://s3-eu-central-2.ionoscloud.comcors.json:
{ "CORSRules": [ { "AllowedOrigins": ["http://www.example.com"], "AllowedHeaders": ["*"], "AllowedMethods": ["PUT", "POST", "DELETE"], "MaxAgeSeconds": 3000, "ExposeHeaders": ["x-amz-server-side-encryption"] }, { "AllowedOrigins": ["*"], "AllowedHeaders": ["Authorization"], "AllowedMethods": ["GET"], "MaxAgeSeconds": 3000 } ] }For more information, see put-bucket-cors command reference.
Enable versioning for the bucket:
aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled --endpoint-url https://s3-eu-central-2.ionoscloud.comGet versioning state of the bucket:
aws s3api get-bucket-versioning --bucket my-bucket --endpoint-url https://s3-eu-central-2.ionoscloud.comSet up a lifetime policy for a bucket (delete objects starting with "my/prefix/" older than 5 days):
aws s3api put-bucket-lifecycle-configuration --bucket my-bucket --lifecycle-configuration file://delete-after-5-days.json --endpoint-url https://s3-eu-central-2.ionoscloud.comdelete-after-5-days.json:
{ "Rules": [ { "ID" : "Delete older than 5 days", "Expiration" : { "Days": 5 }, "Filter": { "Prefix": "my/prefix/" }, "Status" : "Enabled" } ] }
Last updated
Was this helpful?