mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
added ecr module to terraform repo
This commit is contained in:
parent
ad6ed75cc3
commit
517409dfe0
4 changed files with 44 additions and 1 deletions
|
|
@ -98,4 +98,10 @@ module "route53" {
|
|||
providers = {
|
||||
aws.aws_use1 = aws.aws_use1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Create an ECR repository for storage of the lambda's docker images
|
||||
module "ecr" {
|
||||
source = "./modules/ecr"
|
||||
environment = var.stage
|
||||
}
|
||||
|
|
|
|||
29
infrastructure/terraform/modules/ecr/main.tf
Normal file
29
infrastructure/terraform/modules/ecr/main.tf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
resource "aws_ecr_repository" "my_repository" {
|
||||
name = "fastapi-repository-${var.environment}"
|
||||
image_tag_mutability = "MUTABLE" # Allows overwriting image tags, change to IMMUTABLE if you want to prevent overwriting
|
||||
|
||||
image_scanning_configuration {
|
||||
scan_on_push = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_ecr_lifecycle_policy" "my_repository_policy" {
|
||||
repository = aws_ecr_repository.my_repository.name
|
||||
|
||||
policy = jsonencode({
|
||||
rules = [
|
||||
{
|
||||
rulePriority = 1
|
||||
description = "Retain only the last 10 images"
|
||||
selection = {
|
||||
tagStatus = "any"
|
||||
countType = "imageCountMoreThan"
|
||||
countNumber = 10
|
||||
}
|
||||
action = {
|
||||
type = "expire"
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
4
infrastructure/terraform/modules/ecr/outputs.tf
Normal file
4
infrastructure/terraform/modules/ecr/outputs.tf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
output "ecr_repository_name" {
|
||||
description = "Name of the EPR repo in AWS"
|
||||
value = aws_ecr_repository.my_repository.name
|
||||
}
|
||||
4
infrastructure/terraform/modules/ecr/variables.tf
Normal file
4
infrastructure/terraform/modules/ecr/variables.tf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
variable "environment" {
|
||||
description = "The environment for the ECR repository (dev or prod)"
|
||||
type = string
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue