AWS CLI
AWS CLI is a command line tool that you can use to interact with the IONOS S3 Object Storage service. It is available for Windows, macOS, and Linux.
You can follow the installation instructions described here.
Configuration
Run the following command in a terminal:
aws configure
AWS Access Key ID [None]: Insert the Access Key. It can be found in the Data Center Designer by selecting Manager resources > Object Storage Key Manager
AWS Secret Access Key [None]: Paste the Secret Key. It can be found in the Data Center Designer - Manager resources / Object Storage Key Manager
Default region name [None]:
eu-central-1
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.com
There 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:
aws s3api list-buckets --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Create a bucket in the
eu-central-2
region (Berlin, Germany):
aws s3api create-bucket --bucket my-bucket --endpoint-url=https://s3-eu-central-2.ionoscloud.com --region=eu-south-1
Upload an object from the current directory to a bucket (see more examples):
aws s3 cp filename.txt s3://my-bucket --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Copy the object to the bucket:
aws s3 cp my-dir s3://my-bucket/ --recursive --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Copy the contents of the local directory
my-dir
to the bucketmy-bucket
:
aws s3 cp my-dir s3://my-bucket/ --recursive --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Copy all objects from
my-source-bucket
tomy-dest-bucket
excluding .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-bucket
bucket to the local directorymy-dir
:
aws s3 cp s3://my-bucket my-dir --recursive --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Sync the bucket
my-bucket
with the contents of the local directorymy-dir
(more examples):
aws s3 sync my-dir s3://my-bucket --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Get Cross-Origin Resource Sharing (CORS) configuration:
aws s3api get-bucket-cors --bucket my-bucket --endpoint-url=https://s3-eu-central-2.ionoscloud.com
Set up Cross-Origin Resource Sharing (CORS) configuration (more examples):
aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.json --endpoint-url=https://s3-eu-central-2.ionoscloud.com
cors.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
}
]
}
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.com
Set 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.com
delete-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?