Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add grafana terraform definition and comment for accessing key #287

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
29 changes: 29 additions & 0 deletions grafana/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions grafana/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
terraform {
r33drichards marked this conversation as resolved.
Show resolved Hide resolved
required_providers {
grafana = {
source = "grafana/grafana"
}
}
}

variable "grafana_cloud_access_policy_token_secret_name" {
type = string
description = <<EOT
The name of the secret in GCP Secret Manager that contains the Grafana cloud access policy token.

should have permissions:
- stacks read write delete
- stack-service-accounts write
EOT

default = "e2b-grafana-cloud-access-policy-token"
}

data "google_secret_manager_secret_version" "grafana_cloud_access_policy_token" {
secret = var.grafana_cloud_access_policy_token_secret_name
}

// Step 1: Create a stack
provider "grafana" {
alias = "cloud"
cloud_access_policy_token = data.google_secret_manager_secret_version.grafana_cloud_access_policy_token.secret_data
}

resource "grafana_cloud_stack" "my_stack" {
provider = grafana.cloud

name = "e2b-stack"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use var.prefix as we do in all other places 🙏🏻

slug = "e2b-stack"
region_slug = "us"
}

// Step 2: Create a service account and key for the stack
resource "grafana_cloud_stack_service_account" "cloud_sa" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really needed, it seems to me you only need to create Access Policy token
terraform resource

provider = grafana.cloud
stack_slug = grafana_cloud_stack.my_stack.slug

name = "e2b-stack-service-account"
r33drichards marked this conversation as resolved.
Show resolved Hide resolved
role = "Admin"
is_disabled = false
}

resource "grafana_cloud_stack_service_account_token" "cloud_sa" {
provider = grafana.cloud
stack_slug = grafana_cloud_stack.my_stack.slug

name = "e2b-stack-service-account-token"
service_account_id = grafana_cloud_stack_service_account.cloud_sa.id
}

# grafana_cloud_stack_service_account_token.cloud_sa.key // <-- how to get the key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes to the GCP secret


2 changes: 1 addition & 1 deletion self-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Check if you can use config for terraform state management
12. Secrets are created and stored in GCP Secrets Manager. Once created, that is the source of truth--you will need to update values there to make changes. Create a secret value for the following secrets:
- e2b-cloudflare-api-token
- e2b-postgres-connection-string
- Grafana secrets (optional)
- e2b-grafana-cloud-access-policy-token (optional)
- Posthog API keys for monitoring (optional)
13. Run `make plan-without-jobs` and then `make apply`
14. Run `make plan` and then `make apply`. Note: This will work after the TLS certificates was issued. It1 can take some time; you can check the status in the Google Cloud Console
Expand Down