-
Notifications
You must be signed in to change notification settings - Fork 1
add terraform code for doccano service and conf file changes for nginx #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pcdc_dev
Are you sure you want to change the base?
Changes from all commits
8c98429
5f56c65
a0aa4ec
72e3163
26d0902
c402e0c
c07d665
ea79193
0f561d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| worker_processes ${WORKER_PROCESSES}; | ||
| worker_processes auto; | ||
|
|
||
| error_log /var/log/nginx/error.log warn; | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| module "doccano_ecs" { | ||
| source = "../modules/ecs" | ||
| app_name = var.app_name | ||
| subnet_ids = var.private_subnet_ids | ||
| lb_security_group = [module.doccano_alb.alb_security_group] | ||
| load_balancer = { | ||
| container_port = 8080 | ||
| } | ||
| vpc_id = var.vpc_id | ||
| target_group_arn = module.doccano_alb.alb_target_group_arn | ||
| container_name = "nginx" | ||
| # container_count = 2 | ||
| efs_volume = module.doccano_efs.efs_id | ||
| efs_access_point_static_files = module.doccano_efs.access_point_ids["staticfiles"] | ||
| efs_access_point_id_media = module.doccano_efs.access_point_ids["media"] | ||
| efs_access_point_id_tmp = module.doccano_efs.access_point_ids["tmp"] | ||
| database_url = aws_ssm_parameter.DATABASE_URL.arn | ||
| } | ||
|
|
||
| module "doccano_efs" { | ||
| source = "git::ssh://git@github.com/chicagopcdc/terraform_modules.git//aws/efs?ref=0.5.0" | ||
| vpc_id = var.vpc_id | ||
| efs_name = var.app_name | ||
| subnet_ids = var.private_subnet_ids | ||
| security_groups = [module.doccano_ecs.ecs_tasks_sg] | ||
| access_points = [ | ||
| { | ||
| name = "media" | ||
| posix_user = { uid = 1000, gid = 1000 } | ||
| root_directory = { | ||
| path = "/backend/media" | ||
| creation_info = { | ||
| owner_uid = "1000" | ||
| owner_gid = "1000" | ||
| permissions = "755" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| name = "staticfiles" | ||
| posix_user = { uid = 1000, gid = 1000 } | ||
| root_directory = { | ||
| path = "/backend/staticfiles" | ||
| creation_info = { | ||
| owner_uid = "1000" | ||
| owner_gid = "1000" | ||
| permissions = "755" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| name = "tmp" | ||
| posix_user = { uid = 1000, gid = 1000 } | ||
| root_directory = { | ||
| path = "/backend/filepond-temp-uploads" | ||
| creation_info = { | ||
| owner_uid = "1000" | ||
| owner_gid = "1000" | ||
| permissions = "755" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| module "doccano_alb" { | ||
| source = "git::ssh://git@github.com/chicagopcdc/terraform_modules.git//aws/alb?ref=0.5.0" | ||
| environment = var.environment | ||
| app_name = "doccano" | ||
| vpc_id = var.vpc_id | ||
| subnet_ids = var.private_subnet_ids | ||
| acm_cert_arn = "arn:aws:acm:us-east-1:471835990085:certificate/c1cebe37-738d-4766-a635-bc23d3e8caa7" # | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, this should be a variable, we shouldn't hardcode it. |
||
| } | ||
|
|
||
| module "rds" { | ||
| source = "git::ssh://git@github.com/chicagopcdc/terraform_modules.git//aws/rds?ref=0.5.0" | ||
| rds_security_groups = module.doccano_ecs.ecs_tasks_sg | ||
| vpc_id = var.vpc_id | ||
| subnet_ids = var.private_subnet_ids | ||
| db_name = "doccano" | ||
| } | ||
|
|
||
| resource "aws_ssm_parameter" "DATABASE_URL" { | ||
| name = "/${var.environment}/${var.app_name}/DATABASE_URL" | ||
| type = "SecureString" | ||
| value = "postgres://doccano:${module.rds.rds_random_password}@${module.rds.rds_enpoint}/doccano?sslmode=disable" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should update sslmode=require instead of disable. The new version of RDS enforce the SSL.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good, it was just taken from current values at the time |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| provider "aws" { | ||
| region = var.aws_region | ||
| default_tags { | ||
| tags = { | ||
| Environment = var.environment | ||
| Name = var.app_name | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # terraform { | ||
| # backend "s3" { | ||
| # bucket = "pcdc-doccano-dev-tfstate-bucket" | ||
| # key = "terraform.tfstate" | ||
| # region = var.aws_region | ||
| # dynamodb_table = "pcdc-doccano-dynomodb-table-terraform-lock" | ||
| # encrypt = true | ||
| # } | ||
| # } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| variable "aws_region" { | ||
| default = "us-east-1" | ||
| } | ||
|
|
||
| variable "environment" { | ||
| default = "dev" | ||
| } | ||
|
|
||
| variable "app_name" { | ||
| default = "doccano" | ||
| } | ||
|
|
||
| variable "private_subnet_ids" { | ||
| default = ["subnet-02daaea0d231975df", "subnet-0c7f4570d0c82bdc3"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these should be in the tfvars, we shouldn't default to them. |
||
| } | ||
|
|
||
| variable "vpc_id" { | ||
| default = "vpc-0e20603ab3c8dd65e" #doccano dev vpc | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be in the tfvars, we shouldn't default to it. |
||
| } | ||
|
|
||
| variable "efs_sg_id" { | ||
| default = "" | ||
| } | ||
|
|
||
| # variable "alb_sg_id" { | ||
| # default = "" | ||
| # } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module "dev" { | ||
| source = "./dev" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| resource "aws_cloudwatch_log_group" "doccano" { | ||
| name = "/ecs/doccano-logs" | ||
| retention_in_days = 7 | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_log_group" "flower" { | ||
| name = "/ecs/flower-logs" | ||
| retention_in_days = 7 | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_log_group" "celery" { | ||
| name = "/ecs/celery-logs" | ||
| retention_in_days = 7 | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_log_group" "nginx" { | ||
| name = "/ecs/nginx-logs" | ||
| retention_in_days = 7 | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_log_group" "rabbitmq" { | ||
| name = "/ecs/rabbitmq-logs" | ||
| retention_in_days = 7 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| resource "aws_ecs_cluster" "cluster" { | ||
| name = "${var.environment}-cluster" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you defining a new module here instead of using https://github.com/chicagopcdc/terraform_modules/tree/main/aws/ecs?
Is it a use case that is hard to generalize and parametrize?
If so that is good, otherwise we should try to move the module to the terraform module repo and import it here so we can reuse it for other projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I will update this to use module with reference to terraform_modules repo, initially I thought local reference was more appropriate