Skip to content

Commit caf75f2

Browse files
committed
feat(examples): grafana minimal
1 parent d2c19a5 commit caf75f2

File tree

5 files changed

+339
-0
lines changed

5 files changed

+339
-0
lines changed

examples/minimal/.header.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Grafana Minimal
2+
3+
Configuration in this directory creates:
4+
5+
- ECS Service in a pre-configured ECS Cluster to deploy Grafana tasks
6+
- ECS Task Definition to run Grafana container
7+
- Application Load Balancer to provide endpoint for accessing the Grafana dashboard, and
8+
- ACM certificate for a domain name to use with the Grafana ALB endpoint
9+
10+
## Example `tfvars` Configuration
11+
12+
```tf
13+
vpc_id = "vpc-06c3718eeee7ce034"
14+
cluster_name = "default-cluster"
15+
16+
# ECS Service
17+
service_subnet_ids = ["subnet-08a47aaf2e2328e38", "subnet-04017c6ce4c1adaa4"]
18+
19+
# ALB
20+
alb_subnet_ids = ["subnet-00e0e78571726e5c1", "subnet-00ec7b7882cfb78b1"]
21+
22+
# ACM
23+
acm_grafana_domain_name = "grafana.gaussb.io"
24+
acm_record_zone_id = "Z0105802SJKE46BQ70GU"
25+
26+
# RDS
27+
rds_db_subnet_group_subnet_ids = ["subnet-08a47aaf2e2328e38", "subnet-04017c6ce4c1adaa4"]
28+
```
29+
30+
## Usage
31+
32+
To run this example, you will need to execute the commands:
33+
34+
```bash
35+
terraform init
36+
terraform plan
37+
terraform apply
38+
```
39+
40+
Please note that this example may create resources that can incur monetary charges on your AWS bill. You can run `terraform destroy` when you no longer need the resources.

examples/minimal/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module "grafana" {
2+
source = "../../"
3+
4+
vpc_id = var.vpc_id
5+
cluster_name = var.cluster_name
6+
7+
# ECS Service
8+
service_subnet_ids = var.service_subnet_ids
9+
10+
# ALB
11+
alb_subnet_ids = var.alb_subnet_ids
12+
13+
# ACM
14+
acm_grafana_domain_name = var.acm_grafana_domain_name
15+
acm_record_zone_id = var.acm_record_zone_id
16+
17+
# RDS
18+
rds_db_subnet_group_subnet_ids = var.rds_db_subnet_group_subnet_ids
19+
}

