-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update eventbridge-event-bus module to support default event bus (#14)
* Update eventbridge-event-bus module to support default event bus * Add eventbridge-rule module
- Loading branch information
Showing
13 changed files
with
344 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# eventbridge-rule | ||
|
||
This module creates following resources. | ||
|
||
- `aws_cloudwatch_event_rule` | ||
- `aws_cloudwatch_event_target` (optional) | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.27 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_cloudwatch_event_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_name"></a> [name](#input\_name) | (Required) A name of the rule for the event bus. | `string` | n/a | yes | | ||
| <a name="input_description"></a> [description](#input\_description) | (Optional) The description of the rule. | `string` | `"Managed by Terraform."` | no | | ||
| <a name="input_event_bus"></a> [event\_bus](#input\_event\_bus) | (Optional) The name or ARN of the event bus to associate with this rule. If you omit this, the `default` event bus is used. | `string` | `"default"` | no | | ||
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no | | ||
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no | | ||
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no | | ||
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | (Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. | `string` | `""` | no | | ||
| <a name="input_state"></a> [state](#input\_state) | (Optional) The state of the rule. Valid values are `DISABLED`, `ENABLED`, and `ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS`. Defaults to `ENABLED`.<br> `DISABLED` - The rule is disabled. EventBridge does not match any events against the rule.<br> `ENABLED` - The rule is enabled. EventBridge matches events against the rule, except for Amazon Web Services management events delivered through CloudTrail.<br> `ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS` - The rule is enabled for all events, including Amazon Web Services management events delivered through CloudTrail. Management events provide visibility into management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. This value is only valid for rules on the default event bus or custom event buses. It does not apply to partner event buses. | `string` | `"ENABLED"` | no | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no | | ||
| <a name="input_trigger"></a> [trigger](#input\_trigger) | (Required) The configuration for the rule trigger. At least one of `schedule_expression` or `event_pattern` is required. `trigger` as defined below.<br> (Optional) `event_pattern` - The event pattern to trigger when an event matching the pattern occurs. This is described in a JSON object. The `event_pattern` size is 2048 by default but it is adjustable up to 4096 characters by submitting a service quota increase request.<br> (Optional) `schedule_expression` - The scheduling expression. For example, `cron(0 20 * * ? *)` or `rate(5 minutes)`. Can only be used on the default event bus. | <pre>object({<br> event_pattern = optional(string)<br> schedule_expression = optional(string)<br> })</pre> | `{}` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_arn"></a> [arn](#output\_arn) | The Amazon Resource Name (ARN) of the rule. | | ||
| <a name="output_description"></a> [description](#output\_description) | The description of the rule. | | ||
| <a name="output_event_bus"></a> [event\_bus](#output\_event\_bus) | The name of the event bus. | | ||
| <a name="output_id"></a> [id](#output\_id) | The unique identifier for the rule. | | ||
| <a name="output_name"></a> [name](#output\_name) | The name of the rule. | | ||
| <a name="output_state"></a> [state](#output\_state) | The state of the rule. | | ||
| <a name="output_targets"></a> [targets](#output\_targets) | A list of archives for the event bus. | | ||
| <a name="output_trigger"></a> [trigger](#output\_trigger) | The configuration for the rule trriger. | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
locals { | ||
metadata = { | ||
package = "terraform-aws-messaging" | ||
version = trimspace(file("${path.module}/../../VERSION")) | ||
module = basename(path.module) | ||
name = var.name | ||
} | ||
module_tags = var.module_tags_enabled ? { | ||
"module.terraform.io/package" = local.metadata.package | ||
"module.terraform.io/version" = local.metadata.version | ||
"module.terraform.io/name" = local.metadata.module | ||
"module.terraform.io/full-name" = "${local.metadata.package}/${local.metadata.module}" | ||
"module.terraform.io/instance" = local.metadata.name | ||
} : {} | ||
} | ||
|
||
|
||
################################################### | ||
# Rule of Event Bus on EventBridge | ||
################################################### | ||
|
||
# role_arn - (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. | ||
# INFO: Not supported attributes | ||
# - `is_enabled` | ||
# - `name_prefix` | ||
resource "aws_cloudwatch_event_rule" "this" { | ||
event_bus_name = var.event_bus | ||
|
||
name = var.name | ||
description = var.description | ||
state = var.state | ||
|
||
|
||
## Triggers | ||
event_pattern = var.trigger.event_pattern | ||
schedule_expression = var.trigger.schedule_expression | ||
|
||
|
||
tags = merge( | ||
{ | ||
"Name" = local.metadata.name | ||
}, | ||
local.module_tags, | ||
var.tags, | ||
) | ||
} | ||
|
||
|
||
################################################### | ||
# Rule Targets | ||
################################################### | ||
|
||
# resource "aws_cloudwatch_event_target" "this" { | ||
# count = var.policy != null ? 1 : 0 | ||
# | ||
# event_bus_name = aws_cloudwatch_event_bus.this.name | ||
# policy = var.policy | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
output "id" { | ||
description = "The unique identifier for the rule." | ||
value = aws_cloudwatch_event_rule.this.id | ||
} | ||
|
||
output "arn" { | ||
description = "The Amazon Resource Name (ARN) of the rule." | ||
value = aws_cloudwatch_event_rule.this.arn | ||
} | ||
|
||
output "name" { | ||
description = "The name of the rule." | ||
value = aws_cloudwatch_event_rule.this.name | ||
} | ||
|
||
output "description" { | ||
description = "The description of the rule." | ||
value = aws_cloudwatch_event_rule.this.description | ||
} | ||
|
||
output "event_bus" { | ||
description = "The name of the event bus." | ||
value = aws_cloudwatch_event_rule.this.event_bus_name | ||
} | ||
|
||
output "state" { | ||
description = "The state of the rule." | ||
value = aws_cloudwatch_event_rule.this.state | ||
} | ||
|
||
output "trigger" { | ||
description = "The configuration for the rule trriger." | ||
value = { | ||
event_pattern = aws_cloudwatch_event_rule.this.event_pattern | ||
schedule_expression = aws_cloudwatch_event_rule.this.schedule_expression | ||
} | ||
} | ||
|
||
output "targets" { | ||
description = "A list of archives for the event bus." | ||
value = [ | ||
# for target in aws_cloudwatch_event_target.this : { | ||
# id = archive.id | ||
# arn = archive.arn | ||
# name = archive.name | ||
# description = archive.description | ||
# retention_in_days = archive.retention_days | ||
# } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
locals { | ||
resource_group_name = (var.resource_group_name != "" | ||
? var.resource_group_name | ||
: join(".", [ | ||
local.metadata.package, | ||
local.metadata.module, | ||
replace(local.metadata.name, "/[^a-zA-Z0-9_\\.-]/", "-"), | ||
]) | ||
) | ||
} | ||
|
||
|
||
module "resource_group" { | ||
source = "tedilabs/misc/aws//modules/resource-group" | ||
version = "~> 0.10.0" | ||
|
||
count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0 | ||
|
||
name = local.resource_group_name | ||
description = var.resource_group_description | ||
|
||
query = { | ||
resource_tags = local.module_tags | ||
} | ||
|
||
module_tags_enabled = false | ||
tags = merge( | ||
local.module_tags, | ||
var.tags, | ||
) | ||
} |
Oops, something went wrong.