-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvariables.tf
More file actions
302 lines (261 loc) · 10.9 KB
/
Copy pathvariables.tf
File metadata and controls
302 lines (261 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# -----------------------------------------------------
# Required variables
# -----------------------------------------------------
variable "name" {
description = "Created resources will be named with this."
type = string
validation {
condition = length(var.name) > 0
error_message = "The name variable cannot be an empty string."
}
}
variable "source_location" {
type = string
description = "Your source code repo location, for example https://github.com/my/repo.git, or `CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION` for org-level webhooks."
validation {
condition = can(regex("^(?:https://github\\.com/[^/]+/[^/]+\\.git|CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION)$", var.source_location))
error_message = "The source_location must be a valid GitHub repository URL in the format: https://github.com/owner/repo.git, or the string `CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION`."
}
}
# -----------------------------------------------------
# Optional variables
# -----------------------------------------------------
# General
variable "source_organization" {
type = string
default = null
description = "Your GitHub organization name for organization-level webhook creation."
}
variable "build_timeout" {
type = number
default = 5
description = "Number of minutes, from 5 to 2160 (36 hours), for AWS CodeBuild to wait until timing out any related build that does not get marked as completed."
validation {
condition = var.build_timeout >= 5 && var.build_timeout <= 2160
error_message = "The build_timeout must be between 5 and 2160 minutes (36 hours)."
}
}
variable "description" {
type = string
default = null
description = "Short description of the project."
}
# environment
variable "environment_type" {
type = string
default = "LINUX_CONTAINER"
description = "Type of build environment to use for related builds. Valid values: `LINUX_CONTAINER`, `LINUX_GPU_CONTAINER`, `WINDOWS_CONTAINER` (deprecated), `WINDOWS_SERVER_2019_CONTAINER`, `ARM_CONTAINER`, `LINUX_LAMBDA_CONTAINER`, `ARM_LAMBDA_CONTAINER`"
}
variable "environment_compute_type" {
type = string
default = "BUILD_GENERAL1_SMALL"
description = " Information about the compute resources the build project will use. Valid values: `BUILD_GENERAL1_SMALL`, `BUILD_GENERAL1_MEDIUM`, `BUILD_GENERAL1_LARGE`, `BUILD_GENERAL1_2XLARGE`, `BUILD_LAMBDA_1GB`, `BUILD_LAMBDA_2GB`, `BUILD_LAMBDA_4GB`, `BUILD_LAMBDA_8GB`, `BUILD_LAMBDA_10GB`. `BUILD_GENERAL1_SMALL` is only valid if type is set to `LINUX_CONTAINER`. When type is set to `LINUX_GPU_CONTAINER`, compute_type must be `BUILD_GENERAL1_LARGE`. When type is set to `LINUX_LAMBDA_CONTAINER` or `ARM_LAMBDA_CONTAINER`, compute_type must be `BUILD_LAMBDA_XGB`"
}
variable "privileged_mode" {
type = bool
default = false
description = "Whether to enable running the Docker daemon inside a Docker container. Set to true if the build project needs to build Docker images or run Docker containers (e.g., via docker-compose, Testcontainers, or LocalStack)."
}
variable "environment_image" {
type = string
default = null
description = "Docker image to use for this build project. Valid values include Docker images provided by CodeBuild (e.g `aws/codebuild/amazonlinux2-x86_64-standard:4.0`), Docker Hub images (e.g., `hashicorp/terraform:latest`) and full Docker repository URIs such as those for ECR (e.g., `137112412989.dkr.ecr.us-west-2.amazonaws.com/amazonlinux:latest`). If not specified and not using ECR, then a default CodeBuild image is used, or if using ECR then an ECR image with a `latest` tag is used."
}
variable "environment_variables" {
description = "List of environment variables to set for the CodeBuild environment. Valid types are `PLAINTEXT`, `PARAMETER_STORE`, and `SECRETS_MANAGER`."
type = list(object({
name = string
value = string
type = string
}))
default = []
validation {
condition = alltrue([
for environment_variable in var.environment_variables :
contains(["PLAINTEXT", "PARAMETER_STORE", "SECRETS_MANAGER"], environment_variable.type)
])
error_message = "Each environment variable type must be one of: PLAINTEXT, PARAMETER_STORE, SECRETS_MANAGER."
}
}
variable "source_auth" {
description = "Override the default CodeBuild source credential for this project. This allows using project-specific authentication instead of the account/region baseline credential. See docs/GITHUB-AUTH-SETUP.md for usage details."
type = object({
type = string
resource = string
})
default = null
}
variable "tags" {
description = "A map of tags to assign to the resources created by this module. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level."
type = map(string)
default = {}
}
variable "webhook_filter_groups" {
description = <<-EOT
CodeBuild webhook filter groups.
Filters within a group are combined with AND logic.
Multiple filter groups are combined with OR logic.
EOT
type = list(list(object({
type = string
pattern = string
exclude_matched_pattern = optional(bool, false)
})))
default = [
[
{
type = "EVENT"
pattern = "WORKFLOW_JOB_QUEUED"
}
]
]
}
# logs
variable "create_cloudwatch_log_group" {
description = "Determines whether a log group is created by this module. If not, AWS will automatically create one if logging is enabled"
type = bool
default = true
}
variable "cloudwatch_logs_group_name" {
description = "Name of the log group used by the CodeBuild project. If not specified then a default is used."
type = string
default = null
}
variable "cloudwatch_logs_stream_name" {
description = "Name of the log stream used by the CodeBuild project. If not specified then a default is used."
type = string
default = null
}
variable "cloudwatch_log_group_retention_in_days" {
description = "Number of days to retain log events"
type = number
default = 14
validation {
condition = contains([
0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653
], var.cloudwatch_log_group_retention_in_days)
error_message = "The cloudwatch_log_group_retention_in_days must be one of the valid CloudWatch Logs retention values: 0 (never expire), 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, or 3653 days."
}
}
variable "s3_logs_bucket_name" {
description = "Name of the S3 bucket to store logs in. If not specified then logging to S3 will be disabled."
type = string
default = null
}
variable "s3_logs_bucket_prefix" {
description = "Prefix to use for the logs in the S3 bucket"
type = string
default = ""
}
# vpc
variable "vpc_id" {
type = string
description = "The VPC ID for AWS CodeBuild to launch ephemeral instances in."
default = null
}
variable "subnet_ids" {
type = list(string)
description = "The list of Subnet IDs for AWS CodeBuild to launch ephemeral EC2 instances in."
default = []
}
variable "security_group_name" {
description = "Name to use on created Security Group. Defaults to `name`"
type = string
default = null
}
variable "security_group_ids" {
type = list(string)
description = "The list of Security Group IDs for AWS CodeBuild to launch ephemeral EC2 instances in."
default = []
}
variable "ingress_with_cidr_blocks" {
description = "List of ingress rules to add to the default security group with CIDR blocks"
type = list(object({
from_port = number
to_port = number
protocol = string
description = string
cidr_blocks = list(string)
}))
default = []
}
variable "ingress_with_source_security_group_id" {
description = "List of ingress rules to add to the default security group with source security group IDs"
type = list(object({
from_port = number
to_port = number
protocol = string
description = string
source_security_group_id = string
}))
default = []
}
# IAM
variable "iam_role_name" {
description = "Name of the IAM role to be used. If not specified then a role will be created"
type = string
default = null
}
variable "iam_role_assume_role_policy" {
description = "The IAM role assume role policy document to use. If not specified then a default is used."
type = string
default = null
}
variable "iam_role_policies" {
description = "Map of IAM role policy ARNs to attach to the IAM role"
type = map(string)
default = {}
}
variable "iam_role_permissions_boundary" {
description = "ARN of the policy that is used to set the permissions boundary for the IAM service role"
type = string
default = null
}
variable "iam_role_path" {
description = "Path of the IAM role. If not specified then the default of '/' is used."
type = string
default = "/"
}
variable "iam_role_tags" {
description = "A map of tags to assign specifically to the IAM role. These tags will be merged with the module-level tags."
type = map(string)
default = {}
}
# GitHub
variable "github_personal_access_token" {
description = "The GitHub personal access token for the region-wide CodeBuild Source Credential. See `docs/GITHUB-AUTH-SETUP.md` for more information."
type = string
default = null
}
variable "github_secretsmanager_secret_arn" {
description = "The Secret ARN containing the credentials to use for the region-wide CodeBuild Source Credential. See `docs/GITHUB-AUTH-SETUP.md` for more information."
type = string
default = null
}
variable "github_personal_access_token_ssm_parameter" {
description = "SSM parameter containing the GitHub personal access token to use for the region-wide CodeBuild Source Credential. See `docs/GITHUB-AUTH-SETUP.md` for more information."
type = string
default = null
}
variable "github_codeconnection_arn" {
description = "ARN of an active GitHub app CodeConnection to use for the region-wide CodeBuild Source Credential. See `docs/GITHUB-AUTH-SETUP.md` for more information."
type = string
default = null
}
# Encryption
variable "kms_key_id" {
description = "The AWS KMS key to be used"
type = string
default = null
}
# Custom image
variable "create_ecr_repository" {
description = "If set to true then an ECR repository will be created, and an image needs to be pushed to it before running the build project"
type = string
default = false
}
variable "ecr_repository_name" {
description = "Name of the ECR repository to create or use. If not specified and `create_ecr_repository` is true, then a default is used."
type = string
default = null
}