examples/minimal/outputs.tf

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
################################################################################
2+
# Grafana ECS Deployment
3+
################################################################################
4+
5+
################################################################################
6+
# # ECS Service
7+
################################################################################
8+
9+
output "grafana_ecs_service_arn" {
10+
description = "ARN that identifies the Grafana ECS service."
11+
value = module.grafana.grafana_ecs_service_arn
12+
}
13+
14+
################################################################################
15+
# # ECS Task Definition
16+
################################################################################
17+
18+
output "grafana_ecs_task_definition_arn" {
19+
description = "Full ARN of the Grafana ECS Task Definition."
20+
value = module.grafana.grafana_ecs_task_definition_arn
21+
}
22+
23+
################################################################################
24+
# # Amazon Certificates Manager
25+
################################################################################
26+
27+
output "acm_certificate_id" {
28+
description = "Identifier of the ACM certificate for Grafana endpoint."
29+
value = module.grafana.acm_certificate_id
30+
}
31+
32+
output "acm_certificate_arn" {
33+
description = "ARN of the ACM certificate for Grafana endpoint."
34+
value = module.grafana.acm_certificate_arn
35+
}
36+
37+
output "acm_route53_record_id" {
38+
description = "Identifier of the Route53 Record for validation of the Grafana endpoint ACM certificate."
39+
value = module.grafana.acm_route53_record_id
40+
}
41+
42+
output "acm_certificate_validation_id" {
43+
description = "Identifier of the Grafana endpoint ACM certificate validation resource."
44+
value = module.grafana.acm_certificate_validation_id
45+
}
46+
47+
################################################################################
48+
# # Application Load Balancer
49+
################################################################################
50+
51+
output "alb_arn" {
52+
description = "ARN of the Grafana load balancer."
53+
value = module.grafana.alb_arn
54+
}
55+
56+
output "alb_dns_name" {
57+
description = "DNS name of the Grafana load balancer."
58+
value = module.grafana.alb_dns_name
59+
}
60+
61+
output "alb_zone_id" {
62+
description = "Canonical hosted zone ID of the Grafana Load Balancer."
63+
value = module.grafana.alb_zone_id
64+
}
65+
66+
output "alb_target_group_id" {
67+
description = "Identifier of the Target Group of Grafana services."
68+
value = module.grafana.alb_target_group_id
69+
}
70+
71+
output "alb_target_group_arn" {
72+
description = "ARN of the Target Group of Grafana services."
73+
value = module.grafana.alb_target_group_arn
74+
}
75+
76+
output "alb_listener_id" {
77+
description = "Identifier of the Listener for Grafana services."
78+
value = module.grafana.alb_listener_id
79+
}
80+
81+
output "alb_listener_arn" {
82+
description = "ARN of the Listener for Grafana services."
83+
value = module.grafana.alb_listener_arn
84+
}
85+
86+
################################################################################
87+
# # S3 Bucket
88+
################################################################################
89+
90+
output "s3_bucket_id" {
91+
description = "Name of the bucket where the Grafana ALB logs will be stored."
92+
value = module.grafana.s3_bucket_id
93+
}
94+
95+
output "s3_bucket_arn" {
96+
description = "ARN of the bucket where the Grafana ALB logs will be stored."
97+
value = module.grafana.s3_bucket_arn
98+
}
99+
100+
################################################################################
101+
# IAM Role Sub-module
102+
################################################################################
103+
104+
output "grafana_task_iam_role_id" {
105+
description = "Name of the Grafana Task IAM role."
106+
value = module.grafana.grafana_task_iam_role_id
107+
}
108+
109+
output "grafana_task_iam_role_arn" {
110+
description = "Amazon Resource Name (ARN) specifying the Grafana Task IAM role."
111+
value = module.grafana.grafana_task_iam_role_arn
112+
}
113+
114+
output "grafana_task_iam_role_policies_ids" {
115+
description = "Map of IAM Policies Identifiers created and attached with the Grafana Task IAM role."
116+
value = module.grafana.grafana_task_iam_role_policies_ids
117+
}
118+
119+
output "grafana_task_iam_role_policies_arns" {
120+
description = "Map of IAM Policies ARNs created and attached with the Grafana Task IAM role."
121+
value = module.grafana.grafana_task_iam_role_policies_arns
122+
}
123+
124+
output "grafana_execution_iam_role_id" {
125+
description = "Name of the Grafana Execution IAM role."
126+
value = module.grafana.grafana_execution_iam_role_id
127+
}
128+
129+
output "grafana_execution_iam_role_arn" {
130+
description = "Amazon Resource Name (ARN) specifying the Grafana Execution IAM role."
131+
value = module.grafana.grafana_execution_iam_role_arn
132+
}
133+
134+
output "grafana_execution_iam_role_policies_ids" {
135+
description = "Map of IAM Policies Identifiers created and attached with the Grafana Execution IAM role."
136+
value = module.grafana.grafana_execution_iam_role_policies_ids
137+
}
138+
139+
output "grafana_execution_iam_role_policies_arns" {
140+
description = "Map of IAM Policies ARNs created and attached with the Grafana Execution IAM role."
141+
value = module.grafana.grafana_execution_iam_role_policies_arns
142+
}
143+
144+
################################################################################
145+
# RDS Sub-module
146+
################################################################################
147+
148+
output "rds_id" {
149+
description = "Grafana RDS DBI resource ID."
150+
value = module.grafana.rds_id
151+
}
152+
153+
output "rds_arn" {
154+
description = "The ARN of the Grafana RDS instance."
155+
value = module.grafana.rds_arn
156+
}
157+
158+
output "rds_endpoint" {
159+
description = "The Grafana RDS connection endpoint in `address:port` format."
160+
value = module.grafana.rds_endpoint
161+
}
162+
163+
output "rds_master_user_secret" {
164+
description = "Details of the secret containing the database master password for Grafana RDS."
165+
value = module.grafana.rds_master_user_secret
166+
}
167+
168+
output "rds_db_subnet_group_id" {
169+
description = "The db subnet group name to use with the Grafana RDS."
170+
value = module.grafana.rds_db_subnet_group_id
171+
}
172+
173+
output "rds_db_subnet_group_arn" {
174+
description = "The ARN of the db subnet group attached with Grafana RDS."
175+
value = module.grafana.rds_db_subnet_group_arn
176+
}
177+
178+
output "rds_db_parameter_group_id" {
179+
description = "The db parameter group name to use with the Grafana RDS."
180+
value = module.grafana.rds_db_parameter_group_id
181+
}
182+
183+
output "rds_db_parameter_group_arn" {
184+
description = "The ARN of the db parameter group attached with Grafana RDS."
185+
value = module.grafana.rds_db_parameter_group_arn
186+
}
187+
188+
################################################################################
189+
# Security Groups
190+
################################################################################
191+
192+
output "ecs_service_security_group_id" {
193+
description = "Identifier of the Grafana ECS Service Security Group."
194+
value = module.grafana.ecs_service_security_group_id
195+
}
196+
197+
output "ecs_service_security_group_arn" {
198+
description = "ARN of the Grafana ECS Service Security Group."
199+
value = module.grafana.ecs_service_security_group_arn
200+
}
201+
202+
output "grafana_alb_security_group_id" {
203+
description = "Identifier of the Grafana ALB Security Group."
204+
value = module.grafana.grafana_alb_security_group_id
205+
}
206+
207+
output "grafana_alb_security_group_arn" {
208+
description = "ARN of the Grafana ALB Security Group."
209+
value = module.grafana.grafana_alb_security_group_arn
210+
}
211+
212+
output "grafana_backend_rds_security_group_id" {
213+
description = "Identifier of the Grafana Backend RDS Security Group."
214+
value = module.grafana.grafana_backend_rds_security_group_id
215+
}
216+
217+
output "grafana_backend_rds_security_group_arn" {
218+
description = "ARN of the Grafana Backend RDS Security Group."
219+
value = module.grafana.grafana_backend_rds_security_group_arn
220+
}

