Skip to content

Commit 10a08f4

Browse files
authored
move ECR repo creation to shared-env (#236)
1 parent 87f27a9 commit 10a08f4

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

templates/terraform/environments/prod/main.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ provider "aws" {
2929
allowed_account_ids = [local.account_id]
3030
}
3131

32-
# remote state of "shared" - contains mostly IAM users that will be shared between environments
32+
# remote state of "shared" - contains IAM users that will be shared between environments and ecr repository for docker images
3333
data "terraform_remote_state" "shared" {
3434
backend = "s3"
3535
config = {
@@ -52,9 +52,6 @@ module "prod" {
5252
allowed_account_ids = [local.account_id]
5353
random_seed = local.random_seed
5454

55-
# ECR configuration
56-
ecr_repositories = [] # Should be created by the staging environment
57-
5855
# EKS configuration
5956
eks_cluster_version = "1.21"
6057
# Cluster addons. These often need to be updated when upgrading the cluster version.

templates/terraform/environments/shared/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ resource "aws_iam_access_key" "access_user" {
110110
depends_on = [aws_iam_user.access_user]
111111
}
112112

113+
data "aws_iam_user" "ci_user" {
114+
user_name = local.ci_user_name
115+
}
116+
117+
module "ecr" {
118+
source = "commitdev/zero/aws//modules/ecr"
119+
version = "0.4.0"
120+
121+
environment = "stage"
122+
ecr_repositories = [local.project]
123+
ecr_principals = [data.aws_iam_user.ci_user.arn]
124+
}
125+
126+
113127
module "secret_keys" {
114128
source = "commitdev/zero/aws//modules/secret"
115129
version = "0.0.2"

templates/terraform/environments/stage/main.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ provider "aws" {
2929
allowed_account_ids = [local.account_id]
3030
}
3131

32-
# remote state of "shared" - contains mostly IAM users that will be shared between environments
32+
# remote state of "shared" - contains IAM users that will be shared between environments and ecr repository for docker images
3333
data "terraform_remote_state" "shared" {
3434
backend = "s3"
3535
config = {
@@ -63,9 +63,6 @@ module "stage" {
6363
allowed_account_ids = [local.account_id]
6464
random_seed = local.random_seed
6565

66-
# ECR configuration
67-
ecr_repositories = [ local.project ]
68-
6966
# EKS configuration
7067
eks_cluster_version = "1.21"
7168
# Cluster addons. These often need to be updated when upgrading the cluster version.

templates/terraform/modules/environment/main.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ locals {
3232
]
3333
}
3434

35-
data "aws_iam_user" "ci_user" {
36-
user_name = var.ci_user_name
37-
}
3835

3936
module "vpc" {
4037
source = "commitdev/zero/aws//modules/vpc"
@@ -125,15 +122,6 @@ module "db" {
125122
database_engine = var.database
126123
}
127124

128-
module "ecr" {
129-
source = "commitdev/zero/aws//modules/ecr"
130-
version = "0.4.0"
131-
132-
environment = var.environment
133-
ecr_repositories = var.ecr_repositories
134-
ecr_principals = [data.aws_iam_user.ci_user.arn]
135-
}
136-
137125
module "logging" {
138126
source = "commitdev/zero/aws//modules/logging"
139127
version = "0.4.0"

templates/terraform/modules/environment/variables.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ variable "random_seed" {
1919
description = "A randomly generated string to prevent collisions of resource names - should be unique within an AWS account"
2020
}
2121

22-
variable "ecr_repositories" {
23-
description = "List of ECR repository names to create"
24-
type = list(string)
25-
}
2622

2723
variable "eks_cluster_version" {
2824
description = "EKS cluster version number to use. Incrementing this will start a cluster upgrade"
@@ -47,7 +43,7 @@ variable "eks_addon_coredns_version" {
4743
}
4844

4945
variable "eks_node_groups" {
50-
type = any
46+
type = any
5147
description = "Map of maps of eks node group config where keys are node group names. See the EKS module documentation for details"
5248
}
5349

0 commit comments

Comments
 (0)