|
| 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. |
0 commit comments