examples/minimal/variables.tf

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
variable "vpc_id" {
2+
description = "The ID of the VPC."
3+
type = string
4+
nullable = false
5+
}
6+
7+
variable "cluster_name" {
8+
description = "Name of the cluster."
9+
type = string
10+
nullable = false
11+
}
12+
13+
################################################################################
14+
# ECS Service
15+
################################################################################
16+
17+
variable "service_subnet_ids" {
18+
description = "List of VPC subnet IDs where the infrastructure will be configured."
19+
type = list(string)
20+
nullable = false
21+
}
22+
23+
################################################################################
24+
# Application Load Balancer
25+
################################################################################
26+
27+
variable "alb_subnet_ids" {
28+
description = "List of public VPC subnet IDs where the Application Load Balancer will be configured."
29+
type = list(string)
30+
nullable = false
31+
}
32+
33+
################################################################################
34+
# ACM
35+
################################################################################
36+
37+
variable "acm_grafana_domain_name" {
38+
description = "Grafana domain name for which the certificate should be issued."
39+
type = string
40+
nullable = false
41+
}
42+
43+
variable "acm_record_zone_id" {
44+
description = "Canonical hosted zone ID of the Load Balancer."
45+
type = string
46+
nullable = false
47+
}
48+
49+
################################################################################
50+
# RDS Sub-module
51+
################################################################################
52+
53+
variable "rds_db_subnet_group_subnet_ids" {
54+
description = "A list of VPC subnet IDs."
55+
type = list(string)
56+
nullable = false
57+
}

examples/minimal/versions.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 1.8.4"
3+
}

0 commit comments

Comments
 (0)