-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../global_variables.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,61 @@ | ||
resource "oci_identity_user" "grafana" { | ||
description = "" | ||
description = "grafana" | ||
name = "grafana" | ||
email = "grafana.sa@dcotta.com" | ||
} | ||
|
||
resource "oci_identity_group" "metrics" { | ||
description = "grafana" | ||
description = "grafana metrics" | ||
name = "metrics" | ||
|
||
} | ||
|
||
resource "oci_identity_policy" "metrics" { | ||
compartment_id = local.ociRoot | ||
description = "" | ||
description = "grafana metrics" | ||
name = "metrics" | ||
statements = [ | ||
"allow group grafana to read metrics in tenancy", | ||
"allow group grafana to read compartments in tenancy", | ||
"allow group metrics to read metrics in tenancy", | ||
"allow group metrics to inspect metrics in tenancy", | ||
# "allow group grafana to inspect metrics in compartment cottand9000", | ||
"allow group metrics to read compartments in tenancy", | ||
] | ||
} | ||
|
||
resource "oci_identity_user_group_membership" "grafana" { | ||
group_id = oci_identity_group.metrics.id | ||
user_id = oci_identity_user.grafana.id | ||
} | ||
|
||
data "vault_kv_secret_v2" "grafana_oci" { | ||
mount = "secret" | ||
name = "nomad/job/grafana/oci_user" | ||
} | ||
|
||
resource "oci_identity_api_key" "grafana" { | ||
key_value = data.vault_kv_secret_v2.grafana_oci.data["publicKeyPem"] | ||
user_id = oci_identity_user.grafana.id | ||
} | ||
|
||
resource "grafana_data_source" "oci" { | ||
name = "oci" | ||
type = "oci-metrics-datasource" | ||
} | ||
|
||
|
||
resource "grafana_data_source_config" "oci" { | ||
uid = grafana_data_source.oci.uid | ||
# https://github.com/oracle/oci-grafana-metrics/blob/master/docs/datasource_configuration.md | ||
json_data_encoded = jsonencode({ | ||
"profile0" : "DEFAULT", | ||
"region0" : "eu-frankfurt-1", | ||
"tenancymode" : "single", | ||
"environment" : "local", | ||
}) | ||
|
||
secure_json_data_encoded = jsonencode({ | ||
user0 : oci_identity_user.grafana.id | ||
tenancy0 : local.ociTenancyOcid | ||
fingerprint0 : oci_identity_api_key.grafana.fingerprint | ||
privkey0 : data.vault_kv_secret_v2.grafana_oci.data["privateKey"] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters