-
Notifications
You must be signed in to change notification settings - Fork 240
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 PDC network and PDC network token resources #1975
Conversation
- Add resource lister function that will return a slice of resources
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good! Thanks a lot for starting it off. I've added some comments around the naming of things for now. We need a more thorough review of the terraform itself, we can get to that soon.
examples/resources/grafana_cloud_private_datasource_connect/resource.tf
Outdated
Show resolved
Hide resolved
examples/resources/grafana_cloud_private_datasource_connect/resource.tf
Outdated
Show resolved
Hide resolved
examples/resources/grafana_cloud_private_datasource_connect/resource.tf
Outdated
Show resolved
Hide resolved
internal/resources/cloud/resource_private_datasource_connect.go
Outdated
Show resolved
Hide resolved
internal/resources/cloud/resource_private_datasource_connect.go
Outdated
Show resolved
Hide resolved
- Tidy up property names
Updated based on your suggestions @dafydd-t. I've also added a data source to allow retrieval of networks that may not be managed by TF. |
docs/data-sources/cloud_private_data_source_connect_networks.md
Outdated
Show resolved
Hide resolved
docs/data-sources/cloud_private_data_source_connect_networks.md
Outdated
Show resolved
Hide resolved
internal/resources/cloud/data_source_private_data_source_connect_network.go
Outdated
Show resolved
Hide resolved
@aangelisc do you have an example terraform plan that you used to run this locally? I'd love to give it a go |
Hey @dafydd-t, I've pushed some more updates 😊 You should be able to test this with the following tf: terraform {
required_providers {
grafana = {
source = "grafana/grafana"
}
}
}
provider "grafana" {
alias = "cloud"
cloud_access_policy_token = "<token>"
}
data "grafana_cloud_stack" "stack" {
provider = grafana.cloud
slug = "stack"
}
resource "grafana_cloud_stack_service_account" "cloud_sa" {
provider = grafana.cloud
stack_slug = data.grafana_cloud_stack.stack.slug
name = "pdc-test-sa"
role = "Admin"
is_disabled = false
}
resource "grafana_cloud_stack_service_account_token" "cloud_sa" {
provider = grafana.cloud
stack_slug = data.grafana_cloud_stack.stack.slug
name = "terraform serviceaccount key"
service_account_id = grafana_cloud_stack_service_account.cloud_sa.id
}
provider "grafana" {
alias = "stack"
url = data.grafana_cloud_stack.stack.url
auth = grafana_cloud_stack_service_account_token.cloud_sa.key
cloud_access_policy_token = "<token>"
}
resource "grafana_cloud_private_data_source_connect_network" "test" {
provider = grafana.stack
region = data.grafana_cloud_stack.stack.region_slug
name = "test-pdc"
display_name = "Test PDC"
stack_identifier = data.grafana_cloud_stack.stack.id
}
resource "grafana_cloud_private_data_source_connect_network_token" "test" {
provider = grafana.stack
pdc_network_id = grafana_cloud_private_data_source_connect_network.test.pdc_network_id
region = grafana_cloud_private_data_source_connect_network.test.region
name = "my-pdc-token"
display_name = "My PDC Token"
}
resource "grafana_data_source" "influxdb" {
provider = grafana.stack
type = "influxdb"
name = "pdc-test-influx"
url = "http://influxdb.example.net:8086/"
basic_auth_enabled = true
basic_auth_username = "username"
database_name = "dbname" // Example: influxdb_database.metrics.name
json_data_encoded = jsonencode({
authType = "default"
basicAuthPassword = "mypassword"
})
private_data_source_connect_network_id = grafana_cloud_private_data_source_connect_network.test.pdc_network_id
}
|
Thanks - I tried this myself to create a cloud stack, PDC network and some tokens and it works a treat! One behaviour i don't understand is when I run
Why are these properties in the datasource getting deleted? But also, when i apply it and go check the datasource, it still looks configured correctly :/ Apart from that, from a PDC perspective this looks good! I've asked again in #platform for a terraform focused review. |
I've fixed this! It's because the data source |
That issue looks fixed! Thanks. I'm still seeing one unexpected behaviour. I've got three tokens in my sample terraform, and running
I think once we've fixed this one we're good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks like good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Feedback welcome here (my first time creating some TF resources), this is essentially a duplicate of the access policy and token resources with some minor changes that are specific to PDC.
Fixes #1222
Fixes #1638
Fixes https://github.com/grafana/hosted-grafana/issues/4278