diff --git a/README.md b/README.md index 904d86a..c0b15c5 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ module "example_team_s3" { is-production = "false" environment-name = "development" infrastructure-support = "example-team@digtal.justice.gov.uk" + aws-s3-region = "eu-west-1" } ``` diff --git a/example/main.tf b/example/main.tf index eb00e8f..42d25d2 100644 --- a/example/main.tf +++ b/example/main.tf @@ -13,7 +13,7 @@ provider "aws" { * */ module "example_team_s3_bucket" { - source = "github.com/ministryofjustice/cloud-platform-terraform-s3-bucket?ref=1.0" + source = "github.com/ministryofjustice/cloud-platform-terraform-s3-bucket?ref=2.0" team_name = "cloudplatform" business-unit = "mojdigital" @@ -21,6 +21,7 @@ module "example_team_s3_bucket" { is-production = "false" environment-name = "development" infrastructure-support = "platform@digtal.justice.gov.uk" + aws-s3-region = "eu-west-2" } resource "kubernetes_secret" "example_team_s3_bucket" { diff --git a/main.tf b/main.tf index fec61a5..9a69699 100644 --- a/main.tf +++ b/main.tf @@ -1,15 +1,21 @@ data "aws_caller_identity" "current" {} data "aws_region" "current" {} +provider "aws" { + alias = "destination" + region = "${var.aws-s3-region}" +} + resource "random_id" "id" { byte_length = 16 } resource "aws_s3_bucket" "bucket" { + provider = "aws.destination" bucket = "cloud-platform-${random_id.id.hex}" acl = "${var.acl}" force_destroy = "true" - region = "${data.aws_region.current.name}" + region = "${var.aws-s3-region}" server_side_encryption_configuration { rule { @@ -30,6 +36,7 @@ resource "aws_s3_bucket" "bucket" { environment-name = "${var.environment-name}" owner = "${var.team_name}" infrastructure-support = "${var.infrastructure-support}" + aws-s3-region = "${var.aws-s3-region}" } } diff --git a/variables.tf b/variables.tf index e04d926..52ad994 100644 --- a/variables.tf +++ b/variables.tf @@ -26,3 +26,8 @@ variable "versioning" { description = "version objects stored within your bucket. " default = false } + +variable "aws-s3-region" { + description= "Region into whicn the bucket will be created" + default = "eu-west-1" +} \ No newline at end of file