Skip to content

Commit a90fbdb

Browse files
dyajamanMaxrovr
authored andcommitted
Added - Support DR for cloud native applications running on OKE
1 parent 4bf02df commit a90fbdb

11 files changed

+1613
-54
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
variable "bucket_name" {
2+
default = "testBucketName_1"
3+
}
4+
5+
variable "bucket_namespace" {
6+
default = "ansh8lvru1zp"
7+
}
8+
9+
data "oci_identity_tenancy" "test_tenancy" {
10+
#Required
11+
tenancy_id = var.tenancy_ocid
12+
}
13+
14+
data "oci_objectstorage_namespace" "test_namespace" {
15+
16+
#Optional
17+
compartment_id = var.compartment_id
18+
}
19+
20+
data "oci_objectstorage_bucket" "test_bucket" {
21+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
22+
name = var.bucket_name
23+
}
24+
25+
data "oci_objectstorage_bucket" "test_member_bucket" {
26+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
27+
name = "example-bucket-source"
28+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {}
5+
variable "user_ocid" {}
6+
variable "fingerprint" {}
7+
variable "private_key_path" {}
8+
variable "region" {}
9+
variable "compartment_id" {
10+
default = "ocid1.tenancy.oc1..aaaaaaaahowp4zu5z3p3to5mj7vjtlo7zqi2qmbjiij73vfulltlmvtf624a"
11+
}
12+
variable "disassociate_trigger" {
13+
default = 0
14+
}
15+
16+
variable "dr_protection_group_association_peer_region" {
17+
default = "us-ashburn-1"
18+
}
19+
20+
variable "dr_protection_group_association_role" {
21+
default = "STANDBY"
22+
}
23+
24+
variable "dr_protection_group_defined_tags_value" {
25+
default = "value"
26+
}
27+
28+
variable "dr_protection_group_display_name" {
29+
default = "displayName"
30+
}
31+
32+
variable "dr_protection_group_freeform_tags" {
33+
default = { "Department" = "Finance" }
34+
}
35+
36+
variable "dr_protection_group_members_member_type_oke_cluster" {
37+
default = "OKE_CLUSTER"
38+
}
39+
40+
variable "dr_protection_group_state" {
41+
default = "ACTIVE"
42+
}
43+
44+
provider "oci" {
45+
tenancy_ocid = var.tenancy_ocid
46+
user_ocid = var.user_ocid
47+
fingerprint = var.fingerprint
48+
private_key_path = var.private_key_path
49+
region = var.region
50+
}
51+
52+
resource "oci_disaster_recovery_dr_protection_group" "test_peer" {
53+
#Required
54+
compartment_id = var.compartment_id
55+
display_name = var.dr_protection_group_display_name
56+
log_location {
57+
#Required
58+
bucket = data.oci_objectstorage_bucket.test_bucket.name
59+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
60+
}
61+
62+
# Add OKE as a member
63+
members {
64+
#Required
65+
member_id = data.oci_containerengine_clusters.test_clusters.clusters[0].id
66+
member_type = var.dr_protection_group_members_member_type_oke_cluster
67+
peer_cluster_id = data.oci_containerengine_clusters.peer_clusters.clusters[0].id
68+
}
69+
}
70+
71+
resource "oci_disaster_recovery_dr_protection_group" "test_dr_protection_group" {
72+
#Required
73+
compartment_id = var.compartment_id
74+
display_name = var.dr_protection_group_display_name
75+
log_location {
76+
#Required
77+
bucket = data.oci_objectstorage_bucket.test_bucket.name
78+
namespace = data.oci_objectstorage_namespace.test_namespace.namespace
79+
}
80+
81+
lifecycle {
82+
ignore_changes = [defined_tags]
83+
}
84+
85+
#Optional
86+
members {
87+
#Required
88+
member_id = data.oci_containerengine_clusters.peer_clusters.clusters[0].id
89+
member_type = var.dr_protection_group_members_member_type_oke_cluster
90+
peer_cluster_id = data.oci_containerengine_clusters.test_clusters.clusters[0].id
91+
}
92+
93+
association {
94+
#Required
95+
role = var.dr_protection_group_association_role
96+
97+
#Optional
98+
peer_id = oci_disaster_recovery_dr_protection_group.test_peer.id
99+
peer_region = var.dr_protection_group_association_peer_region
100+
}
101+
102+
#Optional
103+
disassociate_trigger = var.disassociate_trigger
104+
105+
defined_tags = map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.dr_protection_group_defined_tags_value}")
106+
freeform_tags = var.dr_protection_group_freeform_tags
107+
}
108+
109+
data "oci_disaster_recovery_dr_protection_groups" "test_dr_protection_groups" {
110+
#Required
111+
compartment_id = var.compartment_id
112+
113+
#Optional
114+
display_name = var.dr_protection_group_display_name
115+
dr_protection_group_id = oci_disaster_recovery_dr_protection_group.test_dr_protection_group.id
116+
state = var.dr_protection_group_state
117+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "primary_cluster_name" {
5+
description = "Primary OKE cluster"
6+
type = string
7+
default = "myCluster"
8+
}
9+
10+
variable "peer_cluster_name" {
11+
description = "Peer OKE cluster"
12+
type = string
13+
default = "peerCluster"
14+
}
15+
16+
data "oci_containerengine_clusters" "test_clusters" {
17+
#Required
18+
compartment_id = var.compartment_id
19+
20+
#Optional
21+
name = var.primary_cluster_name
22+
}
23+
24+
data "oci_containerengine_clusters" "peer_clusters" {
25+
#Required
26+
compartment_id = var.compartment_id
27+
28+
#Optional
29+
name = var.peer_cluster_name
30+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tag_namespace_defined_tags_value" {
5+
default = "value"
6+
}
7+
8+
variable "tag_namespace_description" {
9+
default = "This namespace contains tags that will be used in billing."
10+
}
11+
12+
variable "tag_namespace_freeform_tags" {
13+
default = { "Department" = "Finance" }
14+
}
15+
16+
variable "tag_namespace_include_subcompartments" {
17+
default = false
18+
}
19+
20+
variable "tag_namespace_name" {
21+
default = "BillingTags"
22+
}
23+
24+
variable "tag_namespace_state" {
25+
default = "ACTIVE"
26+
}
27+
28+
variable defined_tag_namespace_name { default = "" }
29+
30+
resource "oci_identity_tag_namespace" "tag-namespace1" {
31+
#Required
32+
compartment_id = var.tenancy_ocid
33+
description = "example tag namespace"
34+
name = var.defined_tag_namespace_name != "" ? var.defined_tag_namespace_name : "example-tag-namespace-all"
35+
36+
is_retired = false
37+
}
38+
39+
resource "oci_identity_tag" "tag1" {
40+
#Required
41+
description = "example tag"
42+
name = "example-tag"
43+
tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id
44+
45+
is_retired = false
46+
}
47+
48+
resource "oci_identity_tag_namespace" "test_tag_namespace" {
49+
#Required
50+
compartment_id = var.compartment_id
51+
description = var.tag_namespace_description
52+
name = var.tag_namespace_name
53+
54+
#Optional
55+
defined_tags = map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.tag_namespace_defined_tags_value}")
56+
freeform_tags = var.tag_namespace_freeform_tags
57+
}
58+
59+
data "oci_identity_tag_namespaces" "test_tag_namespaces" {
60+
#Required
61+
compartment_id = var.compartment_id
62+
63+
#Optional
64+
include_subcompartments = var.tag_namespace_include_subcompartments
65+
state = var.tag_namespace_state
66+
}
67+

