Skip to content

Commit 023ccdb

Browse files
ccushingbriangustafson
authored andcommitted
Factor identity examples into single template
* Factor multi-region example into distinct "concept" folder
1 parent 6313196 commit 023ccdb

File tree

15 files changed

+257
-196
lines changed

15 files changed

+257
-196
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This example file demonstrates how to read AD values from multiple regions and employ filters
3+
* to isolate specific ADs.
4+
*/
5+
6+
data "oci_identity_availability_domains" "ad-phx" {
7+
compartment_id = "${var.tenancy_ocid}"
8+
9+
filter {
10+
name = "name"
11+
values = ["\\w*-AD-1"]
12+
regex = true
13+
}
14+
}
15+
16+
data "oci_identity_availability_domains" "ad-iad" {
17+
provider = "oci.iad"
18+
compartment_id = "${var.tenancy_ocid}"
19+
20+
filter {
21+
name = "name"
22+
values = ["\\w*-AD-1"]
23+
regex = true
24+
}
25+
}
26+
27+
28+
output "ad-phx" {
29+
value = "${data.oci_identity_availability_domains.ad-phx.availability_domains}"
30+
}
31+
32+
output "ad-iad" {
33+
value = "${data.oci_identity_availability_domains.ad-iad.availability_domains}"
34+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* This example file shows how to configure multiple oci providers to target different regions.
3+
*/
4+
5+
// These variables would commonly be defined as environment variablbe or sourced in a .env file
6+
variable "tenancy_ocid" {}
7+
variable "user_ocid" {}
8+
variable "fingerprint" {}
9+
variable "private_key_path" {}
10+
variable "compartment_ocid" {}
11+
12+
// This provider has no alias and consequently will be used by resources that do not specify an alias
13+
provider "oci" {
14+
region = "us-phoenix-1"
15+
tenancy_ocid = "${var.tenancy_ocid}"
16+
user_ocid = "${var.user_ocid}"
17+
fingerprint = "${var.fingerprint}"
18+
private_key_path = "${var.private_key_path}"
19+
}
20+
21+
// This provider defines an alias and is targetable by resources by including `provider = "oci.iad"`.
22+
provider "oci" {
23+
region = "us-ashburn-1"
24+
alias = "iad"
25+
tenancy_ocid = "${var.tenancy_ocid}"
26+
user_ocid = "${var.user_ocid}"
27+
fingerprint = "${var.fingerprint}"
28+
private_key_path = "${var.private_key_path}"
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ___ ____ _ ____ _ _____
2+
# / _ \| _ \ / \ / ___| | | ____|
3+
# | | | | |_) | / _ \| | | | | _|
4+
# | |_| | _ < / ___ | |___| |___| |___
5+
# \___/|_| \_/_/ \_\____|_____|_____|
6+
***
7+
8+
## Multi-Region Provider Configuration
9+
10+
This example demonstrates how to:
11+
* Define multiple OCI providers targeting different regions
12+
* List and filter Availability Domains across regions

docs/examples/iam/ad_multi_region/ad_multi_region.tf

Lines changed: 0 additions & 59 deletions
This file was deleted.

docs/examples/iam/compartment/compartment.tf

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/examples/iam/group/group.tf

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/examples/iam/policy/policy.tf

Lines changed: 0 additions & 48 deletions
This file was deleted.

docs/examples/iam/user/user.tf

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This example file demonstrates how to read AD values from a region and employ filters
3+
* to isolate specific ADs.
4+
*/
5+
6+
7+
data "oci_identity_availability_domains" "ads" {
8+
compartment_id = "${var.tenancy_ocid}"
9+
10+
filter {
11+
name = "name"
12+
values = ["\\w*-AD-1"]
13+
regex = true
14+
}
15+
}
16+
17+
output "ads" {
18+
value = "${data.oci_identity_availability_domains.ads.availability_domains}"
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* This example file shows how to create a compartment or reference an existing compartment as a resource.
3+
*
4+
* Note: the compartment resource internally resolves name collisions and returns a reference to the preexisting
5+
* compartment. Compartments can not be deleted, so removing a compartment resource from your .tf file will only
6+
* remove it from your statefile.
7+
*/
8+
9+
resource "oci_identity_compartment" "compartment1" {
10+
name = "tf-example-compartment"
11+
description = "compartment created by terraform"
12+
}
13+
14+
data "oci_identity_compartments" "compartments1" {
15+
compartment_id = "${oci_identity_compartment.compartment1.compartment_id}"
16+
17+
filter {
18+
name = "name"
19+
values = ["tf-example-compartment"]
20+
}
21+
}
22+
23+
output "compartments" {
24+
value = "${data.oci_identity_compartments.compartments1.compartments}"
25+
}

0 commit comments

Comments
 (0)