Skip to content

Commit

Permalink
Added module for aws health events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Fortuna committed Mar 11, 2021
1 parent 031f799 commit 15f974c
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Created by .ignore support plugin (hsz.mobi)
terraform-aws-cloudwatch-event-rule.iml
terraform-aws-cloudwatch-event.iml
.terraform/
*.tfstate*
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
SHELL:=/bin/bash
AWS_DEFAULT_REGION?=ap-southeast-2

ifneq (, $(shell which docker))
TERRAFORM_VERSION=0.13.4
TERRAFORM=docker run --rm -v "${PWD}:/work" -v "${HOME}:/root" -e AWS_DEFAULT_REGION=$(AWS_DEFAULT_REGION) -e http_proxy=$(http_proxy) --net=host -w /work hashicorp/terraform:$(TERRAFORM_VERSION)
else
TERRAFORM=terraform
endif

TERRAFORM_DOCS=docker run --rm -v "${PWD}:/work" tmknom/terraform-docs

Expand All @@ -23,7 +27,8 @@ clean:

validate:
$(TERRAFORM) init && $(TERRAFORM) validate && \
$(TERRAFORM) init modules/codecommit && $(TERRAFORM) validate modules/codecommit
$(TERRAFORM) init modules/codecommit && $(TERRAFORM) validate modules/codecommit && \
$(TERRAFORM) init modules/health && $(TERRAFORM) validate modules/health

test: validate
$(CHECKOV) -d /work
Expand All @@ -34,11 +39,13 @@ diagram:

docs: diagram
$(TERRAFORM_DOCS) markdown ./ >./README.md && \
$(TERRAFORM_DOCS) markdown ./modules/codecommit >./modules/codecommit/README.md
$(TERRAFORM_DOCS) markdown ./modules/codecommit >./modules/codecommit/README.md && \
$(TERRAFORM_DOCS) markdown ./modules/health >./modules/health/README.md

format:
$(TERRAFORM) fmt -list=true ./ && \
$(TERRAFORM) fmt -list=true ./modules/codecommit
$(TERRAFORM) fmt -list=true ./modules/codecommit && \
$(TERRAFORM) fmt -list=true ./modules/health

example:
$(TERRAFORM) init -upgrade examples/$(EXAMPLE) && $(TERRAFORM) plan -input=false examples/$(EXAMPLE)
2 changes: 1 addition & 1 deletion modules/codecommit/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data "aws_codecommit_repository" "repository" {
repository_name = var.repository_name
}

module "event_trigger" {
module "cloudwatch_event" {
source = "../.."

description = var.description
Expand Down
22 changes: 22 additions & 0 deletions modules/health/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Requirements

No requirements.

## Providers

No provider.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| description | Trigger description | `any` | n/a | yes |
| name | Name of the CloudWatch Event trigger | `any` | n/a | yes |
| target\_arn | ARN of the CloudWatch Event target | `any` | n/a | yes |
| target\_name | Function name for Lambda targets (used to configure invocation permissions) | `any` | `null` | no |
| target\_role | Name of the IAM role assumed by the target | `any` | n/a | yes |

## Outputs

No output.

11 changes: 11 additions & 0 deletions modules/health/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module "cloudwatch_event" {
source = "../.."

description = var.description
name = var.name
event_source = "aws.health"
event_types = ["AWS Health Event"]
target_arn = var.target_arn
target_name = var.target_name
target_role = var.target_role
}
20 changes: 20 additions & 0 deletions modules/health/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
variable "name" {
description = "Name of the CloudWatch Event trigger"
}

variable "description" {
description = "Trigger description"
}

variable "target_arn" {
description = "ARN of the CloudWatch Event target"
}

variable "target_name" {
description = "Function name for Lambda targets (used to configure invocation permissions)"
default = null
}

variable "target_role" {
description = "Name of the IAM role assumed by the target"
}

0 comments on commit 15f974c

Please sign in to comment.