Conversation
| { | ||
| stackSlug, | ||
| slug: 'grafana-amazonprometheus-datasource', | ||
| version: 'latest', |
There was a problem hiding this comment.
Should we make this configurable and use the latest as a default?
It seems convenient to have the ability to pinpoint a specific version.
| export namespace Grafana { | ||
| export type PrometheusConfig = { | ||
| prometheusEndpoint: pulumi.Input<string>; | ||
| region: pulumi.Input<string>; |
There was a problem hiding this comment.
Should region be optional and fallback to the current AWS region used by the stack?
| super('studion:grafana:Grafana', name, {}, opts); | ||
|
|
||
| if (args.prometheus) { | ||
| const ampRole = this.createAmpRole(name, args.tags); |
There was a problem hiding this comment.
Set ampRole on the instance, e.g. this.ampRole = ...
| if (!grafanaUrl) { | ||
| throw new Error('GRAFANA_URL environment variable is not set.'); | ||
| } |
There was a problem hiding this comment.
Stack config should be the first option, env is the fallback, e.g.
const config = new pulumi.Config('grafana');
const url = grafanaConfig.get('url') ?? process.env.GRAFANA_URL;
NOTE: This should apply to other props mentioned in PR description since they are provider options.
| import * as grafana from '@pulumiverse/grafana'; | ||
|
|
||
| // Fixed AWS account ID owned by Grafana Cloud, used to assume roles in customer accounts. | ||
| const GRAFANA_CLOUD_AWS_ACCOUNT_ID = '008923505280'; |
There was a problem hiding this comment.
I see this is exposed in GH, but the docs do not mention there is just one fixed account ID.
Remove the constant and make it a config option.
| super('studion:grafana:Grafana', name, {}, opts); | ||
|
|
||
| if (args.prometheus) { | ||
| const ampRole = this.createAmpRole(name, args.tags); |
There was a problem hiding this comment.
In the future we would have more data sources than just prometheus so I would recommend:
- renaming this iam role to more generic name (
grafanaIamRoleor something) - separating creating that iam role and
amprole policy to two methods - creating iam role outside this condition
- creating
amprole policy inside this condition (grouped with creating promtheus data source)
This PR introduces the Grafana builder and component. It's the first in a series of upcoming PRs.
Dashboard configuration will be covered in the next one.
To instantiate the Grafana component, the following env variables need to be set:
GRAFANA_URL,GRAFANA_AUTH,GRAFANA_CLOUD_ACCESS_POLICY_TOKEN.