-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstorage.tf
71 lines (58 loc) · 2.59 KB
/
storage.tf
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
# CICD utilities Storage
resource "random_string" "deployment_utils_bucket_suffix" {
length = 4
special = false
lower = true
upper = false
}
resource "google_storage_bucket" "deployment_utils" {
name = "${var.infra_name}-utils-${random_string.deployment_utils_bucket_suffix.result}"
location = "US"
storage_class = "STANDARD"
uniform_bucket_level_access = true
provider = google.offensive-pipeline
force_destroy = true
}
resource "google_storage_bucket_object" "disable_windows_defender_ps" {
name = "scripts/Powershell/disabledefender.ps1"
bucket = google_storage_bucket.deployment_utils.name
source = "${path.module}/scripts/Powershell/disabledefender.ps1"
}
resource "google_storage_bucket_object" "gitlab_startup_script" {
depends_on = [
google_storage_bucket_object.gitlab_helpers_script,
google_storage_bucket_object.gcloud_logger_script,
google_storage_bucket_object.gitlab_backup_script]
name = "scripts/bash/gitlab_startup.sh"
bucket = google_storage_bucket.deployment_utils.name
source = "${path.module}/scripts/bash/gitlab_startup.sh"
}
resource "google_storage_bucket_object" "gitlab_helpers_script" {
name = "scripts/bash/gitlab_helpers.sh"
bucket = google_storage_bucket.deployment_utils.name
source = "${path.module}/scripts/bash/gitlab_helpers.sh"
}
resource "google_storage_bucket_object" "gcloud_logger_script" {
name = "scripts/bash/gcloud_logger.sh"
bucket = google_storage_bucket.deployment_utils.name
source = "${path.module}/scripts/bash/gcloud_logger.sh"
}
resource "google_storage_bucket_object" "gitlab_backup_script" {
depends_on = [google_storage_bucket_object.gitlab_helpers_script,
google_storage_bucket_object.gcloud_logger_script]
name = "scripts/bash/gitlab_backup.sh"
bucket = google_storage_bucket.deployment_utils.name
source = "${path.module}/scripts/bash/gitlab_backup.sh"
}
# Migration resource
# Transfer is done in this way since state file won't support big files in resource attributes.
resource "null_resource" "transfer_gitlab_backup" {
count = var.migrate_gitlab ? 1 : 0
triggers = {
gcs_backup_path = "gs://${var.migrate_gitlab_backup_bucket}/${var.migrate_gitlab_backup_path}"
}
provisioner "local-exec" {
when = create
command = "gsutil cp gs://${var.migrate_gitlab_backup_bucket}/${var.migrate_gitlab_backup_path} ${local.gitlab_migrate_backup}"
}
}