mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 13:55:50 +00:00
Add ECR repository name output for debugging
This commit is contained in:
parent
171da4b97b
commit
dbd3abc82a
1 changed files with 16 additions and 10 deletions
|
@ -2,19 +2,25 @@ provider "aws" {
|
||||||
region = var.aws_region
|
region = var.aws_region
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create a local value to ensure we always have a valid environment name
|
||||||
|
locals {
|
||||||
|
# If environment is empty, default to "dev"
|
||||||
|
env_name = var.environment != "" ? var.environment : "dev"
|
||||||
|
}
|
||||||
|
|
||||||
# S3 bucket for storing artifacts
|
# S3 bucket for storing artifacts
|
||||||
resource "aws_s3_bucket" "artifacts" {
|
resource "aws_s3_bucket" "artifacts" {
|
||||||
bucket = "petclinic-${var.environment}-artifacts"
|
bucket = "petclinic-${local.env_name}-artifacts"
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "PetClinic Artifacts"
|
Name = "PetClinic Artifacts"
|
||||||
Environment = var.environment
|
Environment = local.env_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ECR repository for Docker images
|
# ECR repository for Docker images
|
||||||
resource "aws_ecr_repository" "petclinic" {
|
resource "aws_ecr_repository" "petclinic" {
|
||||||
name = "petclinic-${var.environment}"
|
name = "petclinic-${local.env_name}"
|
||||||
|
|
||||||
image_scanning_configuration {
|
image_scanning_configuration {
|
||||||
scan_on_push = true
|
scan_on_push = true
|
||||||
|
@ -22,13 +28,13 @@ resource "aws_ecr_repository" "petclinic" {
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "PetClinic Docker Repository"
|
Name = "PetClinic Docker Repository"
|
||||||
Environment = var.environment
|
Environment = local.env_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ECS cluster
|
# ECS cluster
|
||||||
resource "aws_ecs_cluster" "petclinic" {
|
resource "aws_ecs_cluster" "petclinic" {
|
||||||
name = "petclinic-${var.environment}"
|
name = "petclinic-${local.env_name}"
|
||||||
|
|
||||||
setting {
|
setting {
|
||||||
name = "containerInsights"
|
name = "containerInsights"
|
||||||
|
@ -37,13 +43,13 @@ resource "aws_ecs_cluster" "petclinic" {
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "PetClinic Cluster"
|
Name = "PetClinic Cluster"
|
||||||
Environment = var.environment
|
Environment = local.env_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Security group for the ECS tasks
|
# Security group for the ECS tasks
|
||||||
resource "aws_security_group" "ecs_tasks" {
|
resource "aws_security_group" "ecs_tasks" {
|
||||||
name = "petclinic-${var.environment}-tasks-sg"
|
name = "petclinic-${local.env_name}-tasks-sg"
|
||||||
description = "Allow inbound traffic to petclinic application"
|
description = "Allow inbound traffic to petclinic application"
|
||||||
vpc_id = var.vpc_id
|
vpc_id = var.vpc_id
|
||||||
|
|
||||||
|
@ -63,13 +69,13 @@ resource "aws_security_group" "ecs_tasks" {
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "PetClinic Tasks SG"
|
Name = "PetClinic Tasks SG"
|
||||||
Environment = var.environment
|
Environment = local.env_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# RDS Database for PetClinic
|
# RDS Database for PetClinic
|
||||||
resource "aws_db_instance" "petclinic" {
|
resource "aws_db_instance" "petclinic" {
|
||||||
identifier = "petclinic-${var.environment}db"
|
identifier = "petclinic-${local.env_name}db"
|
||||||
allocated_storage = 20
|
allocated_storage = 20
|
||||||
storage_type = "gp2"
|
storage_type = "gp2"
|
||||||
engine = "mysql"
|
engine = "mysql"
|
||||||
|
@ -82,7 +88,7 @@ resource "aws_db_instance" "petclinic" {
|
||||||
|
|
||||||
tags = {
|
tags = {
|
||||||
Name = "PetClinic Database"
|
Name = "PetClinic Database"
|
||||||
Environment = var.environment
|
Environment = local.env_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue