variables.tf 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. variable "aws_region" {
  2. description = "AWS region."
  3. type = string
  4. }
  5. variable "vpc_id" {
  6. description = "The VPC for the security groups."
  7. type = string
  8. }
  9. variable "subnet_ids" {
  10. description = "List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`."
  11. type = list(string)
  12. }
  13. variable "overrides" {
  14. description = "This map provides the possibility to override some defaults. The following attributes are supported: `name_sg` overrides the `Name` tag for all security groups created by this module. `name_runner_agent_instance` overrides the `Name` tag for the ec2 instance defined in the auto launch configuration. `name_docker_machine_runners` overrides the `Name` tag spot instances created by the runner agent."
  15. type = map(string)
  16. default = {
  17. name_runner = ""
  18. name_sg = ""
  19. }
  20. }
  21. variable "tags" {
  22. description = "Map of tags that will be added to created resources. By default resources will be tagged with name."
  23. type = map(string)
  24. default = {}
  25. }
  26. variable "environment" {
  27. description = "A name that identifies the environment, used as prefix and for tagging."
  28. type = string
  29. default = null
  30. validation {
  31. condition = var.environment == null
  32. error_message = "The \"environment\" variable is no longer used. To migrate, set the \"prefix\" variable to the original value of \"environment\" and optionally, add \"Environment\" to the \"tags\" variable map with the same value."
  33. }
  34. }
  35. variable "prefix" {
  36. description = "The prefix used for naming resources"
  37. type = string
  38. default = "github-actions"
  39. }
  40. variable "s3_bucket_runner_binaries" {
  41. type = object({
  42. arn = string
  43. })
  44. }
  45. variable "s3_location_runner_binaries" {
  46. description = "S3 location of runner distribution."
  47. type = string
  48. }
  49. variable "block_device_mappings" {
  50. description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`"
  51. type = list(object({
  52. device_name = string
  53. delete_on_termination = bool
  54. volume_type = string
  55. volume_size = number
  56. encrypted = bool
  57. iops = number
  58. }))
  59. default = [{
  60. device_name = "/dev/xvda"
  61. delete_on_termination = true
  62. volume_type = "gp3"
  63. volume_size = 30
  64. encrypted = true
  65. iops = null
  66. }]
  67. }
  68. variable "market_options" {
  69. description = "DEPCRECATED: Replaced by `instance_target_capacity_type`."
  70. type = string
  71. default = null
  72. validation {
  73. condition = anytrue([var.market_options == null])
  74. error_message = "Deprecated, replaced by `instance_target_capacity_type`."
  75. }
  76. }
  77. variable "instance_target_capacity_type" {
  78. description = "Default lifecyle used runner instances, can be either `spot` or `on-demand`."
  79. type = string
  80. default = "spot"
  81. validation {
  82. condition = contains(["spot", "on-demand"], var.instance_target_capacity_type)
  83. error_message = "The instance target capacity should be either spot or on-demand."
  84. }
  85. }
  86. variable "instance_allocation_strategy" {
  87. description = "The allocation strategy for spot instances. AWS recommends to use `capacity-optimized` however the AWS default is `lowest-price`."
  88. type = string
  89. default = "lowest-price"
  90. validation {
  91. condition = contains(["lowest-price", "diversified", "capacity-optimized", "capacity-optimized-prioritized"], var.instance_allocation_strategy)
  92. error_message = "The instance allocation strategy does not match the allowed values."
  93. }
  94. }
  95. variable "instance_max_spot_price" {
  96. description = "Max price price for spot intances per hour. This variable will be passed to the create fleet as max spot price for the fleet."
  97. type = string
  98. default = null
  99. }
  100. variable "runner_os" {
  101. description = "The EC2 Operating System type to use for action runner instances (linux,windows)."
  102. type = string
  103. default = "linux"
  104. validation {
  105. condition = contains(["linux", "windows"], var.runner_os)
  106. error_message = "Valid values for runner_os are (linux, windows)."
  107. }
  108. }
  109. variable "instance_type" {
  110. description = "[DEPRECATED] See instance_types."
  111. type = string
  112. default = "m5.large"
  113. }
  114. variable "instance_types" {
  115. description = "List of instance types for the action runner. Defaults are based on runner_os (amzn2 for linux and Windows Server Core for win)."
  116. type = list(string)
  117. default = null
  118. }
  119. variable "ami_filter" {
  120. description = "Map of lists used to create the AMI filter for the action runner AMI."
  121. type = map(list(string))
  122. default = null
  123. }
  124. variable "ami_owners" {
  125. description = "The list of owners used to select the AMI of action runner instances."
  126. type = list(string)
  127. default = ["amazon"]
  128. }
  129. variable "enabled_userdata" {
  130. description = "Should the userdata script be enabled for the runner. Set this to false if you are using your own prebuilt AMI"
  131. type = bool
  132. default = true
  133. }
  134. variable "userdata_template" {
  135. description = "Alternative user-data template, replacing the default template. By providing your own user_data you have to take care of installing all required software, including the action runner. Variables userdata_pre/post_install are ignored."
  136. type = string
  137. default = null
  138. }
  139. variable "userdata_pre_install" {
  140. description = "User-data script snippet to insert before GitHub action runner install"
  141. type = string
  142. default = ""
  143. }
  144. variable "userdata_post_install" {
  145. description = "User-data script snippet to insert after GitHub action runner install"
  146. type = string
  147. default = ""
  148. }
  149. variable "sqs_build_queue" {
  150. description = "SQS queue to consume accepted build events."
  151. type = object({
  152. arn = string
  153. })
  154. }
  155. variable "enable_organization_runners" {
  156. type = bool
  157. }
  158. variable "github_app_parameters" {
  159. description = "Parameter Store for GitHub App Parameters."
  160. type = object({
  161. key_base64 = map(string)
  162. id = map(string)
  163. })
  164. }
  165. variable "scale_down_schedule_expression" {
  166. description = "Scheduler expression to check every x for scale down."
  167. type = string
  168. default = "cron(*/5 * * * ? *)"
  169. }
  170. variable "minimum_running_time_in_minutes" {
  171. description = "The time an ec2 action runner should be running at minimum before terminated if non busy. If not set the default is calculated based on the OS."
  172. type = number
  173. default = null
  174. }
  175. variable "runner_boot_time_in_minutes" {
  176. description = "The minimum time for an EC2 runner to boot and register as a runner."
  177. type = number
  178. default = 5
  179. }
  180. variable "runner_extra_labels" {
  181. description = "Extra labels for the runners (GitHub). Separate each label by a comma"
  182. type = string
  183. default = ""
  184. }
  185. variable "runner_group_name" {
  186. description = "Name of the runner group."
  187. type = string
  188. default = "Default"
  189. }
  190. variable "lambda_zip" {
  191. description = "File location of the lambda zip file."
  192. type = string
  193. default = null
  194. }
  195. variable "lambda_timeout_scale_down" {
  196. description = "Time out for the scale down lambda in seconds."
  197. type = number
  198. default = 60
  199. }
  200. variable "scale_up_reserved_concurrent_executions" {
  201. description = "Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations."
  202. type = number
  203. default = 1
  204. }
  205. variable "lambda_timeout_scale_up" {
  206. description = "Time out for the scale up lambda in seconds."
  207. type = number
  208. default = 60
  209. }
  210. variable "role_permissions_boundary" {
  211. description = "Permissions boundary that will be added to the created role for the lambda."
  212. type = string
  213. default = null
  214. }
  215. variable "role_path" {
  216. description = "The path that will be added to the role; if not set, the prefix will be used."
  217. type = string
  218. default = null
  219. }
  220. variable "instance_profile_path" {
  221. description = "The path that will be added to the instance_profile, if not set the prefix will be used."
  222. type = string
  223. default = null
  224. }
  225. variable "runner_as_root" {
  226. description = "Run the action runner under the root user. Variable `runner_run_as` will be ingored."
  227. type = bool
  228. default = false
  229. }
  230. variable "runner_run_as" {
  231. description = "Run the GitHub actions agent as user."
  232. type = string
  233. default = "ec2-user"
  234. }
  235. variable "runners_maximum_count" {
  236. description = "The maximum number of runners that will be created."
  237. type = number
  238. default = 3
  239. }
  240. variable "runner_architecture" {
  241. description = "The platform architecture of the runner instance_type."
  242. type = string
  243. default = "x64"
  244. }
  245. variable "idle_config" {
  246. description = "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."
  247. type = list(object({
  248. cron = string
  249. timeZone = string
  250. idleCount = number
  251. }))
  252. default = []
  253. }
  254. variable "logging_retention_in_days" {
  255. description = "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."
  256. type = number
  257. default = 180
  258. }
  259. variable "logging_kms_key_id" {
  260. description = "Specifies the kms key id to encrypt the logs with"
  261. type = string
  262. default = null
  263. }
  264. variable "enable_ssm_on_runners" {
  265. description = "Enable to allow access to the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances."
  266. type = bool
  267. }
  268. variable "lambda_s3_bucket" {
  269. description = "S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly."
  270. default = null
  271. }
  272. variable "runners_lambda_s3_key" {
  273. description = "S3 key for runners lambda function. Required if using S3 bucket to specify lambdas."
  274. default = null
  275. }
  276. variable "runners_lambda_s3_object_version" {
  277. description = "S3 object version for runners lambda function. Useful if S3 versioning is enabled on source bucket."
  278. default = null
  279. }
  280. variable "create_service_linked_role_spot" {
  281. description = "(optional) create the service linked role for spot instances that is required by the scale-up lambda."
  282. type = bool
  283. default = false
  284. }
  285. variable "aws_partition" {
  286. description = "(optional) partition for the base arn if not 'aws'"
  287. type = string
  288. default = "aws"
  289. }
  290. variable "runner_iam_role_managed_policy_arns" {
  291. description = "Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role"
  292. type = list(string)
  293. default = []
  294. }
  295. variable "enable_cloudwatch_agent" {
  296. description = "Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`."
  297. type = bool
  298. default = true
  299. }
  300. variable "enable_managed_runner_security_group" {
  301. description = "Enabling the default managed security group creation. Unmanaged security groups can be specified via `runner_additional_security_group_ids`."
  302. type = bool
  303. default = true
  304. }
  305. variable "cloudwatch_config" {
  306. description = "(optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details."
  307. type = string
  308. default = null
  309. }
  310. variable "runner_log_files" {
  311. description = "(optional) List of logfiles to send to CloudWatch, will only be used if `enable_cloudwatch_agent` is set to true. Object description: `log_group_name`: Name of the log group, `prefix_log_group`: If true, the log group name will be prefixed with `/github-self-hosted-runners/<var.prefix>`, `file_path`: path to the log file, `log_stream_name`: name of the log stream."
  312. type = list(object({
  313. log_group_name = string
  314. prefix_log_group = bool
  315. file_path = string
  316. log_stream_name = string
  317. }))
  318. default = null
  319. }
  320. variable "ghes_url" {
  321. description = "GitHub Enterprise Server URL. DO NOT SET IF USING PUBLIC GITHUB"
  322. type = string
  323. default = null
  324. }
  325. variable "ghes_ssl_verify" {
  326. description = "GitHub Enterprise SSL verification. Set to 'false' when custom certificate (chains) is used for GitHub Enterprise Server (insecure)."
  327. type = bool
  328. default = true
  329. }
  330. variable "lambda_subnet_ids" {
  331. description = "List of subnets in which the lambda will be launched, the subnets needs to be subnets in the `vpc_id`."
  332. type = list(string)
  333. default = []
  334. }
  335. variable "lambda_security_group_ids" {
  336. description = "List of security group IDs associated with the Lambda function."
  337. type = list(string)
  338. default = []
  339. }
  340. variable "key_name" {
  341. description = "Key pair name"
  342. type = string
  343. default = null
  344. }
  345. variable "runner_additional_security_group_ids" {
  346. description = "(optional) List of additional security groups IDs to apply to the runner"
  347. type = list(string)
  348. default = []
  349. }
  350. variable "kms_key_arn" {
  351. description = "Optional CMK Key ARN to be used for Parameter Store."
  352. type = string
  353. default = null
  354. }
  355. variable "enable_runner_detailed_monitoring" {
  356. description = "Enable detailed monitoring for runners"
  357. type = bool
  358. default = false
  359. }
  360. variable "egress_rules" {
  361. description = "List of egress rules for the GitHub runner instances."
  362. type = list(object({
  363. cidr_blocks = list(string)
  364. ipv6_cidr_blocks = list(string)
  365. prefix_list_ids = list(string)
  366. from_port = number
  367. protocol = string
  368. security_groups = list(string)
  369. self = bool
  370. to_port = number
  371. description = string
  372. }))
  373. default = [{
  374. cidr_blocks = ["0.0.0.0/0"]
  375. ipv6_cidr_blocks = ["::/0"]
  376. prefix_list_ids = null
  377. from_port = 0
  378. protocol = "-1"
  379. security_groups = null
  380. self = null
  381. to_port = 0
  382. description = null
  383. }]
  384. }
  385. variable "log_type" {
  386. description = "Logging format for lambda logging. Valid values are 'json', 'pretty', 'hidden'. "
  387. type = string
  388. default = "pretty"
  389. validation {
  390. condition = anytrue([
  391. var.log_type == "json",
  392. var.log_type == "pretty",
  393. var.log_type == "hidden",
  394. ])
  395. error_message = "`log_type` value not valid. Valid values are 'json', 'pretty', 'hidden'."
  396. }
  397. }
  398. variable "log_level" {
  399. description = "Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'."
  400. type = string
  401. default = "info"
  402. validation {
  403. condition = anytrue([
  404. var.log_level == "silly",
  405. var.log_level == "trace",
  406. var.log_level == "debug",
  407. var.log_level == "info",
  408. var.log_level == "warn",
  409. var.log_level == "error",
  410. var.log_level == "fatal",
  411. ])
  412. error_message = "`log_level` value not valid. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'."
  413. }
  414. }
  415. variable "runner_ec2_tags" {
  416. description = "Map of tags that will be added to the launch template instance tag specificatons."
  417. type = map(string)
  418. default = {}
  419. }
  420. variable "metadata_options" {
  421. description = "Metadata options for the ec2 runner instances."
  422. type = map(any)
  423. default = {
  424. # tfsec:ignore:aws-ec2-enforce-http-token-imds Saltstack doesn't use s3 sources appropriately; see https://github.com/saltstack/salt/issues/60668
  425. # checkov:skip=CKV_AWS_79:see tfsec explanation
  426. http_endpoint = "enabled"
  427. http_tokens = "optional"
  428. http_put_response_hop_limit = 1
  429. }
  430. }
  431. variable "enable_ephemeral_runners" {
  432. description = "Enable ephemeral runners, runners will only be used once."
  433. type = bool
  434. default = false
  435. }
  436. variable "enable_job_queued_check" {
  437. description = "Only scale if the job event received by the scale up lambda is is in the state queued. By default enabled for non ephemeral runners and disabled for ephemeral. Set this variable to overwrite the default behavior."
  438. type = bool
  439. default = null
  440. }
  441. variable "pool_lambda_timeout" {
  442. description = "Time out for the pool lambda lambda in seconds."
  443. type = number
  444. default = 60
  445. }
  446. variable "pool_runner_owner" {
  447. description = "The pool will deploy runners to the GitHub org ID, set this value to the org to which you want the runners deployed. Repo level is not supported."
  448. type = string
  449. default = null
  450. }
  451. variable "pool_lambda_reserved_concurrent_executions" {
  452. description = "Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations."
  453. type = number
  454. default = 1
  455. }
  456. variable "pool_config" {
  457. description = "The configuration for updating the pool. The `pool_size` to adjust to by the events triggered by the the `schedule_expression. For example you can configure a cron expression for week days to adjust the pool to 10 and another expression for the weekend to adjust the pool to 1."
  458. type = list(object({
  459. schedule_expression = string
  460. size = number
  461. }))
  462. default = []
  463. }
  464. variable "disable_runner_autoupdate" {
  465. description = "Disable the auto update of the github runner agent. Be-aware there is a grace period of 30 days, see also the [GitHub article](https://github.blog/changelog/2022-02-01-github-actions-self-hosted-runners-can-now-disable-automatic-updates/)"
  466. type = bool
  467. default = false
  468. }
  469. variable "lambda_runtime" {
  470. description = "AWS Lambda runtime."
  471. type = string
  472. default = "nodejs16.x"
  473. }
  474. variable "lambda_architecture" {
  475. description = "AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86_64' functions. "
  476. type = string
  477. default = "x86_64"
  478. validation {
  479. condition = contains(["arm64", "x86_64"], var.lambda_architecture)
  480. error_message = "`lambda_architecture` value is not valid, valid values are: `arm64` and `x86_64`."
  481. }
  482. }