diff --git a/infrastructure/terraform/main.tf b/infrastructure/terraform/main.tf index 81f23f63..a64788a4 100644 --- a/infrastructure/terraform/main.tf +++ b/infrastructure/terraform/main.tf @@ -96,6 +96,13 @@ module "s3" { allowed_origins = var.allowed_origins } +module "s3" { + source = "./modules/s3" + bucketname = "retrofit-model-directory-${var.stage}" + allowed_origins = var.allowed_origins +} + + # Set up the route53 record for the API module "route53" { source = "./modules/route53" @@ -108,6 +115,11 @@ module "route53" { # Create an ECR repository for storage of the lambda's docker images module "ecr" { - source = "./modules/ecr" - environment = var.stage + name = "fastapi-repository-${var.environment}" + source = "./modules/ecr" +} + +module "ecr" { + name = "lambda-sap-prediction-${var.environment}" + source = "./modules/ecr" } diff --git a/infrastructure/terraform/modules/ecr/main.tf b/infrastructure/terraform/modules/ecr/main.tf index 5a30c3cf..468ef3d2 100644 --- a/infrastructure/terraform/modules/ecr/main.tf +++ b/infrastructure/terraform/modules/ecr/main.tf @@ -1,6 +1,7 @@ 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 + name = "${var.ecr_name}" + image_tag_mutability = "MUTABLE" + # Allows overwriting image tags, change to IMMUTABLE if you want to prevent overwriting image_scanning_configuration { scan_on_push = true @@ -15,7 +16,7 @@ resource "aws_ecr_lifecycle_policy" "my_repository_policy" { { rulePriority = 1 description = "Retain only the last 10 images" - selection = { + selection = { tagStatus = "any" countType = "imageCountMoreThan" countNumber = 10 diff --git a/infrastructure/terraform/modules/ecr/variables.tf b/infrastructure/terraform/modules/ecr/variables.tf index 108bb626..c916f875 100644 --- a/infrastructure/terraform/modules/ecr/variables.tf +++ b/infrastructure/terraform/modules/ecr/variables.tf @@ -1,4 +1,4 @@ -variable "environment" { - description = "The environment for the ECR repository (dev or prod)" +variable "ecr_name" { + description = "The name for the ECR repository" type = string } \ No newline at end of file