Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6d72e6d
Adding BV,BP,BPA resources to terraform samples
niharika-98 Nov 11, 2024
7a4c06c
Updating scripts
niharika-98 Nov 11, 2024
0861f25
Adding code owners and required api enablement
niharika-98 Nov 11, 2024
9e1ceea
Adding gcbdr team as code owners
niharika-98 Nov 11, 2024
a3eb6eb
Fixing code owners
niharika-98 Nov 12, 2024
b258a10
Fixing resource name to default
niharika-98 Nov 12, 2024
859aeb8
Fixing commit
niharika-98 Nov 12, 2024
de0fa63
Merge branch 'main' into gcbdr-samples
niharika-98 Nov 12, 2024
ed8c284
Fixing reviewers
niharika-98 Nov 12, 2024
6a027b1
Adding comment
niharika-98 Nov 13, 2024
6ce52a0
Fixing lint to codeowners
niharika-98 Nov 14, 2024
39393c7
Update gcbdr/backupvault/main.tf
niharika-98 Nov 14, 2024
0c7dd09
Update gcbdr/backupplanassociation/main.tf
niharika-98 Nov 14, 2024
aadf7be
Update gcbdr/backupplan/main.tf
niharika-98 Nov 14, 2024
8ca3519
FIxing lint for resources
niharika-98 Nov 14, 2024
25e8286
Fixing lint in BP and BPA resource files
niharika-98 Nov 18, 2024
9561661
Merge branch 'main' into gcbdr-samples
niharika-98 Nov 20, 2024
71ede18
Update code owners with gcbdr team
niharika-98 Nov 20, 2024
3791fbd
Fixing group name
niharika-98 Nov 20, 2024
e8f6405
Update gcbdr/backupvault/main.tf
niharika-98 Nov 20, 2024
49751f2
FIxing naming issues
niharika-98 Nov 20, 2024
755ab7b
changing backupdr to gcbdr
niharika-98 Nov 20, 2024
31c6293
Updating region tag
niharika-98 Nov 21, 2024
7879467
Updating folder name to backupdr
niharika-98 Nov 21, 2024
35e8005
Fixing code owners and description
niharika-98 Nov 21, 2024
12cf18c
Merge branch 'main' into gcbdr-samples
glasnt Nov 21, 2024
ba1f9ff
Fix labels for backup vault
niharika-98 Nov 21, 2024
1a04f7e
Update backupdr/backup_vault/main.tf
glasnt Nov 21, 2024
9e59fc8
Fixing lint
niharika-98 Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
/traffic_director/ @terraform-google-modules/dee-infra @terraform-google-modules/terraform-samples-reviewers
/vpc/ @terraform-google-modules/dee-infra @terraform-google-modules/terraform-samples-reviewers
/managedkafka/ @terraform-google-modules/managedkafka-dev-team @terraform-google-modules/terraform-samples-reviewers
/backupdr/ @terraform-google-modules/terraform-samples-reviewers
69 changes: 69 additions & 0 deletions gcbdr/backupplan/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
# [START backupdr_create_backupvault]

resource "google_backup_dr_backup_vault" "default" {
provider = google-beta
location = "us-central1"
backup_vault_id = "bv-1"
description = "This is a second backup vault built by Terraform."
backup_minimum_enforced_retention_duration = "100000s"

labels = {
foo = "bar1"
bar = "baz1"
}

annotations = {
annotations1 = "bar1"
annotations2 = "baz1"
}

force_update = "true"
force_delete = "true"
allow_missing = "true"
}

# [END backupdr_create_backupvault]

# [START backupdr_create_backupplan]

# Before creating a backup plan, you need to create backup vault (google_backup_dr_backup_vault).
resource "google_backup_dr_backup_plan" "default" {
provider = google-beta
location = "us-central1"
backup_plan_id = "bp-test"
resource_type = "compute.googleapis.com/Instance"
backup_vault = google_backup_dr_backup_vault.default.name

backup_rules {
rule_id = "rule-1"
backup_retention_days = 5

standard_schedule {
recurrence_type = "HOURLY"
hourly_frequency = 6
time_zone = "UTC"

backup_window {
start_hour_of_day = 0
end_hour_of_day = 24
}
}
}
}

# [END backupdr_create_backupplan]
117 changes: 117 additions & 0 deletions gcbdr/backupplanassociation/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

resource "google_service_account" "default" {
provider = google-beta
account_id = "tf-test-my-custom-1"
display_name = "Custom SA for VM Instance"
}

resource "google_compute_instance" "default" {
provider = google-beta
name = "tf-test-compute-instance-1"
machine_type = "n2-standard-2"
zone = "us-central1-a"
tags = ["foo", "bar"]

boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
labels = {
my_label = "value"
}
}
}

// Local SSD disk
scratch_disk {
interface = "NVME"
}

network_interface {
network = "default"
access_config {
// Ephemeral public IP
}
}

service_account {
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
email = google_service_account.default.email
scopes = ["cloud-platform"]
}
}

resource "google_backup_dr_backup_vault" "default" {
provider = google-beta
location = "us-central1"
backup_vault_id = "tf-test-bv-1"
description = "This is a second backup vault built by Terraform."
backup_minimum_enforced_retention_duration = "100000s"

labels = {
foo = "bar1"
bar = "baz1"
}

annotations = {
annotations1 = "bar1"
annotations2 = "baz1"
}

force_update = "true"
force_delete = "true"
allow_missing = "true"
}

resource "google_backup_dr_backup_plan" "default" {
provider = google-beta
location = "us-central1"
backup_plan_id = "tf-test-bp-test-1"
resource_type = "compute.googleapis.com/Instance"
backup_vault = google_backup_dr_backup_vault.default.name

backup_rules {
rule_id = "rule-1"
backup_retention_days = 2

standard_schedule {
recurrence_type = "HOURLY"
hourly_frequency = 6
time_zone = "UTC"

backup_window {
start_hour_of_day = 12
end_hour_of_day = 18
}
}
}
}

# [START backupdr_create_backupplanassociation]

# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
# and compute instance (google_compute_instance).
resource "google_backup_dr_backup_plan_association" "default" {
provider = google-beta
location = "us-central1"
backup_plan_association_id = "tf-test-bpa-test"
resource = google_compute_instance.default.id
resource_type = "compute.googleapis.com/Instance"
backup_plan = google_backup_dr_backup_plan.default.name
}

# [END backupdr_create_backupplanassociation]
41 changes: 41 additions & 0 deletions gcbdr/backupvault/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

# [START backupdr_create_backupvault]

resource "google_backup_dr_backup_vault" "default" {
provider = google-beta
location = "us-central1"
backup_vault_id = "bv-1"
description = "This is a second backup vault built by Terraform."
backup_minimum_enforced_retention_duration = "100000s"

labels = {
foo = "bar1"
bar = "baz1"
}

annotations = {
annotations1 = "bar1"
annotations2 = "baz1"
}

force_update = "true"
force_delete = "true"
allow_missing = "true"
}

# [END backupdr_create_backupvault]
1 change: 1 addition & 0 deletions test/setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module "projects" {
"anthos.googleapis.com",
"anthospolicycontroller.googleapis.com",
"artifactregistry.googleapis.com",
"backupdr.googleapis.com",
"biglake.googleapis.com",
"bigquery.googleapis.com",
"bigqueryconnection.googleapis.com",
Expand Down