Skip to content

Commit 2d3fa12

Browse files
committed
Refactor github app parameter
1 parent 52efdbc commit 2d3fa12

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

examples/default/main.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ module "runners" {
2020
Project = "ProjectX"
2121
}
2222

23-
github_app_client_id = var.github_app_client_id
24-
github_app_client_secret = var.github_app_client_secret
25-
github_app_id = var.github_app_id
26-
github_app_key_base64 = var.github_app_key_base64
27-
github_app_webhook_secret = random_password.random.result
23+
github_app = {
24+
key_base64 = var.github_app_key_base64
25+
id = var.github_app_id
26+
client_id = var.github_app_client_id
27+
client_secret = var.github_app_client_secret
28+
webhook_secret = random_password.random.result
29+
}
2830

2931
enable_organization_runners = false
3032
}

main.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module "webhook" {
3030
tags = local.tags
3131

3232
sqs_build_queue = aws_sqs_queue.queued_builds
33-
github_app_webhook_secret = var.github_app_webhook_secret
33+
github_app_webhook_secret = var.github_app.webhook_secret
3434
}
3535

3636
module "runners" {
@@ -47,10 +47,7 @@ module "runners" {
4747

4848
sqs = aws_sqs_queue.queued_builds
4949

50-
github_app_client_id = var.github_app_client_id
51-
github_app_client_secret = var.github_app_client_secret
52-
github_app_id = var.github_app_id
53-
github_app_key_base64 = var.github_app_key_base64
50+
github_app = var.github_app
5451

5552
enable_organization_runners = var.enable_organization_runners
5653
}

modules/runners/scale-runners-lambda.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ resource "aws_lambda_function" "scale_runners_lambda" {
1010
environment {
1111
variables = {
1212
ENABLE_ORGANIZATION_RUNNERS = var.enable_organization_runners
13-
GITHUB_APP_KEY_BASE64 = var.github_app_key_base64
14-
GITHUB_APP_ID = var.github_app_id
15-
GITHUB_APP_CLIENT_ID = var.github_app_client_id
16-
GITHUB_APP_CLIENT_SECRET = var.github_app_client_secret
13+
GITHUB_APP_KEY_BASE64 = var.github_app.key_base64
14+
GITHUB_APP_ID = var.github_app.id
15+
GITHUB_APP_CLIENT_ID = var.github_app.client_id
16+
GITHUB_APP_CLIENT_SECRET = var.github_app.client_secret
1717
SUBNET_IDS = join(",", var.subnet_ids)
1818
LAUNCH_TEMPLATE_NAME = aws_launch_template.runner.name
1919
LAUNCH_TEMPLATE_VERSION = aws_launch_template.runner.latest_version

modules/runners/variables.tf

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ variable "enable_organization_runners" {
9898
type = bool
9999
}
100100

101-
variable "github_app_key_base64" {}
102-
103-
variable "github_app_id" {}
104-
105-
variable "github_app_client_id" {}
101+
variable "github_app" {
102+
description = "GitHub app parameters, see your github aapp. Ensure the key is base64 encoded."
103+
type = object({
104+
key_base64 = string
105+
id = string
106+
client_id = string
107+
client_secret = string
108+
})
109+
}
106110

107-
variable "github_app_client_secret" {}

variables.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ variable "environment" {
2525
type = string
2626
}
2727

28-
variable "github_app_webhook_secret" {
29-
description = "Secret for the GitHub App webhook"
30-
type = string
31-
}
32-
3328
variable "enable_organization_runners" {
3429
type = bool
3530
}
3631

37-
variable "github_app_key_base64" {}
38-
39-
variable "github_app_id" {}
32+
variable "github_app" {
33+
description = "GitHub app parameters, see your github aapp. Ensure the key is base64 encoded."
34+
type = object({
35+
key_base64 = string
36+
id = string
37+
client_id = string
38+
client_secret = string
39+
webhook_secret = string
40+
})
41+
}
4042

41-
variable "github_app_client_id" {}
4243

43-
variable "github_app_client_secret" {}

0 commit comments

Comments
 (0)