Skip to content

Commit

Permalink
Merge pull request #9 from ministryofjustice/feature/region-input
Browse files Browse the repository at this point in the history
Feature/region input
  • Loading branch information
mtrbls authored Mar 19, 2019
2 parents 19ed726 + f3eedc1 commit 327d0ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module "example_team_s3" {
is-production = "false"
environment-name = "development"
infrastructure-support = "[email protected]"
aws-s3-region = "eu-west-1"
}
```

Expand Down
3 changes: 2 additions & 1 deletion example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ 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"
application = "cloud-platform-terraform-s3-bucket"
is-production = "false"
environment-name = "development"
infrastructure-support = "[email protected]"
aws-s3-region = "eu-west-2"
}

resource "kubernetes_secret" "example_team_s3_bucket" {
Expand Down
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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}"
}
}

Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 327d0ee

Please sign in to comment.