Skip to content

Commit

Permalink
adding frontend deployment infrastructure (#75)
Browse files Browse the repository at this point in the history
Relates to:
#51

### Changes introduced:
Adding happy infrastructure to deploy front end application.

Demo: https://frontend-test.cryoet.dev.si.czi.technology/
  • Loading branch information
manasaV3 authored Oct 9, 2023
1 parent b79e6a2 commit 5b39f1c
Show file tree
Hide file tree
Showing 18 changed files with 485 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ celerybeat.pid
*.sage.py

# Environments
.env.ecr
.env
.venv
env/
Expand All @@ -127,3 +128,6 @@ dmypy.json

# Pyre type checker
.pyre/

.idea
.terraform
70 changes: 70 additions & 0 deletions frontend/.happy/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"default_env": "dev",
"app": "cryoet-frontend",
"default_compose_env_file": ".env.ecr",
"environments": {
"dev": {
"aws_profile": "cryoet-dev",
"aws_region": "us-west-2",
"k8s": {
"namespace": "cryoet-dev-happy-happy-env",
"cluster_id": "cryoet-dev-eks",
"auth_method": "eks"
},
"terraform_directory": ".happy/terraform/envs/dev",
"task_launch_type": "k8s"
},
"prod": {
"aws_profile": "cryoet-prod",
"aws_region": "us-west-2",
"k8s": {
"namespace": "cryoet-prod-happy-happy-env",
"cluster_id": "cryoet-prod-eks",
"auth_method": "eks"
},
"terraform_directory": ".happy/terraform/envs/prod",
"task_launch_type": "k8s"
},
"staging": {
"aws_profile": "cryoet-dev",
"aws_region": "us-west-2",
"k8s": {
"namespace": "cryoet-staging-happy-happy-env",
"cluster_id": "cryoet-staging-eks",
"auth_method": "eks"
},
"terraform_directory": ".happy/terraform/envs/staging",
"task_launch_type": "k8s"
}
},
"services": [
"frontend"
],
"features": {
"enable_dynamo_locking": true,
"enable_happy_api_usage": true,
"enable_ecr_auto_creation": true
},
"api": {},
"stack_defaults": {
"create_dashboard": false,
"routing_method": "CONTEXT",
"services": {
"frontend": {
"build": {
"context": "packages/data-portal",
"dockerfile": "Dockerfile"
},
"health_check_path": "/",
"name": "frontend",
"path": "/*",
"port": 8080,
"priority": 0,
"service_type": "EXTERNAL",
"success_codes": "200-499",
"platform_architecture": "amd64"
}
},
"stack_defaults": "[email protected]:chanzuckerberg/happy//terraform/modules/happy-stack-eks?ref=main"
}
}
28 changes: 28 additions & 0 deletions frontend/.happy/terraform/envs/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
module "stack" {
source = "[email protected]:chanzuckerberg/happy//terraform/modules/happy-stack-eks?ref=jgadling/optional-datadog"
image_tag = var.image_tag
stack_name = var.stack_name
k8s_namespace = var.k8s_namespace
image_tags = jsondecode(var.image_tags)
stack_prefix = "/${var.stack_name}"
app_name = var.app
deployment_stage = "dev"
services = {
frontend = {
health_check_path = "/"
name = "frontend"
path = "/*"
port = 8080
desired_count = 1
priority = 0
service_type = "EXTERNAL"
success_codes = "200-499"
memory = "1500Mi"
cpu = "1500m"
}
}
create_dashboard = false
routing_method = "CONTEXT"
}
20 changes: 20 additions & 0 deletions frontend/.happy/terraform/envs/dev/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
output "dashboard" {
sensitive = false
value = module.stack.dashboard
}
output "service_ecrs" {
sensitive = false
value = module.stack.service_ecrs
}
output "service_endpoints" {
description = "The URL endpoints for services"
sensitive = false
value = module.stack.service_endpoints
}
output "task_arns" {
description = "ARNs for all the tasks"
sensitive = false
value = module.stack.task_arns
}
28 changes: 28 additions & 0 deletions frontend/.happy/terraform/envs/dev/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
provider "aws" {
region = "us-west-2"
assume_role {
role_arn = "arn:aws:iam::${var.aws_account_id}:role/${var.aws_role}"
}
allowed_account_ids = ["${var.aws_account_id}"]
}
data "aws_eks_cluster" "cluster" {
name = var.k8s_cluster_id
}
data "aws_eks_cluster_auth" "cluster" {
name = var.k8s_cluster_id
}
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
}
data "kubernetes_namespace" "happy-namespace" {
metadata {
name = var.k8s_namespace
}
}
provider "datadog" {
validate = false
}
35 changes: 35 additions & 0 deletions frontend/.happy/terraform/envs/dev/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
variable "aws_account_id" {
type = string
description = "AWS account ID to apply changes to"
}
variable "k8s_cluster_id" {
type = string
description = "EKS K8S Cluster ID"
}
variable "k8s_namespace" {
type = string
description = "K8S namespace for this stack"
}
variable "aws_role" {
type = string
description = "Name of the AWS role to assume to apply changes"
}
variable "image_tag" {
type = string
description = "Please provide an image tag"
}
variable "image_tags" {
type = string
description = "Override the default image tags (json-encoded map)"
default = "{}"
}
variable "stack_name" {
type = string
description = "Happy Path stack name"
}
variable "app" {
type = string
description = "Happy App Name"
}
23 changes: 23 additions & 0 deletions frontend/.happy/terraform/envs/dev/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
terraform {
required_version = ">= 1.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.14"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.20"
}
datadog = {
source = "datadog/datadog"
version = ">= 3.25.0"
}
happy = {
source = "chanzuckerberg/happy"
version = ">= 0.82.1"
}
}
}
27 changes: 27 additions & 0 deletions frontend/.happy/terraform/envs/prod/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
module "stack" {
source = "[email protected]:chanzuckerberg/happy//terraform/modules/happy-stack-eks?ref=jgadling/optional-datadog"
image_tag = var.image_tag
stack_name = var.stack_name
k8s_namespace = var.k8s_namespace
image_tags = jsondecode(var.image_tags)
stack_prefix = "/${var.stack_name}"
app_name = var.app
deployment_stage = "prod"
services = {
frontend = {
health_check_path = "/"
name = "frontend"
path = "/*"
port = 8080
priority = 0
service_type = "EXTERNAL"
success_codes = "200-499"
memory = "1500Mi"
cpu = "1500m"
}
}
create_dashboard = false
routing_method = "CONTEXT"
}
20 changes: 20 additions & 0 deletions frontend/.happy/terraform/envs/prod/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
output "dashboard" {
sensitive = false
value = module.stack.dashboard
}
output "service_ecrs" {
sensitive = false
value = module.stack.service_ecrs
}
output "service_endpoints" {
description = "The URL endpoints for services"
sensitive = false
value = module.stack.service_endpoints
}
output "task_arns" {
description = "ARNs for all the tasks"
sensitive = false
value = module.stack.task_arns
}
29 changes: 29 additions & 0 deletions frontend/.happy/terraform/envs/prod/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
provider "aws" {
region = "us-west-2"
assume_role {
role_arn = "arn:aws:iam::${var.aws_account_id}:role/${var.aws_role}"
}
allowed_account_ids = ["${var.aws_account_id}"]
}
data "aws_eks_cluster" "cluster" {
name = var.k8s_cluster_id
}
data "aws_eks_cluster_auth" "cluster" {
name = var.k8s_cluster_id
}
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
}
data "kubernetes_namespace" "happy-namespace" {
metadata {
name = var.k8s_namespace
}
}
provider "datadog" {
app_key = "FAKE_APP_KEY"
api_key = "FAKE_API_KEY"
}
35 changes: 35 additions & 0 deletions frontend/.happy/terraform/envs/prod/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
variable "aws_account_id" {
type = string
description = "AWS account ID to apply changes to"
}
variable "k8s_cluster_id" {
type = string
description = "EKS K8S Cluster ID"
}
variable "k8s_namespace" {
type = string
description = "K8S namespace for this stack"
}
variable "aws_role" {
type = string
description = "Name of the AWS role to assume to apply changes"
}
variable "image_tag" {
type = string
description = "Please provide an image tag"
}
variable "image_tags" {
type = string
description = "Override the default image tags (json-encoded map)"
default = "{}"
}
variable "stack_name" {
type = string
description = "Happy Path stack name"
}
variable "app" {
type = string
description = "Happy App Name"
}
23 changes: 23 additions & 0 deletions frontend/.happy/terraform/envs/prod/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
terraform {
required_version = ">= 1.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.14"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.20"
}
datadog = {
source = "datadog/datadog"
version = ">= 3.25.0"
}
happy = {
source = "chanzuckerberg/happy"
version = ">= 0.82.1"
}
}
}
28 changes: 28 additions & 0 deletions frontend/.happy/terraform/envs/staging/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Auto-generated by 'happy infra'. Do not edit
# Make improvements in happy, so that everyone can benefit.
module "stack" {
source = "[email protected]:chanzuckerberg/happy//terraform/modules/happy-stack-eks?ref=jgadling/optional-datadog"
image_tag = var.image_tag
stack_name = var.stack_name
k8s_namespace = var.k8s_namespace
image_tags = jsondecode(var.image_tags)
stack_prefix = "/${var.stack_name}"
app_name = var.app
deployment_stage = "staging"
services = {
frontend = {
health_check_path = "/"
name = "frontend"
path = "/*"
port = 8080
desired_count = 1
priority = 0
service_type = "EXTERNAL"
success_codes = "200-499"
memory = "1500Mi"
cpu = "1500m"
}
}
create_dashboard = false
routing_method = "CONTEXT"
}
Loading

0 comments on commit 5b39f1c

Please sign in to comment.