internal/integrationtest/disaster_recovery_dr_plan_execution_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var (
6262
}
6363

6464
DisasterRecoveryDrPlanExecutionResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_disaster_recovery_dr_protection_group", "test_peer", acctest.Optional, acctest.Create, DisasterRecoveryPeerDrProtectionGroupRepresentation) +
65+
OKEClusterDependencyConfig +
6566
ObjectStorageBucketDependencyConfig +
6667
VolumeGroupDependencyConfig +
6768
AvailabilityDomainConfig +

internal/integrationtest/disaster_recovery_dr_plan_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ var (
9797
`
9898

9999
DisasterRecoveryDrPlanResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_disaster_recovery_dr_protection_group", "test_peer", acctest.Optional, acctest.Create, DisasterRecoveryPeerDrProtectionGroupRepresentation) +
100+
OKEClusterDependencyConfig +
100101
ObjectStorageBucketDependencyConfig +
101102
VolumeGroupDependencyConfig +
102103
AvailabilityDomainConfig +
@@ -238,7 +239,7 @@ func TestDisasterRecoveryDrPlanResource_basic(t *testing.T) {
238239
resource.TestCheckResourceAttrSet(resourceName, "peer_dr_protection_group_id"),
239240
resource.TestCheckResourceAttrSet(resourceName, "peer_region"),
240241
//resource.TestCheckResourceAttrSet(resourceName, "source_plan_id"),
241-
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "3"),
242+
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "4"),
242243
resource.TestCheckResourceAttrSet(resourceName, "state"),
243244
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
244245
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -271,7 +272,7 @@ func TestDisasterRecoveryDrPlanResource_basic(t *testing.T) {
271272
resource.TestCheckResourceAttrSet(resourceName, "peer_dr_protection_group_id"),
272273
resource.TestCheckResourceAttrSet(resourceName, "peer_region"),
273274
//resource.TestCheckResourceAttrSet(resourceName, "source_plan_id"),
274-
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "3"),
275+
resource.TestCheckResourceAttr(resourceName, "plan_groups.#", "4"),
275276
resource.TestCheckResourceAttrSet(resourceName, "state"),
276277
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
277278
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -338,7 +339,7 @@ func TestDisasterRecoveryDrPlanResource_basic(t *testing.T) {
338339
},
339340
// Disassociate DrProtectionGroup
340341
{
341-
Config: config + compartmentIdVariableStr + DisasterRecoveryDrPlanExecutionResourceDependencies +
342+
Config: config + compartmentIdVariableStr + DisasterRecoveryDrPlanResourceDependencies +
342343
DrProtectionGroupWithDisassociateTriggerConfig,
343344
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
344345
func(s *terraform.State) (err error) {

0 commit comments

Comments
 (0)