Skip to content

Commit 5cef900

Browse files
committed
feat(examples): grafana complete example
1 parent ee53887 commit 5cef900

File tree

5 files changed

+779
-0
lines changed

5 files changed

+779
-0
lines changed

examples/complete/.header.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Grafana Complete
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_name = "grafana"
18+
service_subnet_ids = ["subnet-08a47aaf2e2328e38", "subnet-04017c6ce4c1adaa4"]
19+
service_desired_count = 3
20+
service_tags = {}
21+
22+
# ECS Task Definition
23+
task_definition_family = "grafana"
24+
task_definition_grafana_image_version = "11.1.2"
25+
task_definition_tags = {}
26+
27+
# ALB
28+
alb_name = "grafana-alb"
29+
alb_subnet_ids = ["subnet-00e0e78571726e5c1", "subnet-00ec7b7882cfb78b1"]
30+
alb_tags = {}
31+
alb_target_group_name = "grafana-services"
32+
alb_target_group_tags = {}
33+
alb_listener_tags = {}
34+
35+
# S3 Bucket
36+
s3_bucket_name = "grafana-services-alb-logs"
37+
s3_bucket_tags = {}
38+
39+
# ACM
40+
acm_grafana_domain_name = "grafana.gaussb.io"
41+
acm_record_zone_id = "Z0105802SJKE46BQ70GU"
42+
acm_certificate_tags = {}
43+
44+
# Grafana Task IAM Role
45+
grafana_task_role_name = "grafana-task-iam-role"
46+
grafana_task_role_description = "Managed By Terraform"
47+
grafana_task_role_policies = {
48+
rds = {
49+
name = "grafana-task-iam-role-rds"
50+
description = "Allow access to RDS"
51+
policy = {
52+
Statement = [
53+
{
54+
Sid = "AllowRDSFullAccess"
55+
Effect = "Allow"
56+
Resource = "*"
57+
Action = ["rds:*"]
58+
}
59+
]
60+
}
61+
}
62+
athena = {
63+
name = "grafana-task-iam-role-athena"
64+
description = "Allow access to Athena"
65+
policy = {
66+
Statement = [
67+
{
68+
Sid = "AllowAthenaFullAccess"
69+
Effect = "Allow"
70+
Resource = "*"
71+
Action = ["athena:*"]
72+
},
73+
{
74+
Sid = "AllowGlueFullAccess"
75+
Effect = "Allow"
76+
Action = [
77+
"glue:CreateDatabase",
78+
"glue:DeleteDatabase",
79+
"glue:GetDatabase",
80+
"glue:GetDatabases",
81+
"glue:UpdateDatabase",
82+
"glue:CreateTable",
83+
"glue:DeleteTable",
84+
"glue:BatchDeleteTable",
85+
"glue:UpdateTable",
86+
"glue:GetTable",
87+
"glue:GetTables",
88+
"glue:BatchCreatePartition",
89+
"glue:CreatePartition",
90+
"glue:DeletePartition",
91+
"glue:BatchDeletePartition",
92+
"glue:UpdatePartition",
93+
"glue:GetPartition",
94+
"glue:GetPartitions",
95+
"glue:BatchGetPartition",
96+
"glue:StartColumnStatisticsTaskRun",
97+
"glue:GetColumnStatisticsTaskRun",
98+
"glue:GetColumnStatisticsTaskRuns",
99+
"glue:GetCatalogImportStatus"
100+
]
101+
Resource = "*"
102+
}
103+
]
104+
}
105+
}
106+
}
107+
grafana_task_role_tags = {}
108+
109+
# Grafana Task Execution IAM Role
110+
grafana_execution_role_name = "grafana-task-execution-iam-role"
111+
grafana_execution_role_description = "Managed By Terraform"
112+
grafana_execution_role_policies = {
113+
secrets-manager = {
114+
name = "grafana-execution-role-secrets-manager"
115+
description = "Allow access to Secrets Manager"
116+
policy = {
117+
Statement = [
118+
{
119+
Sid = "AllowSecretsManagerFullAccess"
120+
Effect = "Allow"
121+
Resource = "*"
122+
Action = ["secretsmanager:*"]
123+
}
124+
]
125+
}
126+
}
127+
}
128+
grafana_execution_role_tags = {}
129+
130+
# RDS
131+
rds_identifier = "grafana-backend"
132+
rds_instance_class = "db.t3.micro"
133+
rds_allocated_storage = 10
134+
rds_postgres_engine_version = "16.3"
135+
rds_username = "grafana_admin"
136+
rds_tags = {}
137+
rds_db_subnet_group_name = "grafana-rds-subnet-group"
138+
rds_db_subnet_group_description = "Managed By Terraform"
139+
rds_db_subnet_group_subnet_ids = ["subnet-08a47aaf2e2328e38", "subnet-04017c6ce4c1adaa4"]
140+
rds_db_subnet_group_tags = {}
141+
rds_db_parameter_group_name = "grafana-rds-parameter-group"
142+
rds_db_parameter_group_description = "Managed By Terraform"
143+
rds_db_parameter_group_family = "postgres16"
144+
rds_db_parameter_group_parameters = [
145+
{
146+
name = "rds.force_ssl"
147+
value = "0"
148+
apply_method = "immediate"
149+
}
150+
]
151+
rds_db_parameter_group_tags = {}
152+
```
153+
154+
## Usage
155+
156+
To run this example, you will need to execute the commands:
157+
158+
```bash
159+
terraform init
160+
terraform plan
161+
terraform apply
162+
```
163+
164+
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/complete/main.tf

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module "grafana" {
2+
source = "../../"
3+
4+
vpc_id = var.vpc_id
5+
cluster_name = var.cluster_name
6+
7+
# ECS Service
8+
service_name = var.service_name
9+
service_subnet_ids = var.service_subnet_ids
10+
service_desired_count = var.service_desired_count
11+
service_tags = var.service_tags
12+
13+
# ECS Task Definition
14+
task_definition_family = var.task_definition_family
15+
task_definition_grafana_image_version = var.task_definition_grafana_image_version
16+
task_definition_tags = var.task_definition_tags
17+
18+
# ALB
19+
alb_name = var.alb_name
20+
alb_subnet_ids = var.alb_subnet_ids
21+
alb_tags = var.alb_tags
22+
# # Target Group
23+
alb_target_group_name = var.alb_target_group_name
24+
alb_target_group_tags = var.alb_target_group_tags
25+
# # Listener
26+
alb_listener_tags = var.alb_listener_tags
27+
28+
# S3 Bucket
29+
s3_bucket_name = var.s3_bucket_name
30+
s3_bucket_tags = var.s3_bucket_tags
31+
32+
# ACM
33+
acm_grafana_domain_name = var.acm_grafana_domain_name
34+
acm_record_zone_id = var.acm_record_zone_id
35+
acm_certificate_tags = var.acm_certificate_tags
36+
37+
# Task IAM Role
38+
grafana_task_role_name = var.grafana_task_role_name
39+
grafana_task_role_description = var.grafana_task_role_description
40+
grafana_task_role_policies = var.grafana_task_role_policies
41+
grafana_task_role_tags = var.grafana_task_role_tags
42+
43+
# Task Execution IAM Role
44+
grafana_execution_role_name = var.grafana_execution_role_name
45+
grafana_execution_role_description = var.grafana_execution_role_description
46+
grafana_execution_role_policies = var.grafana_execution_role_policies
47+
grafana_execution_role_tags = var.grafana_execution_role_tags
48+
49+
# RDS
50+
rds_identifier = var.rds_identifier
51+
rds_instance_class = var.rds_instance_class
52+
rds_allocated_storage = var.rds_allocated_storage
53+
rds_postgres_engine_version = var.rds_postgres_engine_version
54+
rds_username = var.rds_username
55+
rds_tags = var.rds_tags
56+
# # DB Subnet Group
57+
rds_db_subnet_group_name = var.rds_db_subnet_group_name
58+
rds_db_subnet_group_description = var.rds_db_subnet_group_description
59+
rds_db_subnet_group_subnet_ids = var.rds_db_subnet_group_subnet_ids
60+
rds_db_subnet_group_tags = var.rds_db_subnet_group_tags
61+
# # DB Parameter Group
62+
rds_db_parameter_group_name = var.rds_db_parameter_group_name
63+
rds_db_parameter_group_description = var.rds_db_parameter_group_description
64+
rds_db_parameter_group_family = var.rds_db_parameter_group_family
65+
rds_db_parameter_group_parameters = var.rds_db_parameter_group_parameters
66+
rds_db_parameter_group_tags = var.rds_db_parameter_group_tags
67+
}

0 commit comments

Comments
 (0)