Skip to content

Commit 5b9a769

Browse files
committed
feat!: Formatting and update of example
1 parent 9a2c79d commit 5b9a769

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

examples/with-archive/main.tf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ provider "aws" {
77
skip_credentials_validation = true
88
}
99

10+
data "aws_caller_identity" "current" {}
11+
data "aws_region" "current" {}
12+
13+
1014
module "eventbridge" {
1115
source = "../../"
1216

@@ -50,6 +54,7 @@ module "eventbridge_archive_only" {
5054

5155
create_bus = false
5256
create_archives = true
57+
kms_key_identifier = module.kms.key_id
5358

5459
archives = {
5560
"launch-archive-existing-bus" = {
@@ -79,3 +84,48 @@ resource "random_pet" "this" {
7984
resource "aws_cloudwatch_event_bus" "existing_bus" {
8085
name = "${random_pet.this.id}-existing-bus"
8186
}
87+
88+
module "kms" {
89+
source = "terraform-aws-modules/kms/aws"
90+
version = "~> 2.0"
91+
description = "KMS key for cross region automated backups replication"
92+
93+
# Aliases
94+
aliases = ["test"]
95+
aliases_use_name_prefix = true
96+
key_statements = [
97+
{
98+
sid = "Allow eventbridge"
99+
principals = [
100+
{
101+
type = "Service"
102+
identifiers = ["events.amazonaws.com"]
103+
}
104+
]
105+
actions = [
106+
"kms:DescribeKey",
107+
"kms:GenerateDataKey",
108+
"kms:Decrypt"
109+
]
110+
resources = ["*"]
111+
conditions = [
112+
{
113+
test = "StringEquals"
114+
variable = "kms:EncryptionContext:aws:events:event-bus:arn"
115+
values = [
116+
"arn:aws:events:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:event-bus/example",
117+
]
118+
},
119+
{
120+
test = "StringEquals"
121+
variable = "aws:SourceArn"
122+
values = [
123+
"arn:aws:events:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:event-bus/example",
124+
]
125+
}
126+
]
127+
}
128+
]
129+
130+
key_owners = [data.aws_caller_identity.current.arn]
131+
}

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ resource "aws_cloudwatch_event_archive" "this" {
284284

285285
region = var.region
286286

287-
name = lookup(each.value, "name", each.key)
288-
event_source_arn = try(each.value["event_source_arn"], aws_cloudwatch_event_bus.this[0].arn)
287+
name = lookup(each.value, "name", each.key)
288+
event_source_arn = try(each.value["event_source_arn"], aws_cloudwatch_event_bus.this[0].arn)
289289
kms_key_identifier = var.kms_key_identifier
290290

291291
description = lookup(each.value, "description", null)

0 commit comments

Comments
 (0)