Examples
Basic S3 Bucket Example
Info:
— The access_key
and secret_key
can be retrieved in the DCD, go to Menu > Storage > IONOS S3 Object Storage > Key management.
— For the list of IONOS S3 Object Storage Service endpoints, see S3 Endpoints.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.50.0"
}
}
}
provider "aws" {
region = "de"
access_key = "access_key_here"
secret_key = "secret_key_here"
# all these checks need to be skipped for an s3 external provider
skip_credentials_validation = true
skip_requesting_account_id = true
skip_region_validation = true
endpoints {
s3 = "https://s3-eu-central-1.ionoscloud.com"
}
}
resource "aws_s3_bucket" "tf_bucket_name_here" {
bucket = "unique_name_here"
tags = {
Name = "my bucket name tag"
Environment = "dev"
}
}
S3 bucket with object lock enabled
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.50.0"
}
}
}
provider "aws" {
region = "de"
access_key = "access_key_here"
secret_key = "secret_key_here"
# all these checks need to be skipped for an s3 external provider
skip_credentials_validation = true
skip_requesting_account_id = true
skip_region_validation = true
endpoints {
s3 = "https://s3-eu-central-1.ionoscloud.com"
}
}
resource "aws_s3_bucket" "backup_bucket" {
bucket = "unique_name_here"
tags = {
Name = "backup bucket"
Environment = "dev"
}
object_lock_configuration {
object_lock_enabled = "Enabled"
rule {
default_retention {
days = 10
mode = "COMPLIANCE"
}
}
}
}
S3 bucket with versioning enabled
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.50.0"
}
}
}
provider "aws" {
region = "de"
access_key = "access_key_here"
secret_key = "secret_key_here"
# all these checks need to be skipped for an s3 external provider
skip_credentials_validation = true
skip_requesting_account_id = true
skip_region_validation = true
endpoints {
s3 = "https://s3.eu-central-1.ionoscloud.com"
}
}
resource "aws_s3_bucket" "example" {
bucket = "unique_name_here"
}
resource "aws_s3_bucket_versioning" "example" {
bucket = aws_s3_bucket.example.id
versioning_configuration {
status = "Enabled"
}
}
Last updated