Skip to content

Commit

Permalink
Update config to support multiple clients
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Jan 31, 2024
1 parent 8206e5c commit 9bfd394
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 2,658 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ crash.log
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
*.tfplan

main_override.tf
36 changes: 26 additions & 10 deletions bootstrap/aws.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# terraform init
# export AWS_ACCESS_KEY_ID=
# export AWS_SECRET_ACCESS_KEY=
# export TF_VAR_name=
# terraform apply

terraform {
Expand All @@ -17,22 +18,37 @@ provider "aws" {
region = "us-east-1"
}

variable "name" {
description = "The name to use for S3 bucket, DynamoDB table and IAM users."
type = string
}

resource "aws_s3_bucket" "this" {
bucket = "tf-aws-gh-observability"
bucket = var.name

tags = {
Name = "Terraform AWS GitHub Observability"
Url = "https://github.com/pl-strflt/tf-aws-gh-observability"
Name = "GitHub Monitoring Dashboard"
Url = "https://github.com/ipdxco/github-monitoring-dashboard"
}
}

resource "aws_s3_bucket_ownership_controls" "this" {
bucket = aws_s3_bucket.this.id

rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_acl" "this" {
depends_on = [ aws_s3_bucket_ownership_controls.this ]

bucket = aws_s3_bucket.this.id
acl = "private"
}

resource "aws_dynamodb_table" "this" {
name = "tf-aws-gh-observability"
name = var.name
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"

Expand All @@ -42,17 +58,17 @@ resource "aws_dynamodb_table" "this" {
}

tags = {
Name = "Terraform AWS GitHub Observability"
Url = "https://github.com/pl-strflt/tf-aws-gh-observability"
Name = "GitHub Monitoring Dashboard"
Url = "https://github.com/ipdxco/github-monitoring-dashboard"
}
}

resource "aws_iam_user" "this" {
name = "tf-aws-gh-observability"
name = var.name

tags = {
Name = "Terraform AWS GitHub Observability"
Url = "https://github.com/pl-strflt/tf-aws-gh-observability"
Name = "GitHub Monitoring Dashboard"
Url = "https://github.com/ipdxco/github-monitoring-dashboard"
}
}

Expand All @@ -76,7 +92,7 @@ data "aws_iam_policy_document" "this" {
}

resource "aws_iam_user_policy" "this" {
name = "tf-aws-gh-observability"
name = var.name
user = "${aws_iam_user.this.name}"

policy = "${data.aws_iam_policy_document.this.json}"
Expand Down
4 changes: 2 additions & 2 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ resource "aws_iam_user" "cloud-watcher" {
name = "cloud-watcher"

tags = {
Name = "Terraform AWS GitHub Observability"
Url = "https://github.com/pl-strflt/tf-aws-gh-observability"
Name = "GitHub Monitoring Dashboard"
Url = "https://github.com/ipdxco/github-monitoring-dashboard"
}
}

Expand Down
12 changes: 6 additions & 6 deletions lambdas.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_apigatewayv2_api" "webhook" {
name = "gateway-tf-aws-gh-observability"
name = "gateway-github-monitoring-dashboard"
protocol_type = "HTTP"
tags = local.tags
}
Expand Down Expand Up @@ -51,7 +51,7 @@ resource "aws_apigatewayv2_integration" "webhook" {
resource "aws_lambda_function" "webhook" {
filename = "${path.module}/lambdas/webhook/webhook.zip"
source_code_hash = filebase64sha256("${path.module}/lambdas/webhook/webhook.zip")
function_name = "webhook-tf-aws-gh-observability"
function_name = "webhook-github-monitoring-dashboard"
role = aws_iam_role.webhook_lambda.arn
handler = "index.githubWebhook"
runtime = "nodejs16.x"
Expand Down Expand Up @@ -95,14 +95,14 @@ data "aws_iam_policy_document" "lambda_assume_role_policy" {
}

resource "aws_iam_role" "webhook_lambda" {
name = "role-tf-aws-gh-observability"
name = "role-github-monitoring-dashboard"
assume_role_policy = data.aws_iam_policy_document.lambda_assume_role_policy.json
path = "/tf-aws-gh-observability/"
path = "/github-monitoring-dashboard/"
tags = local.tags
}

resource "aws_iam_role_policy" "webhook_logging" {
name = "logging-policy-tf-aws-gh-observability"
name = "logging-policy-github-monitoring-dashboard"
role = aws_iam_role.webhook_lambda.name
policy = jsonencode({
Version = "2012-10-17"
Expand All @@ -120,7 +120,7 @@ resource "aws_iam_role_policy" "webhook_logging" {
}

resource "aws_iam_role_policy" "webhook_ssm" {
name = "ssm-policy-tf-aws-gh-observability"
name = "ssm-policy-github-monitoring-dashboard"
role = aws_iam_role.webhook_lambda.name

policy = jsonencode({
Expand Down
2 changes: 2 additions & 0 deletions lambdas/webhook/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ build/
*.zip

npm-debug.log*

coverage/
117 changes: 0 additions & 117 deletions lambdas/webhook/coverage/clover.xml

This file was deleted.

Loading

0 comments on commit 9bfd394

Please sign in to comment.