Skip to content

Commit

Permalink
add terraform specs for the service deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
zhelezovartem committed Aug 2, 2022
1 parent 6652c05 commit 1c91302
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 0 deletions.
17 changes: 17 additions & 0 deletions deployment/terraform/.gitignore
@@ -0,0 +1,17 @@
*.zip

# Terraform
**/.terraform/*
.terraform.*
*.tfstate
*.tfstate.*
crash.log
variables.tfvars
override.tf
override.tf.json
*_override.tf
*_override.tf.json
*terraform.tfvars
.terraform.lock.hcl
*plan.json
**/.terraform.lock.hcl
9 changes: 9 additions & 0 deletions deployment/terraform/244531986313-eu-central-1.tfvars
@@ -0,0 +1,9 @@
env = "staging"

# Allow to replicate app docker images to these accounts
ecr_replication_targets = [
{
"account_id" = "274425519734",
"region" = "eu-central-1"
}
]
4 changes: 4 additions & 0 deletions deployment/terraform/274425519734-eu-central-1.tfvars
@@ -0,0 +1,4 @@
env = "prod"

# Allow to replicate app docker images from this account
ecr_replication_origin = "244531986313"
14 changes: 14 additions & 0 deletions deployment/terraform/deployment.tf
@@ -0,0 +1,14 @@
module "ecs-service" {
source = "s3::https://s3-eu-central-1.amazonaws.com/terraform-modules-9d7e951c290ec5bbe6506e0ddb064808764bc636/terraform-modules.zip//ecs-service/v1"
service_name = var.service_name
TAGGED_IMAGE = var.TAGGED_IMAGE
enable_execute_command = "true"
app_port = var.app_port
cpu_limit = var.cpu_limit
mem_reservation = var.mem_reservation
mem_limit = var.mem_limit
app_env_vars = local.app_env_vars
ecr_replication_targets = var.ecr_replication_targets
ecr_replication_origin = var.ecr_replication_origin
tags = module.tags.result
}
8 changes: 8 additions & 0 deletions deployment/terraform/locals.tf
@@ -0,0 +1,8 @@
locals {
app_env_vars = [
for key, value in var.app_env_vars : {
name = key
value = value
}
]
}
20 changes: 20 additions & 0 deletions deployment/terraform/main.tf
@@ -0,0 +1,20 @@
terraform {
backend "s3" {}
}

provider "aws" {
alias = "eu-central-1"
region = "eu-central-1"
}

module "tags" {
source = "fivexl/tag-generator/aws"
version = "2.0.0"
prefix = "merkely"
terraform_managed = "1"
environment_name = var.env
data_owner = "merkely"
data_pci = "0"
data_phi = "0"
data_pii = "0"
}
51 changes: 51 additions & 0 deletions deployment/terraform/variables.tf
@@ -0,0 +1,51 @@
variable "service_name" {
type = string
default = "languages-start-points"
}

variable "env" {
type = string
}

variable "app_port" {
type = number
default = 4524
}

variable "cpu_limit" {
type = number
default = 20
}

variable "mem_limit" {
type = number
default = 64
}

variable "mem_reservation" {
type = number
default = 32
}

variable "TAGGED_IMAGE" {
type = string
}

# App variables
variable "app_env_vars" {
type = map(any)
default = {
CYBER_DOJO_PROMETHEUS = "false"
CYBER_DOJO_LANGUAGES_START_POINTS_PORT = "4524"
}
}

variable "ecr_replication_targets" {
type = list(map(string))
default = []
}

variable "ecr_replication_origin" {
type = string
default = ""
}
13 changes: 13 additions & 0 deletions deployment/terraform/versions.tf
@@ -0,0 +1,13 @@
terraform {
required_version = ">= 0.14"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16.0"
}
random = {
source = "hashicorp/random"
version = "3.3.1"
}
}
}

0 comments on commit 1c91302

Please sign in to comment.