diff --git a/.gitignore b/.gitignore index 4e2212c..60b7755 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ # Created by .ignore support plugin (hsz.mobi) -terraform-aws-cloudwatch-event-rule.iml +terraform-aws-cloudwatch-event.iml .terraform/ *.tfstate* diff --git a/Makefile b/Makefile index 423d880..736ba7f 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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) diff --git a/modules/codecommit/main.tf b/modules/codecommit/main.tf index 4e80e44..c7c4ae1 100644 --- a/modules/codecommit/main.tf +++ b/modules/codecommit/main.tf @@ -2,7 +2,7 @@ data "aws_codecommit_repository" "repository" { repository_name = var.repository_name } -module "event_trigger" { +module "cloudwatch_event" { source = "../.." description = var.description diff --git a/modules/health/README.md b/modules/health/README.md new file mode 100644 index 0000000..af5a799 --- /dev/null +++ b/modules/health/README.md @@ -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. + diff --git a/modules/health/main.tf b/modules/health/main.tf new file mode 100644 index 0000000..799605e --- /dev/null +++ b/modules/health/main.tf @@ -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 +} diff --git a/modules/health/vars.tf b/modules/health/vars.tf new file mode 100644 index 0000000..9663c4f --- /dev/null +++ b/modules/health/vars.tf @@ -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" +} \ No newline at end of file