Skip to content

Commit

Permalink
feat: pagerduty_service_integration_email to alert upon inbound email.
Browse files Browse the repository at this point in the history
This is requried by teams to automatically trigger alerts upon receiving specific emails to specific email
addresses.
  • Loading branch information
bhargavms committed Jan 9, 2024
1 parent 4ea03cc commit fcb7d23
Show file tree
Hide file tree
Showing 31 changed files with 607 additions and 52 deletions.
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Get the latest version from: https://github.com/pre-commit/pre-commit-hooks/releases
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: detect-aws-credentials
args: ["--allow-missing-credentials"]
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.1 # Get the latest version from: https://github.com/antonbabenko/pre-commit-terraform/releases
hooks:
- id: terraform_fmt
- id: terraform_docs
- id: terraform_validate
- id: terraform_tfsec
- id: terraform_checkov
- repo: local
hooks:
- id: docs
name: docs
entry: make
args: [ 'docs' ]
language: system
- repo: https://github.com/gitguardian/ggshield
rev: v1.14.4
hooks:
- id: ggshield
language: python
stages: [commit]
args: [ 'secret', 'scan', 'pre-commit' ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Get the latest version from: https://github.com/pre-commit/pre-commit-hooks/releases
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ docs:
cd examples/pagerduty-escalation-policy/; terraform-docs markdown . --output-file README.md --output-mode inject
cd examples/honest-two-level-schedule/; terraform-docs markdown . --output-file README.md --output-mode inject
cd examples/pagerduty-service/; terraform-docs markdown . --output-file README.md --output-mode inject
cd examples/pagerduty-service-integrations-email/; terraform-docs markdown . --output-file README.md --output-mode inject

clean:
rm -rf examples/*/terraform.tfstate examples/*/terraform.tfstate.backup examples/*/.test-data
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,34 @@ No resources.

## Outputs

No outputs.
<!-- END_TF_DOCS -->- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_pagerduty"></a> [pagerduty](#requirement\_pagerduty) | >= 2.7 |

## Providers

No providers.

## Modules

No modules.

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_pagerduty_token"></a> [pagerduty\_token](#input\_pagerduty\_token) | PagerDuty API token. | `string` | n/a | yes |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
8 changes: 6 additions & 2 deletions examples/honest-two-level-schedule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | n/a |

## Modules

Expand All @@ -27,7 +29,9 @@ No providers.

## Resources

No resources.
| Name | Type |
|------|------|
| [random_id.random_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |

## Inputs

Expand Down
20 changes: 14 additions & 6 deletions examples/honest-two-level-schedule/main.tf
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
resource "random_id" "random_suffix" {
byte_length = 10
}

locals {
random_string = random_id.random_suffix.b64_url
}

module "dummy_users" {
count = var.dummy_user_count

source = "../../modules/pagerduty-user"
name = "pagerduty-schedule-example-user-${count.index}"
email_address = "pagerduty-schedule-example-user-${count.index}@honestbank.com"
name = "pagerduty-schedule-example-user-${count.index}-${local.random_string}"
email_address = "pagerduty-schedule-example-user-${count.index}-${local.random_string}@honestbank.com"
}

module "dummy_team" {
source = "../../modules/pagerduty-team"

name = var.team_name
description = "${var.name} - this is an example description"
name = "${var.team_name}-${local.random_string}"
description = "${var.name}-${local.random_string} - this is an example description"
}

module "schedule" {
source = "../../modules/honest-two-level-schedule"

name = "Example - ${var.name}"
description = "${var.name} - this is an example description"
name = "Example-${var.name}-${local.random_string}"
description = "${var.name} - ${local.random_string} - this is an example description"

# 604,800 seconds = 1 week (7 days)
# 86,400 seconds = 1 day
Expand Down
12 changes: 10 additions & 2 deletions examples/pagerduty-business-service/main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
resource "random_id" "random_suffix" {
byte_length = 10
}

locals {
random_string = random_id.random_suffix.b64_url
}

module "mock_team" {
source = "../../modules/pagerduty-team"

name = "team - ${var.name}"
name = "team - ${var.name} - ${local.random_string}"
description = "Created by terratest"
}


module "pagerduty_business_service" {
source = "../../modules/pagerduty-business-service"

name = var.name
name = "${var.name}-${local.random_string}"
description = var.description
point_of_contact = var.point_of_contact
owner_team_id = module.mock_team.id
Expand Down
8 changes: 6 additions & 2 deletions examples/pagerduty-escalation-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ This example creates a 3-level escalation policy - an example screenshot is prov

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | n/a |

## Modules

Expand All @@ -34,7 +36,9 @@ No providers.

## Resources

No resources.
| Name | Type |
|------|------|
| [random_id.random_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |

## Inputs

Expand Down
42 changes: 25 additions & 17 deletions examples/pagerduty-escalation-policy/main.tf
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
resource "random_id" "random_suffix" {
byte_length = 10
}

locals {
random_string = random_id.random_suffix.b64_url
}

module "engineering_user_one" {
source = "../../modules/pagerduty-user"
name = "pagerduty-escalation-policy-example-engineering-user-one"
email_address = "pagerduty-escalation-policy-example-engineering-user-one@honestbank.com"
name = "engineering-user-one-${local.random_string}"
email_address = "engineering-user-one-${local.random_string}@honestbank.com"
}

module "engineering_user_two" {
source = "../../modules/pagerduty-user"
name = "pagerduty-escalation-policy-example-engineering-user-two"
email_address = "pagerduty-escalation-policy-example-engineering-user-two@honestbank.com"
name = "example-engineering-user-two-${local.random_string}"
email_address = "example-engineering-user-two-${local.random_string}@honestbank.com"
}

module "engineering_lead" {
source = "../../modules/pagerduty-user"
name = "pagerduty-escalation-policy-example-engineering-lead"
email_address = "pagerduty-escalation-policy-example-engineering-lead@honestbank.com"
name = "example-engineering-lead-${local.random_string}"
email_address = "example-engineering-lead-${local.random_string}@honestbank.com"
}

module "product_manager" {
source = "../../modules/pagerduty-user"
name = "pagerduty-escalation-policy-example-product-manager"
email_address = "pagerduty-escalation-policy-example-product-manager@honestbank.com"
name = "example-product-manager-${local.random_string}"
email_address = "example-product-manager-${local.random_string}@honestbank.com"
}

module "product_lead" {
source = "../../modules/pagerduty-user"
name = "pagerduty-escalation-policy-example-product-lead"
email_address = "pagerduty-escalation-policy-example-product-lead@honestbank.com"
name = "example-product-lead-${local.random_string}"
email_address = "example-product-lead-${local.random_string}@honestbank.com"
}

module "level_one_engineering_schedule" {
source = "../../modules/pagerduty-schedule"

description = "level one engineering schedule"
name = "level one engineering schedule - ${var.schedule_suffix}"
name = "level one engineering schedule-${var.schedule_suffix}-${local.random_string}"

# 604,800 seconds = 1 week (7 days)
rotation_turn_length_seconds = 604800
Expand All @@ -51,7 +59,7 @@ module "level_two_engineering_schedule" {
source = "../../modules/pagerduty-schedule"

description = "level two engineering schedule"
name = "level two engineering schedule - ${var.schedule_suffix}"
name = "level two engineering schedule-${var.schedule_suffix}-${local.random_string}"

# 604,800 seconds = 1 week (7 days)
rotation_turn_length_seconds = 604800
Expand All @@ -70,7 +78,7 @@ module "level_two_product_schedule" {
source = "../../modules/pagerduty-schedule"

description = "level two product schedule"
name = "level two product schedule - ${var.schedule_suffix}"
name = "level two product schedule-${var.schedule_suffix}-${local.random_string}"

# 604,800 seconds = 1 week (7 days)
rotation_turn_length_seconds = 604800
Expand All @@ -86,7 +94,7 @@ module "level_three_engineering_schedule" {
source = "../../modules/pagerduty-schedule"

description = "level three engineering schedule"
name = "level three engineering schedule - ${var.schedule_suffix}"
name = "level three engineering schedule-${var.schedule_suffix}-${local.random_string}"

# 604,800 seconds = 1 week (7 days)
rotation_turn_length_seconds = 604800
Expand All @@ -102,7 +110,7 @@ module "level_three_product_schedule" {
source = "../../modules/pagerduty-schedule"

description = "level three product schedule"
name = "level three product schedule - ${var.schedule_suffix}"
name = "level three product schedule-${var.schedule_suffix}-${local.random_string}"

# 604,800 seconds = 1 week (7 days)
rotation_turn_length_seconds = 604800
Expand All @@ -116,14 +124,14 @@ module "level_three_product_schedule" {

module "mock_team" {
source = "../../modules/pagerduty-team"
name = "${var.name} team"
name = "${var.name}-${local.random_string} team"
description = "Created by terratest"
}

module "escalation_policy" {
source = "../../modules/pagerduty-escalation-policy"

name = var.name
name = "${var.name}-${local.random_string}"
description = var.description

escalation_delay_in_minutes = 60
Expand Down
10 changes: 7 additions & 3 deletions examples/pagerduty-schedule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ This example creates a basic PagerDuty Schedule.

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | n/a |

## Modules

Expand All @@ -23,7 +25,9 @@ No providers.

## Resources

No resources.
| Name | Type |
|------|------|
| [random_id.random_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |

## Inputs

Expand All @@ -39,4 +43,4 @@ No resources.
| <a name="output_schedule_id"></a> [schedule\_id](#output\_schedule\_id) | The `id` attribute of the schedule. |
| <a name="output_user_one_id"></a> [user\_one\_id](#output\_user\_one\_id) | Dummy user created for inserting into the schedule. |
| <a name="output_user_two_id"></a> [user\_two\_id](#output\_user\_two\_id) | Dummy user created for inserting into the schedule. |
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS -->
18 changes: 13 additions & 5 deletions examples/pagerduty-schedule/main.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
resource "random_id" "random_suffix" {
byte_length = 10
}

locals {
random_string = random_id.random_suffix.b64_url
}

module "user_one" {
source = "../../modules/pagerduty-user"
name = "pagerduty-schedule-example-user-one"
email_address = "pagerduty-schedule-example-user-one@honestbank.com"
name = "pagerduty-schedule-example-user-one-${local.random_string}"
email_address = "pagerduty-schedule-example-user-one-${local.random_string}@honestbank.com"
}

module "user_two" {
source = "../../modules/pagerduty-user"
name = "pagerduty-schedule-example-user-two"
email_address = "pagerduty-schedule-example-user-two@honestbank.com"
name = "pagerduty-schedule-example-user-two-${local.random_string}"
email_address = "pagerduty-schedule-example-user-two-${local.random_string}@honestbank.com"
}

module "schedule" {
source = "../../modules/pagerduty-schedule"

name = var.name
name = "${var.name}-${local.random_string}"
description = "Example schedule"

# 604,800 seconds = 1 week (7 days)
Expand Down
Loading

0 comments on commit fcb7d23

Please sign in to comment.