From beaf116f69700126f51328e00aefc97743f22fe0 Mon Sep 17 00:00:00 2001 From: Mourad T Date: Mon, 18 Mar 2019 17:17:38 +0000 Subject: [PATCH 1/3] add region input to s3 module, defaults to eu-west-1 --- example/main.tf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/example/main.tf b/example/main.tf index eb00e8f..0b0368d 100644 --- a/example/main.tf +++ b/example/main.tf @@ -1,6 +1,4 @@ -terraform { - backend "s3" {} -} + provider "aws" { region = "eu-west-1" @@ -21,6 +19,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" { From 90feeb4313311a92128de151a554e12604a57c6b Mon Sep 17 00:00:00 2001 From: Mourad T Date: Mon, 18 Mar 2019 17:20:00 +0000 Subject: [PATCH 2/3] add region input to s3 module, edited the module source ref, defaults to eu-west-1 --- README.md | 1 + example/main.tf | 2 +- main.tf | 9 ++++++++- variables.tf | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) 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 0b0368d..97bb840 100644 --- a/example/main.tf +++ b/example/main.tf @@ -11,7 +11,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" 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 From f3eedc1df9c947f2298a0379bc76cf9063b2a3ea Mon Sep 17 00:00:00 2001 From: Mourad T Date: Mon, 18 Mar 2019 17:21:45 +0000 Subject: [PATCH 3/3] rollback tf block --- example/main.tf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/main.tf b/example/main.tf index 97bb840..42d25d2 100644 --- a/example/main.tf +++ b/example/main.tf @@ -1,4 +1,6 @@ - +terraform { + backend "s3" {} +} provider "aws" { region = "eu-west-1"