Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 40 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
# 1. Deploy an S3 storage bucket
# 1. Deploy an S3 storage bucket
resource "aws_s3_bucket" "grafana_bucket" {
bucket = "grafana-storage-bucket"
tags = {
Name = "GrafanaStorage"
Environment = "Production"
}
}

# 2. Configure bucket policy to allow Grafana IAM role to use storage

data "aws_iam_policy_document" "grafana_policy_document" {
statement {
sid = "AllowListBucket"
actions = ["s3:ListBucket"]
resources = [aws_s3_bucket.grafana_bucket.arn]

principals {
type = "AWS"
identifiers = ["arn:aws:iam::069874459391:role/t2_micro-role"]
}
}

statement {
sid = "AllowGetPutObjects"
actions = ["s3:GetObject", "s3:PutObject"]
resources = ["${aws_s3_bucket.grafana_bucket.arn}/*"]

principals {
type = "AWS"
identifiers = ["arn:aws:iam::069874459391:role/t2_micro-role"]
}
}
}

resource "aws_s3_bucket_policy" "grafana_bucket_policy" {
bucket = aws_s3_bucket.grafana_bucket.id
policy = data.aws_iam_policy_document.grafana_policy_document.json
}
# 1. Deploy an S3 storage bucket

# 2. Confugure bucket policy to allow grafana iam role to use storage
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "bucket_name" {
value = aws_s3_bucket.grafana_backups.bucket
value = aws_s3_bucket.grafana_bucket
sensitive = false
}
4 changes: 3 additions & 1 deletion providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ terraform {
}
}

provider "aws" {}
provider "aws" {
region = "us-east-1"
}
2 changes: 1 addition & 1 deletion terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
grafana_iam_role_arn = ""
grafana_iam_role_arn = "arn:aws:iam::069874459391:role/t2_micro-role"
1 change: 1 addition & 0 deletions tfplan.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.