Skip to content

Commit

Permalink
Merge pull request #13 from ministryofjustice/feature/default-region-…
Browse files Browse the repository at this point in the history
…eu-est-2

Feature/default region eu est 2
  • Loading branch information
jasonBirchall authored Mar 26, 2019
2 parents 7e9b4d2 + 1ca9dd2 commit 1d8821d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ module "best_team_ecr_credentials" {
repo_name = "test-repo"
team_name = "best-team"
aws_region= "eu-west-2"
}
```

Note: From version 3.0 of this module, The AWS region will default to eu-west-2 (London). If you want to deploy to eu-west-1(Ireland), edit the above accordingly.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| repo_name | name of the repository to be created | string | - | yes |
| team_name | name of the team creating the credentials | string | - | yes |
| enable_policy | Sets a ECR lifecycle policy to delete every image after count 40 | string | true | yes |
| enable_policy | Sets a ECR lifecycle policy to delete every image after count 40 | string | true | yes
| aws_region | region into which the resource will be created | string | eu-west-2 | no
|

## Outputs

Expand Down
7 changes: 4 additions & 3 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ provider "aws" {
*
*/
module "example_team_ecr_credentials" {
source = "github.com/ministryofjustice/cloud-platform-terraform-ecr-credentials?ref=2.1"
repo_name = "example-repo"
team_name = "example-team"
source = "github.com/ministryofjustice/cloud-platform-terraform-ecr-credentials?ref=3.0"
repo_name = "example-module"
team_name = "example-team"
aws_region = "eu-west-2" # this overwrite the region from the provider defined above.
}

resource "kubernetes_secret" "example_team_ecr_credentials" {
Expand Down
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

provider "aws" {
alias = "destination"
region = "${var.aws_region}"
}

resource "aws_ecr_repository" "repo" {
name = "${var.team_name}/${var.repo_name}"
provider = "aws.destination"
name = "${var.team_name}/${var.repo_name}"
}

resource "aws_ecr_lifecycle_policy" "lifecycle_policy" {
provider = "aws.destination"
count = "${var.enable_policy ? 1 : 0}"
repository = "${aws_ecr_repository.repo.name}"

Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ variable "enable_policy" {
description = "Sets a ECR lifecycle policy to delete every image after count 40. Default is true."
default = true
}

variable "aws_region" {
description = "Region into which the resource will be created."
default = "eu-west-2"
}

0 comments on commit 1d8821d

Please sign in to comment.