Skip to content

Commit

Permalink
Added option to override the statsd environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesiarmes committed Aug 27, 2024
1 parent 9a8fba7 commit bec7dbd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions tofu/config/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module "microservice" {
source = "../../modules/document_transfer"

environment = "development"
stats_environment = "staging"
logging_key = module.logging.kms_key_arn
vpc_id = module.vpc.vpc_id
database_apply_immediately = true
Expand Down
35 changes: 18 additions & 17 deletions tofu/modules/document_transfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ tofu plan

## Inputs

| Name | Description | Type | Default | Required |
|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|----------------|-----------------|----------|
| domain | Domain name for service. Example: `"staging.service.org"` | `string` | n/a | yes |
| logging_key | The ARN of the KMS key used for logging. | `string` | n/a | yes |
| vpc_id | The ID of the VPC in which the service is deployed. | `string` | n/a | yes |
| environment | Environment for the project. | `string` | `"development"` | no |
| database_apply_immediately | Immediately applies database changes rather than waiting for the next maintenance window. WARNING: This may result in a restart of the cluster! | `bool` | `false` | no |
| database_capacity_max | Maximum capacity for the database cluster in ACUs. | `bool` | `false` | no |
| database_capacity_min | Minimum capacity for the database cluster in ACUs. | `bool` | `false` | no |
| database_skip_final_snapshot | Skips the final snapshot when destroying the database cluster. | `bool` | `false` | no |
| database_snapshot | Optional name or ARN of the snapshot to restore the cluster from. Only applicable on create. | `bool` | `false` | no |
| force_delete | Force deletion of resources. If changing to true, be sure to apply before destroying. | `bool` | `false` | no |
| ingress_cidrs | The CIDR blocks to allow ingress from. The current VPC is allowed by default. | `list(string)` | `[]` | no |
| key_recovery_period | Number of days to recover the KMS key after deletion. | `number` | `30` | no |
| public | Launch the service so that it is available on the public Internet. | `bool` | `false` | no |
| secret_recovery_period | Recovery period for deleted secrets in days. Must be between 7 and 30, or 0 to force delete immediately. | `number` | `30` | no |
| service_environment | The environment the service should operate in, if different from `environment`. | `string` | `""` | no |
| Name | Description | Type | Default | Required |
|------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|-----------------|----------|
| domain | Domain name for service. Example: `"staging.service.org"` | `string` | n/a | yes |
| logging_key | The ARN of the KMS key used for logging. | `string` | n/a | yes |
| vpc_id | The ID of the VPC in which the service is deployed. | `string` | n/a | yes |
| environment | Environment for the project. | `string` | `"development"` | no |
| database_apply_immediately | Immediately applies database changes rather than waiting for the next maintenance window. WARNING: This may result in a restart of the cluster! | `bool` | `false` | no |
| database_capacity_max | Maximum capacity for the database cluster in ACUs. | `bool` | `false` | no |
| database_capacity_min | Minimum capacity for the database cluster in ACUs. | `bool` | `false` | no |
| database_skip_final_snapshot | Skips the final snapshot when destroying the database cluster. | `bool` | `false` | no |
| database_snapshot | Optional name or ARN of the snapshot to restore the cluster from. Only applicable on create. | `bool` | `false` | no |
| force_delete | Force deletion of resources. If changing to true, be sure to apply before destroying. | `bool` | `false` | no |
| ingress_cidrs | The CIDR blocks to allow ingress from. The current VPC is allowed by default. | `list(string)` | `[]` | no |
| key_recovery_period | Number of days to recover the KMS key after deletion. | `number` | `30` | no |
| public | Launch the service so that it is available on the public Internet. | `bool` | `false` | no |
| secret_recovery_period | Recovery period for deleted secrets in days. Must be between 7 and 30, or 0 to force delete immediately. | `number` | `30` | no |
| service_environment | The environment the service should operate in, if different from `environment`. | `string` | `""` | no |
| stats_environment | The environment the stats client should operate in, if different from environment. Use `"staging"` or `"production"` to send stats to the collector. | `string` | `""` | no |

## Outputs

Expand Down
11 changes: 7 additions & 4 deletions tofu/modules/document_transfer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ module "service" {
ingress_cidrs = var.ingress_cidrs

environment_variables = {
RACK_ENV = var.service_environment != "" ? var.service_environment : var.environment
OTEL_EXPORTER_OTLP_ENDPOINT = "http://localhost:4318"
DATABASE_HOST = module.database.cluster_endpoint
OTEL_EXPORTER_OTLP_ENDPOINT = "http://localhost:4318"
RACK_ENV = var.service_environment != "" ? var.service_environment : var.environment
STATSD_ENV = var.stats_environment != "" ? var.stats_environment : var.environment
}

environment_secrets = {
Expand All @@ -99,6 +100,7 @@ module "worker" {

project = "illinois-getchildcare"
project_short = "il-gcc"
stats_prefix = "illinois-getchildcare/document-transfer"
environment = var.environment
service = "doc-transfer-worker"
service_short = "doc-worker"
Expand All @@ -114,9 +116,10 @@ module "worker" {
repository_arn = module.service.repository_arn

environment_variables = {
RACK_ENV = var.service_environment != "" ? var.service_environment : var.environment
OTEL_EXPORTER_OTLP_ENDPOINT = "http://localhost:4318"
DATABASE_HOST = module.database.cluster_endpoint
OTEL_EXPORTER_OTLP_ENDPOINT = "http://localhost:4318"
RACK_ENV = var.service_environment != "" ? var.service_environment : var.environment
STATSD_ENV = var.stats_environment != "" ? var.stats_environment : var.environment
}

environment_secrets = {
Expand Down
6 changes: 6 additions & 0 deletions tofu/modules/document_transfer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ variable "service_environment" {
default = ""
}

variable "stats_environment" {
description = "The environment the stats client should operate in, if different from environment. Use \"staging\" or \"production\" to send stats to the collector."
type = string
default = ""
}

variable "vpc_id" {
description = "The ID of the VPC in which the service is deployed."
type = string
Expand Down

0 comments on commit bec7dbd

Please sign in to comment.