Skip to content

Commit

Permalink
Fix TF issues
Browse files Browse the repository at this point in the history
  • Loading branch information
niallthomson committed Jan 3, 2025
1 parent 379295c commit e3ca46e
Show file tree
Hide file tree
Showing 24 changed files with 173 additions and 114 deletions.
2 changes: 1 addition & 1 deletion deploy/terraform/apprunner/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions deploy/terraform/apprunner/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
variable "environment_name" {
type = string
default = "retail-store-ar"
type = string
default = "retail-store-ar"
description = "Name of the environment"
}

variable "container_image_overrides" {
Expand All @@ -10,6 +11,7 @@ variable "container_image_overrides" {
}

variable "image_repository_type" {
type = string
description = "The type of image repository where the images will be pulled from"
default = "ECR_PUBLIC"
}
2 changes: 1 addition & 1 deletion deploy/terraform/ecs/default/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions deploy/terraform/ecs/default/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
variable "environment_name" {
type = string
default = "retail-store-ecs"
type = string
default = "retail-store-ecs"
description = "Name of the environment"
}

variable "container_image_overrides" {
Expand Down
2 changes: 1 addition & 1 deletion deploy/terraform/lib/apprunner/carts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module "app_runner_carts" {
port = 8080
runtime_environment_variables = {
CARTS_DYNAMODB_TABLENAME = var.carts_dynamodb_table_name
SPRING_PROFILES_ACTIVE = "dynamodb"
SPRING_PROFILES_ACTIVE = "dynamodb"
}
}
image_identifier = module.container_images.result.cart.url
Expand Down
3 changes: 3 additions & 0 deletions deploy/terraform/lib/apprunner/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ output "ui_service_url" {

output "catalog_security_group_id" {
value = aws_security_group.catalog.id
description = "Security group ID of the catalog service"
}

output "checkout_security_group_id" {
value = aws_security_group.checkout.id
description = "Security group ID of the checkout service"
}

output "orders_security_group_id" {
value = aws_security_group.orders.id
description = "Security group ID of the orders service"
}
61 changes: 38 additions & 23 deletions deploy/terraform/lib/apprunner/variables.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
variable "environment_name" {
type = string
type = string
description = "Name of the environment"
}

variable "tags" {
description = "List of tags to be associated with resources."
default = {}
type = any
}

variable "vpc_id" {
description = "VPC ID used to create EKS cluster."
type = string
}

variable "vpc_cidr" {
description = "VPC ID used to create EKS cluster."
type = string
}

variable "subnet_ids" {
description = "List of private subnet IDs used by EKS cluster nodes."
type = list(string)
Expand All @@ -25,6 +22,7 @@ variable "subnet_ids" {
variable "image_repository_type" {
description = "The type of image repository where the images will be pulled from"
default = "ECR_PUBLIC"
type = string
}

variable "container_image_overrides" {
Expand All @@ -34,69 +32,86 @@ variable "container_image_overrides" {
}

variable "catalog_db_endpoint" {
type = string
type = string
description = "Endpoint of the catalog database"
}

variable "catalog_db_port" {
type = string
type = string
description = "Port of the catalog database"
}

variable "catalog_db_name" {
type = string
type = string
description = "Name of the catalog database"
}

variable "catalog_db_username" {
type = string
type = string
description = "Username for the catalog database"
}

variable "catalog_db_password" {
type = string
type = string
description = "Password for the catalog database"
}

variable "carts_dynamodb_table_name" {
type = string
type = string
description = "DynamoDB table name for the carts service"
}

variable "carts_dynamodb_policy_arn" {
type = string
type = string
description = "IAM policy for DynamoDB table for the carts service"
}

variable "orders_db_endpoint" {
type = string
type = string
description = "Endpoint of the orders database"
}

variable "orders_db_port" {
type = string
type = string
description = "Port of the orders database"
}

variable "orders_db_name" {
type = string
type = string
description = "Name of the orders database"
}

variable "orders_db_username" {
type = string
type = string
description = "Username for the orders database"
}

variable "orders_db_password" {
type = string
type = string
description = "Username for the password database"
}

variable "checkout_redis_endpoint" {
type = string
type = string
description = "Endpoint of the checkout redis"
}

variable "checkout_redis_port" {
type = string
type = string
description = "Port of the checkout redis"
}

variable "mq_endpoint" {
type = string
type = string
description = "Endpoint of the shared MQ"
}

variable "mq_username" {
type = string
type = string
description = "Username for the shared MQ"
}

variable "mq_password" {
type = string
type = string
description = "Password for the shared MQ"
}
12 changes: 6 additions & 6 deletions deploy/terraform/lib/dependencies/catalog_rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ module "catalog_rds" {
source = "terraform-aws-modules/rds-aurora/aws"
version = "7.7.1"

name = "${var.environment_name}-catalog"
engine = "aurora-mysql"
engine_version = "8.0"
instance_class = "db.t3.medium"
name = "${var.environment_name}-catalog"
engine = "aurora-mysql"
engine_version = "8.0"
instance_class = "db.t3.medium"
allow_major_version_upgrade = true

instances = {
one = {}
}

vpc_id = var.vpc_id
vpc_id = var.vpc_id
subnets = var.subnet_ids

allowed_security_groups = concat(var.allowed_security_group_ids, [var.catalog_security_group_id])
Expand All @@ -32,7 +32,7 @@ module "catalog_rds" {
db_cluster_parameter_group_name = "${var.environment_name}-catalog"
db_cluster_parameter_group_family = "aurora-mysql8.0"

tags = var.tags
tags = var.tags
}

resource "random_string" "catalog_db_master" {
Expand Down
6 changes: 3 additions & 3 deletions deploy/terraform/lib/dependencies/dynamodb.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "dynamodb-carts" {
module "dynamodb_carts" {
source = "terraform-aws-modules/dynamodb-table/aws"
version = "3.2.0"

Expand Down Expand Up @@ -41,8 +41,8 @@ resource "aws_iam_policy" "carts_dynamo" {
"Effect": "Allow",
"Action": "dynamodb:*",
"Resource": [
"arn:${local.aws_partition}:dynamodb:${local.aws_region}:${local.aws_account_id}:table/${module.dynamodb-carts.dynamodb_table_id}",
"arn:${local.aws_partition}:dynamodb:${local.aws_region}:${local.aws_account_id}:table/${module.dynamodb-carts.dynamodb_table_id}/index/*"
"arn:${local.aws_partition}:dynamodb:${local.aws_region}:${local.aws_account_id}:table/${module.dynamodb_carts.dynamodb_table_id}",
"arn:${local.aws_partition}:dynamodb:${local.aws_region}:${local.aws_account_id}:table/${module.dynamodb_carts.dynamodb_table_id}/index/*"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion deploy/terraform/lib/dependencies/elasticache.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "checkout-elasticache-redis" {
module "checkout_elasticache_redis" {
source = "cloudposse/elasticache-redis/aws"
version = "0.52.0"

Expand Down
2 changes: 0 additions & 2 deletions deploy/terraform/lib/dependencies/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
data "aws_region" "current" {}

data "aws_availability_zones" "available" {}

data "aws_caller_identity" "current" {}

data "aws_partition" "current" {}
Expand Down
12 changes: 6 additions & 6 deletions deploy/terraform/lib/dependencies/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ output "orders_db_arn" {

output "carts_dynamodb_table_arn" {
description = "ARN of the carts DynamoDB table"
value = module.dynamodb-carts.dynamodb_table_arn
value = module.dynamodb_carts.dynamodb_table_arn
}

output "carts_dynamodb_table_name" {
description = "Name of the carts DynamoDB table"
value = module.dynamodb-carts.dynamodb_table_id
value = module.dynamodb_carts.dynamodb_table_id
}

output "carts_dynamodb_policy_arn" {
Expand Down Expand Up @@ -114,21 +114,21 @@ output "mq_user" {
}

output "checkout_elasticache_arn" {
value = module.checkout-elasticache-redis.arn
value = module.checkout_elasticache_redis.arn
description = "Checkout Redis ElastiCache ARN."
}

output "checkout_elasticache_primary_endpoint" {
value = module.checkout-elasticache-redis.endpoint
value = module.checkout_elasticache_redis.endpoint
description = "Checkout Redis hostname"
}

output "checkout_elasticache_reader_endpoint" {
value = module.checkout-elasticache-redis.reader_endpoint_address
value = module.checkout_elasticache_redis.reader_endpoint_address
description = "Checkout Redis reader hostname"
}

output "checkout_elasticache_port" {
value = module.checkout-elasticache-redis.port
value = module.checkout_elasticache_redis.port
description = "Checkout Redis port"
}
27 changes: 15 additions & 12 deletions deploy/terraform/lib/dependencies/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
variable "environment_name" {
type = string
type = string
description = "Name of the environment"
}

variable "vpc_id" {
type = string
type = string
description = "VPC ID for the resources"
}

variable "subnet_ids" {
Expand All @@ -12,27 +14,28 @@ variable "subnet_ids" {
}

variable "tags" {
description = "A map of tags to add to all resources"
description = "List of tags to be associated with resources."
default = {}
}

variable "availability_zones" {
type = list(string)
type = any
}

variable "catalog_security_group_id" {
type = string
type = string
description = "Security group ID of the catalog component"
}

variable "orders_security_group_id" {
type = string
type = string
description = "Security group ID of the orders component"
}

variable "checkout_security_group_id" {
type = string
type = string
description = "Security group ID of the checkout component"
}

variable "allowed_security_group_ids" {
type = list(string)
default = []
type = list(string)
default = []
description = "List of additional allowed security group IDs"
}
4 changes: 2 additions & 2 deletions deploy/terraform/lib/ecs/common.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ resource "aws_kms_key" "cmk" {
}

resource "random_string" "random_mq_secret" {
length = 4
special = false
length = 4
special = false
}

resource "aws_secretsmanager_secret" "mq" {
Expand Down
6 changes: 0 additions & 6 deletions deploy/terraform/lib/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ module "container_images" {

container_image_overrides = var.container_image_overrides
}

data "aws_ssm_parameter" "fluentbit" {
name = "/aws/service/aws-for-fluent-bit/stable"
}

data "aws_region" "current" {}
Loading

0 comments on commit e3ca46e

Please sign in to comment.