forked from aminueza/terraform-provider-minio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0ca3c6
commit 486b9ce
Showing
16 changed files
with
2,324 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
terraform { | ||
required_providers { | ||
minio = { | ||
source = "aminueza/minio" | ||
version = ">= 1.0.0" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} | ||
|
||
provider "minio" { | ||
alias = "deployment_a" | ||
minio_server = var.minio_server_a | ||
minio_region = var.minio_region_a | ||
minio_user = var.minio_user_a | ||
minio_password = var.minio_password_a | ||
} | ||
|
||
provider "minio" { | ||
alias = "deployment_b" | ||
minio_server = var.minio_server_b | ||
minio_region = var.minio_region_b | ||
minio_user = var.minio_user_b | ||
minio_password = var.minio_password_b | ||
} | ||
|
154 changes: 154 additions & 0 deletions
154
examples/resources/minio_s3_bucket_replication/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
resource "minio_s3_bucket" "my_bucket_in_a" { | ||
provider = minio.deployment_a | ||
bucket = "my-bucket" | ||
} | ||
|
||
resource "minio_s3_bucket" "my_bucket_in_b" { | ||
provider = minio.deployment_b | ||
bucket = "my-bucket" | ||
} | ||
|
||
resource "minio_s3_bucket_versioning" "my_bucket_in_a" { | ||
provider = minio.deployment_a | ||
bucket = minio_s3_bucket.my_bucket_in_a.bucket | ||
|
||
versioning_configuration { | ||
status = "Enabled" | ||
} | ||
} | ||
|
||
resource "minio_s3_bucket_versioning" "my_bucket_in_b" { | ||
provider = minio.deployment_b | ||
bucket = minio_s3_bucket.my_bucket_in_b.bucket | ||
|
||
versioning_configuration { | ||
status = "Enabled" | ||
} | ||
} | ||
|
||
data "minio_iam_policy_document" "replication_policy" { | ||
statement { | ||
sid = "EnableReplicationOnBucket" | ||
effect = "Allow" | ||
resources = ["arn:aws:s3:::*"] | ||
|
||
actions = [ | ||
"s3:ListBucket", | ||
] | ||
} | ||
|
||
statement { | ||
sid = "EnableReplicationOnBucket" | ||
effect = "Allow" | ||
resources = ["arn:aws:s3:::my-bucket"] | ||
|
||
actions = [ | ||
"s3:GetReplicationConfiguration", | ||
"s3:ListBucket", | ||
"s3:ListBucketMultipartUploads", | ||
"s3:GetBucketLocation", | ||
"s3:GetBucketVersioning", | ||
"s3:GetBucketObjectLockConfiguration", | ||
"s3:GetEncryptionConfiguration", | ||
] | ||
} | ||
|
||
statement { | ||
sid = "EnableReplicatingDataIntoBucket" | ||
effect = "Allow" | ||
resources = ["arn:aws:s3:::my-bucket/*"] | ||
|
||
actions = [ | ||
"s3:GetReplicationConfiguration", | ||
"s3:ReplicateTags", | ||
"s3:AbortMultipartUpload", | ||
"s3:GetObject", | ||
"s3:GetObjectVersion", | ||
"s3:GetObjectVersionTagging", | ||
"s3:PutObject", | ||
"s3:PutObjectRetention", | ||
"s3:PutBucketObjectLockConfiguration", | ||
"s3:PutObjectLegalHold", | ||
"s3:DeleteObject", | ||
"s3:ReplicateObject", | ||
"s3:ReplicateDelete", | ||
] | ||
} | ||
} | ||
|
||
# One-Way replication (A -> B) | ||
resource "minio_iam_policy" "replication_in_b" { | ||
provider = minio.deployment_b | ||
name = "ReplicationToMyBucketPolicy" | ||
policy = data.minio_iam_policy_document.replication_policy.json | ||
} | ||
|
||
resource "minio_iam_user_policy_attachment" "replication_in_b" { | ||
provider = minio.deployment_b | ||
user_name = "my-user" | ||
policy_name = minio_iam_policy.replication_in_b.id | ||
} | ||
|
||
resource "minio_iam_service_account" "replication_in_b" { | ||
provider = minio.deployment_b | ||
target_user = "my-user" | ||
} | ||
|
||
resource "minio_s3_bucket_replication" "replication_in_b" { | ||
bucket = minio_s3_bucket.my_bucket_in_a.bucket | ||
provider = minio.deployment_a | ||
|
||
rule { | ||
delete_replication = true | ||
delete_marker_replication = true | ||
existing_object_replication = true | ||
metadata_sync = true # SHould be false for one-way | ||
|
||
target = { | ||
bucket = minio_s3_bucket.my_bucket_in_b.bucket | ||
host = var.minio_server_b | ||
bandwidth_limt = "100M" | ||
access_key = minio_iam_service_account.replication_in_b.access_key | ||
secret_key = minio_iam_service_account.replication_in_b.secret_key | ||
} | ||
} | ||
} | ||
|
||
|
||
# Two-Way replication (A <-> B) | ||
resource "minio_iam_policy" "replication_in_a" { | ||
provider = minio.deployment_a | ||
name = "ReplicationToMyBucketPolicy" | ||
policy = data.minio_iam_policy_document.replication_policy.json | ||
} | ||
|
||
resource "minio_iam_user_policy_attachment" "replication_in_a" { | ||
provider = minio.deployment_a | ||
user_name = "my-user" | ||
policy_name = minio_iam_policy.replication_in_a.id | ||
} | ||
|
||
resource "minio_iam_service_account" "replication_in_a" { | ||
provider = minio.deployment_a | ||
target_user = "my-user" | ||
} | ||
|
||
resource "minio_s3_bucket_replication" "replication_in_a" { | ||
bucket = minio_s3_bucket.my_bucket_in_b.bucket | ||
provider = minio.deployment_b | ||
|
||
rule { | ||
delete_replication = true | ||
delete_marker_replication = true | ||
existing_object_replication = true | ||
metadata_sync = true | ||
|
||
target = { | ||
bucket = minio_s3_bucket.my_bucket_in_a.bucket | ||
host = var.minio_server_a | ||
bandwidth_limt = "100M" | ||
access_key = minio_iam_service_account.replication_in_a.access_key | ||
secret_key = minio_iam_service_account.replication_in_a.secret_key | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
examples/resources/minio_s3_bucket_replication/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
variable "minio_region_a" { | ||
description = "Default MINIO region" | ||
default = "us-east-1" | ||
} | ||
|
||
variable "minio_server_a" { | ||
description = "Default MINIO host and port" | ||
default = "localhost:9000" | ||
} | ||
|
||
variable "minio_user_a" { | ||
description = "MINIO user" | ||
default = "minio" | ||
} | ||
|
||
variable "minio_password_a" { | ||
description = "MINIO password" | ||
default = "minio123" | ||
} | ||
|
||
variable "minio_region_b" { | ||
description = "Default MINIO region" | ||
default = "eu-west-1" | ||
} | ||
|
||
variable "minio_server_b" { | ||
description = "Default MINIO host and port" | ||
default = "localhost:9002" | ||
} | ||
|
||
variable "minio_user_b" { | ||
description = "MINIO user" | ||
default = "minio" | ||
} | ||
|
||
variable "minio_password_b" { | ||
description = "MINIO password" | ||
default = "minio321" | ||
} |
Oops, something went wrong.