Skip to content

Commit 6507040

Browse files
committed
Restructure ECR Terraform module to align with team conventions
1 parent cdd2fe8 commit 6507040

8 files changed

Lines changed: 58 additions & 61 deletions

File tree

terraform/ecr/outputs.tf

Lines changed: 0 additions & 14 deletions
This file was deleted.

terraform/ecr/terraform.tfvars

Lines changed: 0 additions & 8 deletions
This file was deleted.

terraform/ecr/.terraform.lock.hcl renamed to terraform/environments/staging/.terraform.lock.hcl

Lines changed: 16 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
provider "aws" {
2+
region = "us-east-1"
3+
4+
default_tags {
5+
tags = {
6+
Project = "spring-petclinic-microservices"
7+
ManagedBy = "Terraform"
8+
Environment = "staging"
9+
Sprint = "S2-Core-Infrastructure"
10+
Task = "SPC-005-T4"
11+
}
12+
}
13+
}
14+
15+
module "ecr" {
16+
source = "../../modules/ecr"
17+
18+
aws_region = "us-east-1"
19+
environment = "staging"
20+
repository_prefix = "spring-petclinic"
21+
image_tag_mutability = "MUTABLE"
22+
encryption_type = "AES256"
23+
max_image_count = 10
24+
image_tag = "7a700b9"
25+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.tfstate.*
55
crash.log
66
.terraform.lock.hcl
7+
terraform.tfvars
Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
1-
terraform {
2-
required_version = ">= 1.5.0"
3-
required_providers {
4-
aws = {
5-
source = "hashicorp/aws"
6-
version = "~> 5.0"
7-
}
8-
}
9-
}
101

11-
provider "aws" {
12-
region = var.aws_region
13-
default_tags {
14-
tags = {
15-
Project = "spring-petclinic-microservices"
16-
ManagedBy = "Terraform"
17-
Environment = var.environment
18-
Sprint = "S2-Core-Infrastructure"
19-
Task = "SPC-005-T4"
20-
}
21-
}
22-
}
2+
3+
234

245
data "aws_caller_identity" "current" {}
256
data "aws_region" "current" {}

terraform/modules/ecr/outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
output "repository_urls" {
2+
value = {
3+
for svc, repo in aws_ecr_repository.microservices :
4+
svc => repo.repository_url
5+
}
6+
}
7+
8+
output "registry_url" {
9+
value = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.aws_region}.amazonaws.com"
10+
}
11+
12+
output "docker_login_command" {
13+
value = "aws ecr get-login-password --region ${var.aws_region} | docker login --username AWS --password-stdin ${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.aws_region}.amazonaws.com"
14+
}

0 commit comments

Comments
 (0)