Skip to content

Commit

Permalink
Merge pull request #24 from mackerelio-labs/remove-provider
Browse files Browse the repository at this point in the history
[cloudwatch-logs-aggregator] BREAKING CHANGE: Remove AWS provider block from modules
  • Loading branch information
Arthur1 authored Jan 24, 2024
2 parents 1303bcb + 78c9bfe commit 4dc9e14
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
17 changes: 11 additions & 6 deletions cloudwatch-logs-aggregator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ The cloudwatch-logs-aggregator-lambda module manages a Lambda function that runs

### Example
``` hcl
provider "aws" {
region = "ap-northeast-1"
// >= 5.27.0 is required
}
module "cw_logs_aggregator_lambda" {
source = "github.com/mackerelio-labs/mackerel-monitoring-modules//cloudwatch-logs-aggregator/lambda?ref=v0.2.2"
region = "ap-northeast-1"
}
```

### Variables
| Name | Description | Default |
| --- | --- | --- |
| `region` | The AWS region in which the resources are created. | |
| `iam_role_name` | The name of the Lambda function's execution role. | `"mackerel-cloudwatch-logs-aggregator-lambda"` |
| `function_name` | The name of the Lambda function. | `"mackerel-cloudwatch-logs-aggregator"` |
| `memory_size_in_mb` | The memory size of the Lambda function, in megabytes. | `128` |
Expand All @@ -52,10 +54,14 @@ You can attach multiple rules for a signle Lambda function.

### Example
``` hcl
provider "aws" {
region = "ap-northeast-1"
// >= 5.27.0 is required
}
module "cw_logs_aggregator_rule_batch_jobs" {
source = "github.com/mackerelio-labs/mackerel-monitoring-modules//cloudwatch-logs-aggregator/rule?ref=v0.2.2"
region = "ap-northeast-1"
rule_name = "mackerel-cloudwatch-logs-aggregator-batch-jobs"
function_arn = module.cw_logs_aggregator_lambda.function_arn
Expand All @@ -77,10 +83,9 @@ module "cw_logs_aggregator_rule_batch_jobs" {
### Variables
| Name | Description | Default |
| --- | --- | --- |
| `region` | The AWS region in which the resources are created. | |
| `rule_name` | The name of the EventBridge rule. | |
| `function_arn` | The ARN of the target Lambda function. | |
| `is_enabled` | Whether the rules is enabled or not. | `true` |
| `state` | Whether the rules is enabled or not. See [the document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule#state) | `"ENABLED"` |
| `api_key_name` | The name of the parameter of Parameter Store which stores the Mackerel API key. It is recommended to store the API key as a secure string. | |
| `service_name` | The name of the service on Mackerel to which metrics are posted. | |
| `log_group_name` | The name of the log group to be aggregated. | |
Expand Down
9 changes: 7 additions & 2 deletions cloudwatch-logs-aggregator/lambda/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
provider "aws" {
region = var.region
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.27.0"
}
}
}

resource "aws_iam_role" "this" {
Expand Down
5 changes: 0 additions & 5 deletions cloudwatch-logs-aggregator/lambda/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
variable "region" {
description = "The AWS region in which the resources are created."
type = string
}

variable "iam_role_name" {
description = "The name of the Lambda function's execution role."
type = string
Expand Down
3 changes: 0 additions & 3 deletions cloudwatch-logs-aggregator/rule/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ terraform {
}
}
}
provider "aws" {
region = var.region
}

resource "aws_cloudwatch_event_rule" "this" {
name = var.rule_name
Expand Down
5 changes: 0 additions & 5 deletions cloudwatch-logs-aggregator/rule/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
variable "region" {
description = "The AWS region in which the resources are created."
type = string
}

variable "rule_name" {
description = "The name of the EventBridge rule."
type = string
Expand Down

0 comments on commit 4dc9e14

Please sign in to comment.