Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 56 additions & 60 deletions examples/ecs-service-discovery/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions examples/ecs-service-discovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ service_name-port_name:port

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.2 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.90.1 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_cluster"></a> [cluster](#module\_cluster) | ../../modules/ecs-cluster | n/a |
| <a name="module_lb"></a> [lb](#module\_lb) | ../../modules/lb/alb | n/a |
| <a name="module_public_subnets"></a> [public\_subnets](#module\_public\_subnets) | ../../modules/vpc-public-subnet | n/a |
| <a name="module_service"></a> [service](#module\_service) | ../../modules/ecs-service | n/a |
| <a name="module_secrets"></a> [secrets](#module\_secrets) | ../../modules/ssm/parameters | n/a |
| <a name="module_static_cluster"></a> [static\_cluster](#module\_static\_cluster) | ../../modules/ecs-cluster-static | n/a |
| <a name="module_static_service"></a> [static\_service](#module\_static\_service) | ../../modules/ecs-service-managed | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | ../../modules/vpc | n/a |

## Resources
Expand All @@ -38,7 +38,6 @@ service_name-port_name:port
|------|------|
| [aws_alb_listener.http](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/alb_listener) | resource |
| [aws_service_discovery_http_namespace.local](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/service_discovery_http_namespace) | resource |
| [random_id.example](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |

## Outputs

Expand Down
122 changes: 95 additions & 27 deletions examples/ecs-service-discovery/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ locals {
}
}

resource "random_id" "example" {
byte_length = 2

prefix = "discovery-"
}

# network

module "vpc" {
source = "../../modules/vpc"

name = random_id.example.hex
name = "discovery"
cidr = "10.0.0.0/16"
}

Expand All @@ -43,7 +37,7 @@ module "public_subnets" {
module "lb" {
source = "../../modules/lb/alb"

name = random_id.example.hex
name = "discovery"
vpc_id = module.vpc.id
subnet_ids = module.public_subnets.ids
force_https = false
Expand All @@ -64,54 +58,128 @@ resource "aws_service_discovery_http_namespace" "local" {

# cluster

module "cluster" {
source = "../../modules/ecs-cluster"
# module "cluster" {
# source = "../../modules/ecs-cluster"

# context = {
# namespace = "selleo"
# stage = "dev"
# name = "example"
# }

# name_prefix = random_id.example.hex
# vpc_id = module.vpc.id
# subnet_ids = module.public_subnets.ids
# instance_type = "t3.nano"
# lb_security_group_id = module.lb.security_group_id

# autoscaling_group = {
# min_size = 1
# max_size = 5
# desired_capacity = 1
# }
# }

module "static_cluster" {
source = "../../modules/ecs-cluster-static"

context = {
namespace = "selleo"
stage = "dev"
name = "example"
}

name_prefix = random_id.example.hex
name_prefix = "static-cluster"
vpc_id = module.vpc.id
subnet_ids = module.public_subnets.ids
instance_type = "t3.nano"
lb_security_group_id = module.lb.security_group_id

autoscaling_group = {
min_size = 1
max_size = 5
desired_capacity = 1
instances = {
"search1" = {
ip = "10.0.1.1"
subnet_id = module.public_subnets.ids[0]
}
}
}

module "service" {
source = "../../modules/ecs-service"
# module "service" {
# source = "../../modules/ecs-service"

# context = {
# namespace = "selleo"
# stage = "dev"
# name = "example"
# }

# name = random_id.example.hex
# vpc_id = module.vpc.id
# subnet_ids = module.public_subnets.ids
# cluster_id = module.cluster.id
# desired_count = 1

# tcp_ports = [
# {
# name = "http"
# host = 0
# container = 3000
# }
# ]

# service_discovery = {
# arn = aws_service_discovery_http_namespace.local.arn
# name = "app"
# }
# }

module "secrets" {
source = "../../modules/ssm/parameters"

context = {
namespace = "selleo"
stage = "dev"
name = "example"
context = local.context

path = "/example/meilisearch"
secrets = {
# See other config: https://www.meilisearch.com/docs/learn/self_hosted/configure_meilisearch_at_launch
MEILI_NO_ANALYTICS = "1"
MEILI_ENV = "production"
MEILI_DB_PATH = "/meili/data"
MEILI_MASTER_KEY = "c4379222ecf8533c6004153a31294d30ca481813a9e43284c85a8e3aeb96da19" # ❗️ THIS SHOULD BE EDITABLE SECRET, NOT HARDCODED - this only for example
}
}

module "static_service" {
source = "../../modules/ecs-service-managed"

name = random_id.example.hex
context = local.context

name = "meilisearch"
vpc_id = module.vpc.id
subnet_ids = module.public_subnets.ids
cluster_id = module.cluster.id
subnet_ids = module.public_subnets.ids[0]
cluster_id = module.static_cluster.id
desired_count = 1

tcp_ports = [
{
name = "http"
host = 0
container = 3000
container = 7700
}
]
image = "getmeili/meilisearch:v1.13"
limits = {
mem_min = 100
mem_max = 400
cpu = 500
}
# volumes = [
# {
# name = "$pwd/meili_data"
# path = "/meili_data"
# }
# ]

service_discovery = {
arn = aws_service_discovery_http_namespace.local.arn
name = "app"
name = "meilisearch"
}
}

Expand Down
Loading