From 0a5338f20f7c5c37dd3413ba1ea7c2e10e14ef31 Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Mon, 15 Apr 2024 17:29:24 +0100 Subject: [PATCH] updating application --- 2-simple-example/iac/.terraform.lock.hcl | 3 +- 2-simple-example/iac/ecs.tf | 113 ++++------------------- 2-simple-example/iac/outputs.tf | 13 --- 3 files changed, 19 insertions(+), 110 deletions(-) diff --git a/2-simple-example/iac/.terraform.lock.hcl b/2-simple-example/iac/.terraform.lock.hcl index cb02273..1dbd89e 100644 --- a/2-simple-example/iac/.terraform.lock.hcl +++ b/2-simple-example/iac/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.opentofu.org/hashicorp/aws" { version = "5.45.0" - constraints = ">= 4.0.0, >= 4.66.1, >= 5.30.0, >= 5.33.0" + constraints = ">= 4.66.1, >= 5.30.0, >= 5.33.0" hashes = [ "h1:3zU3yp1SY+8vHAQvhfhYdPnFYQpFwXXXar+hOrnofzQ=", + "h1:A8MJa+VwONA4BNO5xzeleguJbrblNLnXBImHTK/qgFg=", "zh:1d71c406aeaf4ba762eb62e4595ab9c9f8da1a2c9b74bb4277c0acfd9678ae65", "zh:3b00b13154eadedb37bca99bf7cbd556fa9472e6900c970effa17a270ee9f721", "zh:6f264e8b70153925ac8abfa83ebffe2c2d5a27ab5557a6b16124269b08ac2441", diff --git a/2-simple-example/iac/ecs.tf b/2-simple-example/iac/ecs.tf index 6877e32..c6fbd94 100644 --- a/2-simple-example/iac/ecs.tf +++ b/2-simple-example/iac/ecs.tf @@ -44,23 +44,26 @@ module "ecs_service" { # Container definition(s) container_definitions = { - fluent-bit = { + valkey = { cpu = 512 memory = 1024 essential = true - image = nonsensitive(data.aws_ssm_parameter.fluentbit.value) - firelens_configuration = { - type = "fluentbit" - } - memory_reservation = 50 - user = "0" + image = "valkey/valkey:7.2.4-rc1-alpine" + port_mappings = [ + { + name = "valkey" + containerPort = 6379 + hostPort = 6379 + protocol = "tcp" + } + ] } (local.container_name) = { cpu = 512 memory = 1024 essential = true - image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50" + image = "richarvey/chat-app:latest" port_mappings = [ { name = local.container_name @@ -70,39 +73,14 @@ module "ecs_service" { } ] - # Example image used requires access to write to root filesystem - readonly_root_filesystem = false - - dependencies = [{ - containerName = "fluent-bit" - condition = "START" - }] + environment = [ + { + name = "REDIS_ENDPOINT" + value = "valkey" + }, + ] enable_cloudwatch_logging = false - log_configuration = { - logDriver = "awsfirelens" - options = { - Name = "firehose" - region = local.region - delivery_stream = "my-stream" - log-driver-buffer-limit = "2097152" - } - } - - linux_parameters = { - capabilities = { - add = [] - drop = [ - "NET_RAW" - ] - } - } - - # Not required for fluent-bit, just an example - volumes_from = [{ - sourceContainer = "fluent-bit" - readOnly = false - }] memory_reservation = 100 } @@ -154,67 +132,10 @@ module "ecs_service" { tags = local.tags } -################################################################################ -# Standalone Task Definition (w/o Service) -################################################################################ - -module "ecs_task_definition" { - source = "./modules/service" - - # Service - name = "${local.name}-standalone" - cluster_arn = module.ecs_cluster.arn - - # Task Definition - volume = { - ex-vol = {} - } - - runtime_platform = { - cpu_architecture = "ARM64" - operating_system_family = "LINUX" - } - - # Container definition(s) - container_definitions = { - al2023 = { - image = "public.ecr.aws/amazonlinux/amazonlinux:2023-minimal" - - mount_points = [ - { - sourceVolume = "ex-vol", - containerPath = "/var/www/ex-vol" - } - ] - - command = ["echo hello world"] - entrypoint = ["/usr/bin/sh", "-c"] - } - } - - subnet_ids = module.vpc.private_subnets - - security_group_rules = { - egress_all = { - type = "egress" - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - } - - tags = local.tags -} - ################################################################################ # Supporting Resources ################################################################################ -data "aws_ssm_parameter" "fluentbit" { - name = "/aws/service/aws-for-fluent-bit/stable" -} - resource "aws_service_discovery_http_namespace" "this" { name = local.name description = "CloudMap namespace for ${local.name}" diff --git a/2-simple-example/iac/outputs.tf b/2-simple-example/iac/outputs.tf index 6c77f7b..71fddb2 100644 --- a/2-simple-example/iac/outputs.tf +++ b/2-simple-example/iac/outputs.tf @@ -151,16 +151,3 @@ output "service_security_group_id" { value = module.ecs_service.security_group_id } -################################################################################ -# Standalone Task Definition (w/o Service) -################################################################################ - -output "task_definition_run_task_command" { - description = "awscli command to run the standalone task" - value = <