Skip to content

Commit c6badbf

Browse files
mcaulifnnpalmdependabot[bot]ravenolfravenolf
committed
feat: Store lambda secrets paramaters in Paramater Store (#941)
* fix(scale): Refactor Runner Type and Owner (#871) * fix(scale): Refactor Runner Type and Owner * `environment` should not be optional * feat: support multiple instance types (#898) * fix(scale): Refactor Runner Type and Owner * `environment` should not be optional * feat(runners): Support Multiple Instance Types * Correcting failed launch logic * Updating tests * Test for all launch templates failing * Marking `instance_type` as deprecated * docs: fix lambda_security_group_ids incorrect description #738 (#902) close #738 * fix: scale down runners (#905) * fix: scale down runners * fix: scale down runners * chore: group upgrade lambda dependencies (#906) * chore: upgrade dependencies for lambda's * fix auth-app to 3.4.0, issues #904 addresses the issue * feat(runner): Move Lambda Vars to Parameter Store * Add test for ssm module (#1) * Add test for ssm module * Fixing lint * Removing KMS/GH Auth from scale-down * Add SSM permissions to runner policy * Allow custom key_id * Fixing for loop * Move SSM policy to Lambdas * Fixing function call * chore: Bump aws-sdk (#752) (#909) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#908) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#887) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#885) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#889) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#892) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#907) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump aws-sdk (#752) (#864) Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump eslint in /modules/webhook/lambdas/webhook (#918) Bumps [eslint](https://github.com/eslint/eslint) from 7.28.0 to 7.29.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](eslint/eslint@v7.28.0...v7.29.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump typescript (#929) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](microsoft/TypeScript@v4.3.3...v4.3.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump @typescript-eslint/eslint-plugin (#928) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.27.0 to 4.28.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump typescript in /modules/webhook/lambdas/webhook (#926) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](microsoft/TypeScript@v4.3.3...v4.3.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: Added support for white listing of repositories (#915) * add white listing of repositories Signed-off-by: ravenolf <[email protected]> * fix variable naming Signed-off-by: ravenolf <[email protected]> * add unit test * update docs * add successful unit test Co-authored-by: ravenolf <[email protected]> * Need `,` after list item * Move Lambda Policy to data resource * Addressing PR comments, fixing lint * Refactoring Parameters to SSM Module * Fixing rebase * Using only key ARN as input value Co-authored-by: Niek Palm <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sofiane Benahmed <[email protected]> Co-authored-by: ravenolf <[email protected]>
1 parent 09476eb commit c6badbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2995
-2389
lines changed

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Scaling down the runners is at the moment brute-forced, every configurable amoun
5050

5151
Downloading the GitHub Action Runner distribution can be occasionally slow (more than 10 minutes). Therefore a lambda is introduced that synchronizes the action runner binary from GitHub to an S3 bucket. The EC2 instance will fetch the distribution from the S3 bucket instead of the internet.
5252

53-
Secrets and private keys which are passed to the lambdas as environment variables are encrypted by default by a KMS key managed by the module. Alternatively you can pass your own KMS key. Encryption via KMS can be complete disabled by setting `encrypt_secrets` to `false`.
53+
Secrets and private keys are stored in SSM Parameter Store. These values are encrypted using the default KMS key for SSM or passing in a custom KMS key.
5454

5555
![Architecture](docs/component-overview.svg)
5656

@@ -325,14 +325,13 @@ No requirements.
325325
|------|--------|---------|
326326
| runner_binaries | ./modules/runner-binaries-syncer | |
327327
| runners | ./modules/runners | |
328+
| ssm | ./modules/ssm | |
328329
| webhook | ./modules/webhook | |
329330

330331
## Resources
331332

332333
| Name |
333334
|------|
334-
| [aws_kms_alias](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) |
335-
| [aws_kms_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) |
336335
| [aws_resourcegroups_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/resourcegroups_group) |
337336
| [aws_sqs_queue](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) |
338337
| [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) |
@@ -351,7 +350,6 @@ No requirements.
351350
| enable\_cloudwatch\_agent | Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
352351
| enable\_organization\_runners | Register runners to organization, instead of repo level | `bool` | `false` | no |
353352
| enable\_ssm\_on\_runners | Enable to allow access the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances. | `bool` | `false` | no |
354-
| encrypt\_secrets | Encrypt secret variables for lambda's such as secrets and private keys. | `bool` | `true` | no |
355353
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
356354
| ghes\_url | GitHub Enterprise Server URL. Example: https://github.internal.co - DO NOT SET IF USING PUBLIC GITHUB | `string` | `null` | no |
357355
| github\_app | GitHub app parameters, see your github app. Ensure the key is the base64-encoded `.pem` file (the output of `base64 app.private-key.pem`, not the content of `private-key.pem`). | <pre>object({<br> key_base64 = string<br> id = string<br> client_id = string<br> client_secret = string<br> webhook_secret = string<br> })</pre> | n/a | yes |
@@ -360,12 +358,11 @@ No requirements.
360358
| instance\_type | [DEPRECATED] See instance\_types. | `string` | `"m5.large"` | no |
361359
| instance\_types | List of instance types for the action runner. | `set(string)` | `null` | no |
362360
| key\_name | Key pair name | `string` | `null` | no |
363-
| kms\_key\_id | Custom KMS key to encrypted lambda secrets, if not provided and `encrypt_secrets` = `true` a KMS key will be created by the module. Secrets will be encrypted with a context `Environment = var.environment`. | `string` | `null` | no |
361+
| kms\_key\_arn | Optional CMK Key ARN to be used for Parameter Store. This key must be in the current account. | `string` | `null` | no |
364362
| lambda\_s3\_bucket | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
365363
| lambda\_security\_group\_ids | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no |
366364
| lambda\_subnet\_ids | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | `[]` | no |
367365
| logging\_retention\_in\_days | Specifies the number of days you want to retain log events for the lambda log group. Possible values are: 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `180` | no |
368-
| manage\_kms\_key | Let the module manage the KMS key. | `bool` | `true` | no |
369366
| market\_options | Market options for the action runner instances. Setting the value to `null` let the scaler create on-demand instances instead of spot instances. | `string` | `"spot"` | no |
370367
| minimum\_running\_time\_in\_minutes | The time an ec2 action runner should be running at minimum before terminated if non busy. | `number` | `5` | no |
371368
| repository\_white\_list | List of repositories allowed to use the github app | `list(string)` | `[]` | no |
@@ -407,6 +404,7 @@ No requirements.
407404
|------|-------------|
408405
| binaries\_syncer | n/a |
409406
| runners | n/a |
407+
| ssm\_parameters | n/a |
410408
| webhook | n/a |
411409
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
412410

kms.tf

-15
This file was deleted.

main.tf

+22-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ locals {
77
runner_architecture = substr(var.instance_type, 0, 2) == "a1" || substr(var.instance_type, 1, 2) == "6g" ? "arm64" : "x64"
88

99
ami_filter = length(var.ami_filter) > 0 ? var.ami_filter : local.runner_architecture == "arm64" ? { name = ["amzn2-ami-hvm-2*-arm64-gp2"] } : { name = ["amzn2-ami-hvm-2.*-x86_64-ebs"] }
10+
11+
github_app_parameters = {
12+
client_id = module.ssm.parameters.github_app_client_id
13+
client_secret = module.ssm.parameters.github_app_client_secret
14+
id = module.ssm.parameters.github_app_id
15+
key_base64 = module.ssm.parameters.github_app_key_base64
16+
}
1017
}
1118

1219
resource "random_string" "random" {
@@ -26,19 +33,25 @@ resource "aws_sqs_queue" "queued_builds" {
2633
tags = var.tags
2734
}
2835

36+
module "ssm" {
37+
source = "./modules/ssm"
38+
39+
kms_key_arn = var.kms_key_arn
40+
environment = var.environment
41+
github_app = var.github_app
42+
tags = local.tags
43+
}
44+
2945
module "webhook" {
3046
source = "./modules/webhook"
3147

3248
aws_region = var.aws_region
3349
environment = var.environment
3450
tags = local.tags
35-
encryption = {
36-
kms_key_id = local.kms_key_id
37-
encrypt = var.encrypt_secrets
38-
}
51+
kms_key_arn = var.kms_key_arn
3952

40-
sqs_build_queue = aws_sqs_queue.queued_builds
41-
github_app_webhook_secret = var.github_app.webhook_secret
53+
sqs_build_queue = aws_sqs_queue.queued_builds
54+
github_app_webhook_secret_arn = module.ssm.parameters.github_app_webhook_secret.arn
4255

4356
lambda_s3_bucket = var.lambda_s3_bucket
4457
webhook_lambda_s3_key = var.webhook_lambda_s3_key
@@ -60,10 +73,6 @@ module "runners" {
6073
subnet_ids = var.subnet_ids
6174
environment = var.environment
6275
tags = local.tags
63-
encryption = {
64-
kms_key_id = local.kms_key_id
65-
encrypt = var.encrypt_secrets
66-
}
6776

6877
s3_bucket_runner_binaries = module.runner_binaries.bucket
6978
s3_location_runner_binaries = local.s3_action_runner_url
@@ -78,7 +87,7 @@ module "runners" {
7887
ami_owners = var.ami_owners
7988

8089
sqs_build_queue = aws_sqs_queue.queued_builds
81-
github_app = var.github_app
90+
github_app_parameters = local.github_app_parameters
8291
enable_organization_runners = var.enable_organization_runners
8392
scale_down_schedule_expression = var.scale_down_schedule_expression
8493
minimum_running_time_in_minutes = var.minimum_running_time_in_minutes
@@ -118,6 +127,8 @@ module "runners" {
118127
runner_iam_role_managed_policy_arns = var.runner_iam_role_managed_policy_arns
119128

120129
ghes_url = var.ghes_url
130+
131+
kms_key_arn = var.kms_key_arn
121132
}
122133

123134
module "runner_binaries" {

modules/runners/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ No Modules.
7676
| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) |
7777
| [aws_iam_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) |
7878
| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) |
79-
| [aws_kms_ciphertext](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_ciphertext) |
80-
| [aws_kms_grant](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_grant) |
8179
| [aws_lambda_event_source_mapping](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) |
8280
| [aws_lambda_function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) |
8381
| [aws_lambda_permission](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) |
@@ -98,15 +96,15 @@ No Modules.
9896
| enable\_cloudwatch\_agent | Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
9997
| enable\_organization\_runners | n/a | `bool` | n/a | yes |
10098
| enable\_ssm\_on\_runners | Enable to allow access the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances. | `bool` | n/a | yes |
101-
| encryption | KMS key to encrypted lambda environment secrets. Either provide a key and `encrypt` set to `true`. Or set the key to `null` and encrypt to `false`. | <pre>object({<br> kms_key_id = string<br> encrypt = bool<br> })</pre> | n/a | yes |
10299
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
103100
| ghes\_url | GitHub Enterprise Server URL. DO NOT SET IF USING PUBLIC GITHUB | `string` | `null` | no |
104-
| github\_app | GitHub app parameters, see your github app. Ensure the key is the base64-encoded `.pem` file (the output of `base64 app.private-key.pem`, not the content of `private-key.pem`). | <pre>object({<br> key_base64 = string<br> id = string<br> client_id = string<br> client_secret = string<br> })</pre> | n/a | yes |
101+
| github\_app\_parameters | Parameter Store for GitHub App Parameters. | <pre>object({<br> key_base64 = map(string)<br> id = map(string)<br> client_id = map(string)<br> client_secret = map(string)<br> })</pre> | n/a | yes |
105102
| idle\_config | List of time period that can be defined as cron expression to keep a minimum amount of runners active instead of scaling down to 0. By defining this list you can ensure that in time periods that match the cron expression within 5 seconds a runner is kept idle. | <pre>list(object({<br> cron = string<br> timeZone = string<br> idleCount = number<br> }))</pre> | `[]` | no |
106103
| instance\_profile\_path | The path that will be added to the instance\_profile, if not set the environment name will be used. | `string` | `null` | no |
107104
| instance\_type | [DEPRECATED] See instance\_types. | `string` | `"m5.large"` | no |
108105
| instance\_types | List of instance types for the action runner. | `set(string)` | `null` | no |
109106
| key\_name | Key pair name | `string` | `null` | no |
107+
| kms\_key\_arn | Optional CMK Key ARN to be used for Parameter Store. | `string` | `null` | no |
110108
| lambda\_s3\_bucket | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
111109
| lambda\_security\_group\_ids | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no |
112110
| lambda\_subnet\_ids | List of subnets in which the lambda will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | `[]` | no |

modules/runners/encrypt.tf

-24
This file was deleted.

modules/runners/lambdas/runners/package.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,35 @@
1212
"build": "ncc build src/lambda.ts -o dist",
1313
"dist": "yarn build && cd dist && zip ../runners.zip index.js",
1414
"format": "prettier --write \"**/*.ts\"",
15-
"format-check": "prettier --check \"**/*.ts\""
15+
"format-check": "prettier --check \"**/*.ts\"",
16+
"all": "yarn build && yarn format && yarn lint && yarn test"
1617
},
1718
"devDependencies": {
1819
"@types/aws-lambda": "^8.10.75",
1920
"@types/express": "^4.17.11",
20-
"@types/jest": "^26.0.20",
21+
"@types/jest": "^26.0.24",
2122
"@typescript-eslint/eslint-plugin": "^4.17.0",
2223
"@typescript-eslint/parser": "^4.22.0",
2324
"@vercel/ncc": "^0.29.0",
2425
"eslint": "^7.22.0",
25-
"jest": "^26.6.3",
26+
"eslint-plugin-prettier": "3.4.0",
27+
"jest": "27.0.6",
2628
"jest-mock-extended": "^1.0.13",
2729
"moment-timezone": "^0.5.33",
2830
"nock": "^13.0.11",
29-
"ts-jest": "^26.5.5",
31+
"prettier": "2.3.2",
32+
"ts-jest": "^27.0.4",
33+
"ts-node": "^10.1.0",
3034
"ts-node-dev": "^1.1.6"
3135
},
3236
"dependencies": {
37+
"@aws-sdk/client-ssm": "^3.18.0",
3338
"@octokit/auth-app": "3.4.0",
3439
"@octokit/rest": "^18.3.5",
3540
"@octokit/types": "^6.13.0",
3641
"@types/aws-lambda": "^8.10.75",
3742
"@types/express": "^4.17.11",
38-
"@types/node": "^15.12.2",
43+
"@types/node": "^16.4.3",
3944
"aws-sdk": "^2.888.0",
4045
"cron-parser": "^3.3.0",
4146
"typescript": "^4.2.3",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { scaleDown } from './scale-runners/scale-down';
2+
3+
4+
export function run(): void {
5+
scaleDown();
6+
}
7+
8+
run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { scaleUp } from './scale-runners/scale-up';
2+
3+
const sqsEvent = {
4+
Records: [
5+
{
6+
messageId: 'e8d74d08-644e-42ca-bf82-a67daa6c4dad',
7+
// eslint-disable-next-line max-len
8+
receiptHandle: 'AQEBCpLYzDEKq4aKSJyFQCkJduSKZef8SJVOperbYyNhXqqnpFG5k74WygVAJ4O0+9nybRyeOFThvITOaS21/jeHiI5fgaM9YKuI0oGYeWCIzPQsluW5CMDmtvqv1aA8sXQ5n2x0L9MJkzgdIHTC3YWBFLQ2AxSveOyIHwW+cHLIFCAcZlOaaf0YtaLfGHGkAC4IfycmaijV8NSlzYgDuxrC9sIsWJ0bSvk5iT4ru/R4+0cjm7qZtGlc04k9xk5Fu6A+wRxMaIyiFRY+Ya19ykcevQldidmEjEWvN6CRToLgclk=',
9+
// eslint-disable-next-line max-len
10+
body: { "id": 19072, "repositoryName": "ErrBud", "repositoryOwner": "ActionsTest", "eventType": "check_run", "installationId": 5 },
11+
attributes: {
12+
ApproximateReceiveCount: '1',
13+
SentTimestamp: '1626450047230',
14+
SequenceNumber: '18863115285800432640',
15+
MessageGroupId: '19072',
16+
SenderId: 'AROA5KW7SQ6TTB3PW6WPH:cicddev-webhook',
17+
MessageDeduplicationId: '0c458eeb87b7f6d2607301268fd3bf33dd898a49ebd888754ff7db510c4bff1e',
18+
ApproximateFirstReceiveTimestamp: '1626450077251'
19+
},
20+
messageAttributes: {},
21+
md5OfBody: '4aef3bd70526e152e86426a0938cbec6',
22+
eventSource: 'aws:sqs',
23+
eventSourceARN: 'arn:aws:sqs:us-west-2:916370655143:cicddev-queued-builds.fifo',
24+
awsRegion: 'us-west-2'
25+
}
26+
]
27+
};
28+
export function run(): void {
29+
scaleUp(sqsEvent.Records[0].eventSource, sqsEvent.Records[0].body);
30+
}
31+
32+
run();

0 commit comments

Comments
 (0)