Skip to content

Commit

Permalink
adding of to environment, config and terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
geekbrother committed Oct 9, 2023
1 parent 591effe commit 6bfe997
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DISABLE_HEADER=false

# Should Echo Server validate messages it recieves are from the Relay when attempting to send a push notification
VALIDATE_SIGNATURES=true
RELAY_PUBLIC_KEY=

# Filter irrelevant logs from other crates, but enable traces for the relay.
# We're using separate log levels for stderr and telemetry. Note: telemetry
Expand Down
3 changes: 3 additions & 0 deletions .env.multi-tenant-example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ PUBLIC_URL=http://localhost:3000
DATABASE_URL=postgres://user:pass@host:port/database
LOG_LEVEL=debug,echo-server=debug

# Public key can be obtained from the https://relay.walletconnect.com/public-key
RELAY_PUBLIC_KEY=

# Don't validate signatures - allows for users to send push notifications from
# HTTP clients e.g. curl, insomnia, postman, etc
VALIDATE_SIGNATURES=false
Expand Down
3 changes: 3 additions & 0 deletions .env.single-tenant-example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ PUBLIC_URL=http://localhost:3000
DATABASE_URL=postgres://user:pass@host:port/database
LOG_LEVEL=debug,echo-server=debug

# Public key can be obtained from the https://relay.walletconnect.com/public-key
RELAY_PUBLIC_KEY=

# Don't validate signatures - allows for users to send push notifications from
# HTTP clients e.g. curl, insomnia, postman, etc
VALIDATE_SIGNATURES=false
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
TF_VAR_cloud_api_key: ${{ secrets.CLOUD_API_KEY }}
TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET }}
TF_VAR_image_version: ${{ inputs.image_tag }}
TF_VAR_relay_public_key: ${{ secrets.RELAY_PUBLIC_KEY }}
with:
environment: "staging"

Expand Down Expand Up @@ -156,6 +157,7 @@ jobs:
TF_VAR_cloud_api_key: ${{ secrets.CLOUD_API_KEY }}
TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET }}
TF_VAR_image_version: ${{ inputs.image_tag }}
TF_VAR_relay_public_key: ${{ secrets.RELAY_PUBLIC_KEY }}
with:
environment: "prod"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
TF_VAR_grafana_endpoint: ${{ steps.grafana-get-details.outputs.endpoint }}
TF_VAR_cloud_api_key: ${{ secrets.CLOUD_API_KEY }}
TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET }}
TF_VAR_relay_public_key: ${{ secrets.RELAY_PUBLIC_KEY }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
environment: staging
Expand Down
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct Config {
pub disable_header: bool,
#[serde(default = "default_relay_url")]
pub relay_url: String,
pub relay_public_key: String,
#[serde(default = "default_validate_signatures")]
pub validate_signatures: bool,
pub database_url: String,
Expand Down Expand Up @@ -111,6 +112,13 @@ impl Config {
Err(e) => Err(e),
}?;

// Empty Relay public key is not allowed
if self.relay_public_key.is_empty() {
return Err(InvalidConfiguration(
"`RELAY_PUBLIC_KEY` cannot be empty".to_string(),
));
}

Ok(())
}

Expand Down
3 changes: 2 additions & 1 deletion terraform/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ resource "aws_ecs_task_definition" "app_task_definition" {
{ name = "CLOUD_API_KEY", value = var.cloud_api_key },
{ name = "CLOUD_API_URL", value = var.cloud_api_url },

{ name = "JWT_SECRET", value = var.jwt_secret }
{ name = "JWT_SECRET", value = var.jwt_secret },
{ name = "RELAY_PUBLIC_KEY", value = var.relay_public_key }
],
dependsOn = [
{ containerName = "aws-otel-collector", condition = "START" }
Expand Down
5 changes: 5 additions & 0 deletions terraform/ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,8 @@ variable "jwt_secret" {
type = string
sensitive = true
}

variable "relay_public_key" {
type = string
sensitive = true
}
1 change: 1 addition & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ module "ecs" {
cloud_api_url = "https://registry.walletconnect.com/"

jwt_secret = var.jwt_secret
relay_public_key = var.relay_public_key

autoscaling_max_capacity = local.environment == "prod" ? 4 : 1
autoscaling_min_capacity = local.environment == "prod" ? 2 : 1
Expand Down

0 comments on commit 6bfe997

Please sign in to comment.