From e4062f4221f0e9fcc897cda7b40a2b2d9f8aa6b2 Mon Sep 17 00:00:00 2001 From: Josh Liburdi Date: Mon, 4 Mar 2024 19:04:35 -0800 Subject: [PATCH] refactor!: Consistent Environment Variable and Application Names (#141) * refactor!(envar): Standardize Env Var * refactor!(cmd): Standardize Cmd Main Files * docs(terraform): Update Terraform Docs * docs(cmd): Update Autoscale Env Var --- CONTRIBUTING.md | 2 +- README.md | 4 +- build/terraform/aws/README.md | 124 +++--------------- build/terraform/aws/appconfig/README.md | 3 + build/terraform/aws/lambda/README.md | 2 +- cmd/aws/lambda/README.md | 2 +- cmd/aws/lambda/substation/main.go | 6 +- .../lambda/validate/{validator.go => main.go} | 0 .../{validator_test.go => main_test.go} | 0 .../terraform/consumer.tf | 2 +- .../to_lambda/terraform/consumer.tf | 2 +- .../aws/dynamodb/cdc/terraform/node.tf | 2 +- .../kinesis/firehose/terraform/_resources.tf | 2 +- .../multistream/terraform/publisher.tf | 2 +- .../multistream/terraform/subscriber.tf | 2 +- .../time_travel/terraform/enrichment.tf | 2 +- .../time_travel/terraform/subscriber.tf | 2 +- .../aws/lambda/appconfig/terraform/node.tf | 2 +- .../microservice/terraform/microservice.tf | 2 +- .../aws/lambda/vpc/terraform/whatismyip.tf | 2 +- .../aws/s3/data_lake/terraform/node.tf | 2 +- .../terraform/aws/s3/sns/terraform/node.tf | 2 +- .../terraform/aws/s3/xdr/terraform/node.tf | 2 +- .../aws/sns/pub_sub/terraform/subscribers.tf | 6 +- .../sqs/microservice/terraform/frontend.tf | 2 +- .../microservice/terraform/microservice.tf | 2 +- internal/aws/cloudwatch/cloudwatch.go | 8 +- 27 files changed, 54 insertions(+), 135 deletions(-) rename cmd/aws/lambda/validate/{validator.go => main.go} (100%) rename cmd/aws/lambda/validate/{validator_test.go => main_test.go} (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bcdadd44..f8865d37 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ We rely on contributors to test changes before they are submitted as pull reques #### Environment Variables -Applications may implement runtime settings that are managed by environment variables. For example, the [AWS Lambda application](/cmd/aws/lambda/substation/) uses `SUBSTATION_HANDLER` to manage [invocation settings](https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html). +Applications may implement runtime settings that are managed by environment variables. For example, the [AWS Lambda application](/cmd/aws/lambda/substation/) uses `SUBSTATION_LAMBDA_HANDLER` to manage [invocation settings](https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html). These should reference the application by name, if possible. #### Configurations diff --git a/README.md b/README.md index 53ce72e6..7954cf7c 100644 --- a/README.md +++ b/README.md @@ -444,10 +444,10 @@ module "node" { env = { "SUBSTATION_CONFIG" : "https://localhost:2772/applications/substation/environments/example/configurations/node" + "SUBSTATION_DEBUG" : true # This Substation node will ingest data from API Gateway. More nodes can be # deployed to ingest data from other sources, such as Kinesis or SQS. - "SUBSTATION_HANDLER" : "AWS_API_GATEWAY" - "SUBSTATION_DEBUG" : true + "SUBSTATION_LAMBDA_HANDLER" : "AWS_API_GATEWAY" } } diff --git a/build/terraform/aws/README.md b/build/terraform/aws/README.md index b0d6448a..e20f806a 100644 --- a/build/terraform/aws/README.md +++ b/build/terraform/aws/README.md @@ -1,112 +1,28 @@ # terraform -This directory contains Terraform configuration files for deploying Substation to AWS. +This directory contains Terraform modules for deploying Substation to AWS. ## Using Terraform -An overview on how Terraform is used and the write, plan, apply workflow is available [here](https://www.terraform.io/intro). - -Please use the official [Terraform documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) for further details on using Terraform to deploy AWS applications or for boiler plate examples. +An overview on how Terraform is used and the write, plan, apply workflow is available [here](https://www.terraform.io/intro). Refer to the [AWS provider documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) for more information on using Terraform with AWS. ## Modules -Due to the potentially endless number of deployment configurations, Substation comes with Terraform modules that act as component templates for different parts of the system. These modules are designed to be flexible enough to support every known deployment configuration. For an example deployment, see `example.tf` . - -### API Gateway - -This module is used as a template for deploying new API Gateway endpoints. - -Read more about API Gateway [here](https://aws.amazon.com/api-gateway/). - -#### Kinesis - -This module creates an API Gateway that sends a record to a Kinesis Data Stream. To prevent hot shards, the partition key is the request ID of the HTTP request. - -#### Lambda - -This module creates an API Gateway that invokes and sends a record to a Lambda function. - -### CloudWatch - -#### Destination - -This module creates a CloudWatch Logs destination that can be used to receive logs from any AWS account or region and send them to a destination. - -#### Subscription - -This module creates a CloudWatch Logs subscription filter that can be used to send logs from a CloudWatch Logs group to a destination. Use this with the `Destination` module to send logs from any AWS account or region to a single destination. - -### DynamoDB - -This module is used as a template for deploying new DynamoDB tables with autoscaling enabled. These tables have [time to live](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html) enabled and users can optionally use it by writing values to the `ttl` column. - -Read more about DynamoDB [here](https://aws.amazon.com/dynamodb/). - -### ECR - -This module is used as a template for deploying new image repositories to the AWS Elastic Container Registry (ECR) service. - -There are two things to be aware of when deploying new image repositories: - -* Terraform does not manage the build and deployment of container images; after an image repository is created, then container build and upload should happen externally via Docker (see `build/docker` for more information) -* By default all Lambda deployments use containers, but a Lambda deployment will fail if the image repository is empty; prevent deployment failures by building and uploading images before deploying Lambda - -Read more about ECR [here](https://aws.amazon.com/ecr/). - -### Event Bridge - -#### Lambda - -This module is used to create Event Bridge rules that trigger a Lambda. - -Read more about Event Bridge [here](https://aws.amazon.com/eventbridge/). - -### Kinesis - -This module is used to create new Kinesis Data Streams (KDS) and accompanying CloudWatch alarms. The streams created by this module are intended to be used with Substation's autoscaling application -- this feature provides stream autoscaling at a significantly reduced cost compared to Kinesis Firehose. - -For best practices, we recommend users deploy data pipelines that use two Kinesis streams: a stream for pre-processed (i.e., raw) data and a stream for post-processed (i.e., processed) data. This deployment strategy is useful for supporting concurrent access to data across many applications. - -Read more about Kinesis Data Streams [here](https://aws.amazon.com/kinesis/data-streams/). - -### KMS - -This module is used to create encryption keys used across a deployment. Any number of keys can be made, but by default we create one key that is shared by all encrypted resources and data. - -Read more about the Key Management Service [here](https://aws.amazon.com/kms/). - -### Lambda - -This module is used to create and manage Lambda, which is the recommended service for data processing. - -This module is flexible enough to deploy supporting apps (such as `cmd/aws/lambda/kinesis_autoscaling`) and custom apps (such as apps that provide data enrichment functionality). When new Lambda are created with this module, an accompanying AppConfig configuration profile is created under the `substation` application. - -Read more about AWS Lambda [here](https://aws.amazon.com/lambda/). - -### S3 - -This module is used as a template for deploying new S3 buckets. These buckets are private and objects are encrypted. - -Read more about S3 [here](https://aws.amazon.com/s3/). - -#### WORM - -This module creates a write once, read many (WORM) S3 bucket using [Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-overview.html) and applies the [Compliance](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-overview.html#object-lock-retention-modes) retention mode setting. Objects written to these buckets _*cannot be deleted*_. - -### SNS - -This module is used for creating SNS topics. Topics can be standard or first-in-first-out (FIFO). - -Read more about SNS [here](https://aws.amazon.com/sns/). - -### SQS - -This module is used for creating SQS queues. Queues can be standard or first-in-first-out (FIFO). - -Read more about SQS [here](https://aws.amazon.com/sqs/). - -### Networking - -This module can be used to create a custom VPC with outbound connectivity via a NAT gateway to a public subnet that contains an IGW. This allows for connectivity with VPC only services. - -Read more about VPCs [here](https://aws.amazon.com/vpc/). +Due to the potentially endless number of deployment configurations, Substation includes Terraform modules for these AWS services: + +* API Gateway +* AppConfig +* CloudWatch +* DynamoDB +* Elastic Container Registry (ECR) +* Event Bridge +* Kinesis Data Streams +* Key Management Service (KMS) +* Lambda +* S3 +* Secrets Manager +* SNS +* SQS +* VPC Networking + +Refer to each module's README for more information. Several examples of how to use these modules are available [here](/examples/terraform/aws/). diff --git a/build/terraform/aws/appconfig/README.md b/build/terraform/aws/appconfig/README.md index aef43579..4432ef0f 100644 --- a/build/terraform/aws/appconfig/README.md +++ b/build/terraform/aws/appconfig/README.md @@ -23,12 +23,14 @@ No modules. | [aws_appconfig_application.app](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appconfig_application) | resource | | [aws_appconfig_deployment_strategy.instant](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appconfig_deployment_strategy) | resource | | [aws_appconfig_environment.env](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appconfig_environment) | resource | +| [aws_lambda_permission.allow_appconfig](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [config](#input\_config) | Configuration for the AppConfig application:

* name: The name of the AppConfig application.
* environments: A list of environments to create for the AppConfig application. |
object({
name = string
environments = list(object({
name = string
}))
})
| n/a | yes | +| [lambda](#input\_lambda) | Lambda function used to validate configuration profiles. |
object({
name = string
arn = string
role = object({
name = string
arn = string
})
})
| `null` | no | | [tags](#input\_tags) | n/a | `map(any)` | `{}` | no | ## Outputs @@ -37,4 +39,5 @@ No modules. |------|-------------| | [arn](#output\_arn) | The ARN of the AppConfig application. | | [id](#output\_id) | The ID of the AppConfig application. | +| [lambda](#output\_lambda) | The validator Lambda function passed to the AppConfig application. | \ No newline at end of file diff --git a/build/terraform/aws/lambda/README.md b/build/terraform/aws/lambda/README.md index a9843bac..901ad6fe 100644 --- a/build/terraform/aws/lambda/README.md +++ b/build/terraform/aws/lambda/README.md @@ -41,7 +41,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [access](#input\_access) | List of IAM ARNs that are granted access to the resource. | `list(string)` | `[]` | no | -| [appconfig](#input\_appconfig) | AppConfig application used for configuring the function. If not provided, then no AppConfig configuration will be created for the function. |
object({
arn = string
id = string
})
| `null` | no | +| [appconfig](#input\_appconfig) | AppConfig application used for configuring the function. If not provided, then no AppConfig configuration will be created for the function. |
object({
arn = string
id = string
lambda = optional(object({
name = string
arn = string
role = object({
name = string
arn = string
})
}))
})
| `null` | no | | [config](#input\_config) | Configuration for the Lambda function:

* name: The name of the Lambda function.
* description: The description of the Lambda function.
* image\_uri: The URI of the container image that contains the function code.
* image\_arm: Determines whether the image is an ARM64 image.
* timeout: The amount of time that Lambda allows a function to run before stopping it. The default is 300 seconds.
* memory: The amount of memory that your function has access to. The default is 1024 MB.
* env: A map that defines environment variables for the function.
* vpc\_config: A map that defines the VPC configuration for the function.
* iam\_statements: A list of custom IAM policy statements to attach to the function's role. |
object({
name = string
description = string
image_uri = string
image_arm = bool
timeout = optional(number, 300)
memory = optional(number, 1024)
env = optional(map(any), null)
vpc_config = optional(object({
subnet_ids = list(string)
security_group_ids = list(string)
}), {
subnet_ids = []
security_group_ids = []
})
iam_statements = optional(list(object({
sid = string
actions = list(string)
resources = list(string)
})), [])
})
| n/a | yes | | [kms](#input\_kms) | Customer managed KMS key used to encrypt the function's environment variables. If not provided, then an AWS managed key is used. See https://docs.aws.amazon.com/lambda/latest/dg/security-dataprotection.html#security-privacy-atrest for more information. |
object({
arn = string
id = string
})
| `null` | no | | [tags](#input\_tags) | Tags to apply to all resources. | `map(any)` | `{}` | no | diff --git a/cmd/aws/lambda/README.md b/cmd/aws/lambda/README.md index 517bb090..5760b476 100644 --- a/cmd/aws/lambda/README.md +++ b/cmd/aws/lambda/README.md @@ -22,7 +22,7 @@ This app handles Kinesis Data Stream autoscaling through SNS notifications and C Stream utilization is based on volume (i.e., 60, 000 events per minute) and size (i.e., 10GB data per minute); these values are converted to a percentage (0.0 to 1.0) and the maximum of either is considered the stream's current utilization. -By default, streams must be above the upper threshold for all 5 minutes to scale up and below the lower threshold for at least 57 minutes to scale down. These values can be overriden by the environment variables SUBSTATION_AUTOSCALING_UPSCALE_DATAPOINTS (cannot exceed 5 minutes) and SUBSTATION_AUTOSCALING_DOWNSCALE_DATAPOINTS (cannot exceed 60 minutes). +By default, streams must be above the upper threshold for all 5 minutes to scale up and below the lower threshold for at least 57 minutes to scale down. These values can be overriden by the environment variables AUTOSCALE_KINESIS_UPSCALE_DATAPOINTS (cannot exceed 5 minutes) and AUTOSCALE_KINESIS_DOWNSCALE_DATAPOINTS (cannot exceed 60 minutes). For example: diff --git a/cmd/aws/lambda/substation/main.go b/cmd/aws/lambda/substation/main.go index 984f87cb..720677ef 100644 --- a/cmd/aws/lambda/substation/main.go +++ b/cmd/aws/lambda/substation/main.go @@ -16,10 +16,10 @@ var ( handler string // errLambdaMissingHandler is returned when the Lambda is deployed without a configured handler. - errLambdaMissingHandler = fmt.Errorf("SUBSTATION_HANDLER environment variable is missing") + errLambdaMissingHandler = fmt.Errorf("SUBSTATION_LAMBDA_HANDLER environment variable is missing") // errLambdaInvalidHandler is returned when the Lambda is deployed with an unsupported handler. - errLambdaInvalidHandler = fmt.Errorf("SUBSTATION_HANDLER environment variable is invalid") + errLambdaInvalidHandler = fmt.Errorf("SUBSTATION_LAMBDA_HANDLER environment variable is invalid") // errLambdaInvalidJSON is returned when the Lambda is deployed with a transform that produces invalid JSON. errLambdaInvalidJSON = fmt.Errorf("transformed data is invalid JSON and cannot be returned") @@ -87,7 +87,7 @@ func main() { func init() { var ok bool - handler, ok = os.LookupEnv("SUBSTATION_HANDLER") + handler, ok = os.LookupEnv("SUBSTATION_LAMBDA_HANDLER") if !ok { panic(fmt.Errorf("init handler %s: %v", handler, errLambdaMissingHandler)) } diff --git a/cmd/aws/lambda/validate/validator.go b/cmd/aws/lambda/validate/main.go similarity index 100% rename from cmd/aws/lambda/validate/validator.go rename to cmd/aws/lambda/validate/main.go diff --git a/cmd/aws/lambda/validate/validator_test.go b/cmd/aws/lambda/validate/main_test.go similarity index 100% rename from cmd/aws/lambda/validate/validator_test.go rename to cmd/aws/lambda/validate/main_test.go diff --git a/examples/terraform/aws/cloudwatch_logs/cross_account_cross_region/terraform/consumer.tf b/examples/terraform/aws/cloudwatch_logs/cross_account_cross_region/terraform/consumer.tf index 0f4ac65c..a52c8168 100644 --- a/examples/terraform/aws/cloudwatch_logs/cross_account_cross_region/terraform/consumer.tf +++ b/examples/terraform/aws/cloudwatch_logs/cross_account_cross_region/terraform/consumer.tf @@ -10,7 +10,7 @@ module "lambda_consumer" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/consumer" - "SUBSTATION_HANDLER" : "AWS_KINESIS_DATA_STREAM" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_KINESIS_DATA_STREAM" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/cloudwatch_logs/to_lambda/terraform/consumer.tf b/examples/terraform/aws/cloudwatch_logs/to_lambda/terraform/consumer.tf index bc59ef96..7c13eff3 100644 --- a/examples/terraform/aws/cloudwatch_logs/to_lambda/terraform/consumer.tf +++ b/examples/terraform/aws/cloudwatch_logs/to_lambda/terraform/consumer.tf @@ -13,7 +13,7 @@ module "lambda_consumer" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/consumer" - "SUBSTATION_HANDLER" : "AWS_LAMBDA" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_LAMBDA" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/dynamodb/cdc/terraform/node.tf b/examples/terraform/aws/dynamodb/cdc/terraform/node.tf index b065364d..974ce57d 100644 --- a/examples/terraform/aws/dynamodb/cdc/terraform/node.tf +++ b/examples/terraform/aws/dynamodb/cdc/terraform/node.tf @@ -9,7 +9,7 @@ module "node" { image_arm = true env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/node" - "SUBSTATION_HANDLER" : "AWS_DYNAMODB_STREAM" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_DYNAMODB_STREAM" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/kinesis/firehose/terraform/_resources.tf b/examples/terraform/aws/kinesis/firehose/terraform/_resources.tf index 05ab453d..c487c3c9 100644 --- a/examples/terraform/aws/kinesis/firehose/terraform/_resources.tf +++ b/examples/terraform/aws/kinesis/firehose/terraform/_resources.tf @@ -179,7 +179,7 @@ module "processor" { timeout = 60 env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/processor" - "SUBSTATION_HANDLER" : "AWS_KINESIS_DATA_FIREHOSE" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_KINESIS_DATA_FIREHOSE" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/kinesis/multistream/terraform/publisher.tf b/examples/terraform/aws/kinesis/multistream/terraform/publisher.tf index 331d4415..55de43ec 100644 --- a/examples/terraform/aws/kinesis/multistream/terraform/publisher.tf +++ b/examples/terraform/aws/kinesis/multistream/terraform/publisher.tf @@ -11,7 +11,7 @@ module "lambda_publisher" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/publisher" - "SUBSTATION_HANDLER" : "AWS_KINESIS_DATA_STREAM" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_KINESIS_DATA_STREAM" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/kinesis/multistream/terraform/subscriber.tf b/examples/terraform/aws/kinesis/multistream/terraform/subscriber.tf index 9f569ead..bb8d5b2e 100644 --- a/examples/terraform/aws/kinesis/multistream/terraform/subscriber.tf +++ b/examples/terraform/aws/kinesis/multistream/terraform/subscriber.tf @@ -11,7 +11,7 @@ module "lambda_subscriber" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/subscriber" - "SUBSTATION_HANDLER" : "AWS_KINESIS_DATA_STREAM" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_KINESIS_DATA_STREAM" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/kinesis/time_travel/terraform/enrichment.tf b/examples/terraform/aws/kinesis/time_travel/terraform/enrichment.tf index dd26af8b..d1fa004a 100644 --- a/examples/terraform/aws/kinesis/time_travel/terraform/enrichment.tf +++ b/examples/terraform/aws/kinesis/time_travel/terraform/enrichment.tf @@ -10,7 +10,7 @@ module "lambda_enrichment" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/enrichment" - "SUBSTATION_HANDLER" : "AWS_KINESIS_DATA_STREAM" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_KINESIS_DATA_STREAM" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/kinesis/time_travel/terraform/subscriber.tf b/examples/terraform/aws/kinesis/time_travel/terraform/subscriber.tf index 18952587..8a30ce66 100644 --- a/examples/terraform/aws/kinesis/time_travel/terraform/subscriber.tf +++ b/examples/terraform/aws/kinesis/time_travel/terraform/subscriber.tf @@ -10,7 +10,7 @@ module "lambda_subscriber" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/subscriber" - "SUBSTATION_HANDLER" : "AWS_KINESIS_DATA_STREAM" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_KINESIS_DATA_STREAM" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/lambda/appconfig/terraform/node.tf b/examples/terraform/aws/lambda/appconfig/terraform/node.tf index 2d2b341c..3b859902 100644 --- a/examples/terraform/aws/lambda/appconfig/terraform/node.tf +++ b/examples/terraform/aws/lambda/appconfig/terraform/node.tf @@ -14,7 +14,7 @@ module "node" { timeout = 10 env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/node" - "SUBSTATION_HANDLER" : "AWS_LAMBDA" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_LAMBDA" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/lambda/microservice/terraform/microservice.tf b/examples/terraform/aws/lambda/microservice/terraform/microservice.tf index 3511340a..16f36e0a 100644 --- a/examples/terraform/aws/lambda/microservice/terraform/microservice.tf +++ b/examples/terraform/aws/lambda/microservice/terraform/microservice.tf @@ -12,7 +12,7 @@ module "microservice" { timeout = 10 env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/microservice" - "SUBSTATION_HANDLER" : "AWS_LAMBDA" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_LAMBDA" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/lambda/vpc/terraform/whatismyip.tf b/examples/terraform/aws/lambda/vpc/terraform/whatismyip.tf index e1656226..8d1a8c05 100644 --- a/examples/terraform/aws/lambda/vpc/terraform/whatismyip.tf +++ b/examples/terraform/aws/lambda/vpc/terraform/whatismyip.tf @@ -18,7 +18,7 @@ module "whatismyip" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/whatismyip" - "SUBSTATION_HANDLER" : "AWS_LAMBDA" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_LAMBDA" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/s3/data_lake/terraform/node.tf b/examples/terraform/aws/s3/data_lake/terraform/node.tf index 89345c84..a9ac8734 100644 --- a/examples/terraform/aws/s3/data_lake/terraform/node.tf +++ b/examples/terraform/aws/s3/data_lake/terraform/node.tf @@ -23,7 +23,7 @@ module "lambda_node" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/node" - "SUBSTATION_HANDLER" : "AWS_API_GATEWAY" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_API_GATEWAY" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/s3/sns/terraform/node.tf b/examples/terraform/aws/s3/sns/terraform/node.tf index 65ba24db..fe9394c1 100644 --- a/examples/terraform/aws/s3/sns/terraform/node.tf +++ b/examples/terraform/aws/s3/sns/terraform/node.tf @@ -11,7 +11,7 @@ module "lambda_node" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/node" - "SUBSTATION_HANDLER" : "AWS_S3_SNS" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_S3_SNS" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/s3/xdr/terraform/node.tf b/examples/terraform/aws/s3/xdr/terraform/node.tf index bdef28c9..cc994026 100644 --- a/examples/terraform/aws/s3/xdr/terraform/node.tf +++ b/examples/terraform/aws/s3/xdr/terraform/node.tf @@ -10,7 +10,7 @@ module "lambda_node" { env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/node" - "SUBSTATION_HANDLER" : "AWS_S3" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_S3" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/sns/pub_sub/terraform/subscribers.tf b/examples/terraform/aws/sns/pub_sub/terraform/subscribers.tf index 0e4b7b73..fd5a2069 100644 --- a/examples/terraform/aws/sns/pub_sub/terraform/subscribers.tf +++ b/examples/terraform/aws/sns/pub_sub/terraform/subscribers.tf @@ -9,7 +9,7 @@ module "subscriber_x" { image_arm = true env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/subscriber_x" - "SUBSTATION_HANDLER" : "AWS_SNS" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_SNS" "SUBSTATION_DEBUG" : true } } @@ -49,7 +49,7 @@ module "subscriber_y" { image_arm = true env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/subscriber_y" - "SUBSTATION_HANDLER" : "AWS_SNS" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_SNS" "SUBSTATION_DEBUG" : true } } @@ -90,7 +90,7 @@ module "subscriber_z" { image_arm = true env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/subscriber_z" - "SUBSTATION_HANDLER" : "AWS_SNS" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_SNS" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/sqs/microservice/terraform/frontend.tf b/examples/terraform/aws/sqs/microservice/terraform/frontend.tf index 39c94308..56d08f7a 100644 --- a/examples/terraform/aws/sqs/microservice/terraform/frontend.tf +++ b/examples/terraform/aws/sqs/microservice/terraform/frontend.tf @@ -9,7 +9,7 @@ module "frontend" { image_arm = true env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/frontend" - "SUBSTATION_HANDLER" : "AWS_LAMBDA" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_LAMBDA" "SUBSTATION_DEBUG" : true } } diff --git a/examples/terraform/aws/sqs/microservice/terraform/microservice.tf b/examples/terraform/aws/sqs/microservice/terraform/microservice.tf index 9f764e25..7baf1e89 100644 --- a/examples/terraform/aws/sqs/microservice/terraform/microservice.tf +++ b/examples/terraform/aws/sqs/microservice/terraform/microservice.tf @@ -12,7 +12,7 @@ module "microservice" { timeout = 10 env = { "SUBSTATION_CONFIG" : "http://localhost:2772/applications/substation/environments/example/configurations/microservice" - "SUBSTATION_HANDLER" : "AWS_SQS" + "SUBSTATION_LAMBDA_HANDLER" : "AWS_SQS" "SUBSTATION_DEBUG" : true } } diff --git a/internal/aws/cloudwatch/cloudwatch.go b/internal/aws/cloudwatch/cloudwatch.go index 54d538b0..bf64252e 100644 --- a/internal/aws/cloudwatch/cloudwatch.go +++ b/internal/aws/cloudwatch/cloudwatch.go @@ -21,14 +21,14 @@ const ( ) var ( - // By default, AWS Kinesis streams must be below the lower threshold for 95% of the evaluation period (57 minutes) to scale down. This value can be overridden by the environment variable SUBSTATION_AUTOSCALING_DOWNSCALE_DATAPOINTS, but it cannot exceed 60 minutes. + // By default, AWS Kinesis streams must be below the lower threshold for 95% of the evaluation period (57 minutes) to scale down. This value can be overridden by the environment variable AUTOSCALE_KINESIS_DOWNSCALE_DATAPOINTS, but it cannot exceed 60 minutes. kinesisDownscaleDatapoints = 57 - // By default, AWS Kinesis streams must be above the upper threshold for 100% of the evaluation period (5 minutes) to scale up. This value can be overridden by the environment variable SUBSTATION_AUTOSCALING_UPSCALE_DATAPOINTS, but it cannot exceed 5 minutes. + // By default, AWS Kinesis streams must be above the upper threshold for 100% of the evaluation period (5 minutes) to scale up. This value can be overridden by the environment variable AUTOSCALE_KINESIS_UPSCALE_DATAPOINTS, but it cannot exceed 5 minutes. kinesisUpscaleDatapoints = 5 ) func init() { - if v, found := os.LookupEnv("SUBSTATION_AUTOSCALING_DOWNSCALE_DATAPOINTS"); found { + if v, found := os.LookupEnv("AUTOSCALE_KINESIS_DOWNSCALE_DATAPOINTS"); found { downscale, err := strconv.Atoi(v) if err != nil { panic(err) @@ -39,7 +39,7 @@ func init() { } } - if v, found := os.LookupEnv("SUBSTATION_AUTOSCALING_UPSCALE_DATAPOINTS"); found { + if v, found := os.LookupEnv("AUTOSCALE_KINESIS_UPSCALE_DATAPOINTS"); found { upscale, err := strconv.Atoi(v) if err != nil { panic(err)