generated from cloudposse-terraform-components/template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
238 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
# Upstream changes from _extends are only recognized when modifications are made to this file in the default branch. | ||
_extends: .github | ||
repository: | ||
name: template | ||
description: Template for Terraform Components | ||
name: aws-managed-grafana-dashboard | ||
description: This component is responsible for provisioning a dashboard an Amazon Managed Grafana workspace | ||
homepage: https://cloudposse.com/accelerate | ||
topics: terraform, terraform-component | ||
|
||
|
||
|
||
|
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,70 +1,135 @@ | ||
name: "template" | ||
|
||
name: "aws-managed-grafana-dashboard" | ||
# Canonical GitHub repo | ||
github_repo: "cloudposse-terraform-components/template" | ||
|
||
github_repo: "cloudposse-terraform-components/aws-managed-grafana-dashboard" | ||
# Short description of this project | ||
description: |- | ||
Description of this component | ||
This component is responsible for provisioning a dashboard an Amazon Managed Grafana workspace. | ||
## Usage | ||
usage: |- | ||
**Stack Level**: Regional or Test47 | ||
**Stack Level**: Regional | ||
Here's an example snippet for how to use this component. | ||
```yaml | ||
components: | ||
terraform: | ||
foo: | ||
grafana/dashboard/prometheus: | ||
metadata: | ||
component: managed-grafana/dashboard | ||
vars: | ||
enabled: true | ||
name: "prometheus-dashboard" | ||
grafana_component_name: grafana | ||
grafana_api_key_component_name: grafana/api-key | ||
dashboard_url: "https://grafana.com/api/dashboards/315/revisions/3/download" | ||
config_input: | ||
"${DS_PROMETHEUS}": "acme-plat-ue2-sandbox-prometheus" # Input Value : Data source UID | ||
``` | ||
include: | ||
- "docs/terraform.md" | ||
<!-- prettier-ignore-start --> | ||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
tags: | ||
- terraform | ||
- terraform-modules | ||
- aws | ||
- components | ||
- terraform-components | ||
- root | ||
- geodesic | ||
- reference-implementation | ||
- reference-architecture | ||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 | | ||
| <a name="requirement_grafana"></a> [grafana](#requirement\_grafana) | >= 2.18.0 | | ||
| <a name="requirement_http"></a> [http](#requirement\_http) | >= 3.4.2 | | ||
## Providers | ||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 | | ||
| <a name="provider_grafana"></a> [grafana](#provider\_grafana) | >= 2.18.0 | | ||
| <a name="provider_http"></a> [http](#provider\_http) | >= 3.4.2 | | ||
## Modules | ||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_config_json"></a> [config\_json](#module\_config\_json) | cloudposse/config/yaml//modules/deepmerge | 1.0.2 | | ||
| <a name="module_grafana"></a> [grafana](#module\_grafana) | cloudposse/stack-config/yaml//modules/remote-state | 1.5.0 | | ||
| <a name="module_grafana_api_key"></a> [grafana\_api\_key](#module\_grafana\_api\_key) | cloudposse/stack-config/yaml//modules/remote-state | 1.5.0 | | ||
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a | | ||
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 | | ||
## Resources | ||
| Name | Type | | ||
|------|------| | ||
| [grafana_dashboard.this](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/dashboard) | resource | | ||
| [aws_ssm_parameter.grafana_api_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | | ||
| [http_http.grafana_dashboard_json](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source | | ||
## Inputs | ||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_additional_config"></a> [additional\_config](#input\_additional\_config) | Additional dashboard configuration to be merged with the provided dashboard JSON | `map(any)` | `{}` | no | | ||
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | | ||
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no | | ||
| <a name="input_config_input"></a> [config\_input](#input\_config\_input) | A map of string replacements used to supply input for the dashboard config JSON | `map(string)` | `{}` | no | | ||
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no | | ||
| <a name="input_dashboard_name"></a> [dashboard\_name](#input\_dashboard\_name) | The name to use for the dashboard. This must be unique. | `string` | n/a | yes | | ||
| <a name="input_dashboard_url"></a> [dashboard\_url](#input\_dashboard\_url) | The marketplace URL of the dashboard to be created | `string` | n/a | yes | | ||
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | | ||
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | | ||
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | ||
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | | ||
| <a name="input_grafana_api_key_component_name"></a> [grafana\_api\_key\_component\_name](#input\_grafana\_api\_key\_component\_name) | The name of the component used to provision an Amazon Managed Grafana API key | `string` | `"managed-grafana/api-key"` | no | | ||
| <a name="input_grafana_component_name"></a> [grafana\_component\_name](#input\_grafana\_component\_name) | The name of the component used to provision an Amazon Managed Grafana workspace | `string` | `"managed-grafana/workspace"` | no | | ||
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no | | ||
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no | | ||
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | | ||
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no | | ||
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no | | ||
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no | | ||
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | | ||
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | ||
| <a name="input_region"></a> [region](#input\_region) | AWS Region | `string` | n/a | yes | | ||
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | | ||
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | | ||
## Outputs | ||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
<!-- prettier-ignore-end --> | ||
## References | ||
- [cloudposse/terraform-aws-components](https://github.com/cloudposse/terraform-aws-components/tree/main/modules/managed-grafana/dashboard) - | ||
Cloud Posse's upstream component | ||
tags: | ||
- component/managed-grafana/dashboard | ||
- layer/grafana | ||
- provider/aws | ||
- provider/grafana | ||
# Categories of this project | ||
categories: | ||
- terraform-modules/root | ||
- terraform-components | ||
|
||
- component/managed-grafana/dashboard | ||
- layer/grafana | ||
- provider/aws | ||
- provider/grafana | ||
# License of this project | ||
license: "APACHE2" | ||
|
||
# Badges to display | ||
badges: | ||
- name: "Latest Release" | ||
image: "https://img.shields.io/github/release/cloudposse-terraform-components/template.svg?style=for-the-badge" | ||
url: "https://github.com/cloudposse-terraform-components/template/releases/latest" | ||
- name: "Slack Community" | ||
image: "https://slack.cloudposse.com/for-the-badge.svg" | ||
url: "https://slack.cloudposse.com" | ||
|
||
references: | ||
- name: "Cloud Posse Documentation" | ||
description: "Complete documentation for the Cloud Posse solution" | ||
url: "https://docs.cloudposse.com" | ||
- name: "Reference Architectures" | ||
description: "Launch effortlessly with our turnkey reference architectures, built either by your team or ours." | ||
url: "https://cloudposse.com/" | ||
|
||
- name: Latest Release | ||
image: https://img.shields.io/github/release/cloudposse-terraform-components/aws-managed-grafana-dashboard.svg?style=for-the-badge | ||
url: https://github.com/cloudposse-terraform-components/aws-managed-grafana-dashboard/releases/latest | ||
- name: Slack Community | ||
image: https://slack.cloudposse.com/for-the-badge.svg | ||
url: https://slack.cloudposse.com | ||
related: | ||
- name: "Cloud Posse Terraform Modules" | ||
description: Our collection of reusable Terraform modules used by our reference architectures. | ||
url: "https://docs.cloudposse.com/modules/" | ||
- name: "Atmos" | ||
description: "Atmos is like docker-compose but for your infrastructure" | ||
url: "https://atmos.tools" | ||
|
||
- name: "Cloud Posse Terraform Modules" | ||
description: Our collection of reusable Terraform modules used by our reference architectures. | ||
url: "https://docs.cloudposse.com/modules/" | ||
- name: "Atmos" | ||
description: "Atmos is like docker-compose but for your infrastructure" | ||
url: "https://atmos.tools" | ||
contributors: [] # If included generates contribs |
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,8 +1,35 @@ | ||
locals { | ||
enabled = module.this.enabled | ||
|
||
# Replace each of the keys in var.config_input with the given value in the module.config_json[0].merged result | ||
config_json = join("", [for k in keys(var.config_input) : replace(jsonencode(module.config_json[0].merged), k, var.config_input[k])]) | ||
} | ||
|
||
data "http" "grafana_dashboard_json" { | ||
count = local.enabled ? 1 : 0 | ||
|
||
url = var.dashboard_url | ||
} | ||
|
||
module "config_json" { | ||
source = "cloudposse/config/yaml//modules/deepmerge" | ||
version = "1.0.2" | ||
|
||
count = local.enabled ? 1 : 0 | ||
|
||
maps = [ | ||
jsondecode(data.http.grafana_dashboard_json[0].response_body), | ||
{ | ||
"title" : var.dashboard_name, | ||
"uid" : var.dashboard_name, | ||
"id" : var.dashboard_name | ||
}, | ||
var.additional_config | ||
] | ||
} | ||
|
||
resource "grafana_dashboard" "this" { | ||
count = local.enabled ? 1 : 0 | ||
|
||
config_json = local.config_json | ||
} |
This file was deleted.
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,38 @@ | ||
variable "grafana_component_name" { | ||
type = string | ||
description = "The name of the component used to provision an Amazon Managed Grafana workspace" | ||
default = "managed-grafana/workspace" | ||
} | ||
|
||
variable "grafana_api_key_component_name" { | ||
type = string | ||
description = "The name of the component used to provision an Amazon Managed Grafana API key" | ||
default = "managed-grafana/api-key" | ||
} | ||
|
||
module "grafana" { | ||
source = "cloudposse/stack-config/yaml//modules/remote-state" | ||
version = "1.5.0" | ||
|
||
component = var.grafana_component_name | ||
|
||
context = module.this.context | ||
} | ||
|
||
module "grafana_api_key" { | ||
source = "cloudposse/stack-config/yaml//modules/remote-state" | ||
version = "1.5.0" | ||
|
||
component = var.grafana_api_key_component_name | ||
|
||
context = module.this.context | ||
} | ||
|
||
data "aws_ssm_parameter" "grafana_api_key" { | ||
name = module.grafana_api_key.outputs.ssm_path_grafana_api_key | ||
} | ||
|
||
provider "grafana" { | ||
url = format("https://%s/", module.grafana.outputs.workspace_endpoint) | ||
auth = data.aws_ssm_parameter.grafana_api_key.value | ||
} |
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,19 @@ | ||
provider "aws" { | ||
region = var.region | ||
|
||
# Profile is deprecated in favor of terraform_role_arn. When profiles are not in use, terraform_profile_name is null. | ||
profile = module.iam_roles.terraform_profile_name | ||
|
||
dynamic "assume_role" { | ||
# module.iam_roles.terraform_role_arn may be null, in which case do not assume a role. | ||
for_each = compact([module.iam_roles.terraform_role_arn]) | ||
content { | ||
role_arn = assume_role.value | ||
} | ||
} | ||
} | ||
|
||
module "iam_roles" { | ||
source = "../../account-map/modules/iam-roles" | ||
context = module.this.context | ||
} |
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,26 @@ | ||
variable "region" { | ||
type = string | ||
description = "AWS Region" | ||
} | ||
|
||
variable "dashboard_name" { | ||
type = string | ||
description = "The name to use for the dashboard. This must be unique." | ||
} | ||
|
||
variable "dashboard_url" { | ||
type = string | ||
description = "The marketplace URL of the dashboard to be created" | ||
} | ||
|
||
variable "additional_config" { | ||
type = map(any) | ||
description = "Additional dashboard configuration to be merged with the provided dashboard JSON" | ||
default = {} | ||
} | ||
|
||
variable "config_input" { | ||
type = map(string) | ||
description = "A map of string replacements used to supply input for the dashboard config JSON" | ||
default = {} | ||
} |
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,5 +1,18 @@ | ||
terraform { | ||
required_version = ">= 1.0.0" | ||
|
||
required_providers {} | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 4.0" | ||
} | ||
grafana = { | ||
source = "grafana/grafana" | ||
version = ">= 2.18.0" | ||
} | ||
http = { | ||
source = "hashicorp/http" | ||
version = ">= 3.4.2" | ||
} | ||
} | ||
} |