Skip to content

Commit 773d771

Browse files
committed
Added tests
1 parent 37b5e25 commit 773d771

File tree

11 files changed

+875
-10
lines changed

11 files changed

+875
-10
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ $ saw watch /aws/lambda/events_debug_logger_ec2 --expand
103103

104104
| Name | Description |
105105
|------|-------------|
106+
| cloudwatch\_log\_group\_arn | ARN of cloudwatch log group which holds service-specific log events. |
106107
| cloudwatch\_log\_group\_name | Name of cloudwatch log group which holds service-specific log events. |
108+
| event\_bus\_arn | ARN of the event bridge eventbus. |
109+
| event\_bus\_name | Name of the event bridge eventbus. |
110+
| event\_rule\_arn | ARN of the event bridge rule. |
111+
| event\_rule\_id | ID of the event bridge rule. |
112+
| event\_rule\_name | Name of the event bridge rule. |
113+
| event\_target\_arn | ARN of the resource targeted by the eventbridge target. |
114+
| event\_target\_rule | Eventbridge rule responsible for invoking the target. |
107115

108116
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
provider "aws" {
2-
region = "us-east-1"
3-
profile = "sean"
2+
region = "us-east-1"
43
}

examples/modules.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module "eventbridge_debug_logger" {
22
source = "../"
33

4-
name = "eventbridge_debug_logger"
5-
service_name = "ec2"
4+
name = var.name
5+
service_name = var.service_name
66
lambda_logs_retention_in_days = 1
77
tags = var.tags
88
}

examples/outputs.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
output "saw_command" {
2-
value = "saw watch ${module.eventbridge_debug_logger.cloudwatch_log_group_name} --expand"
2+
description = "Tails lambda log group with saw"
3+
value = "saw watch ${module.eventbridge_debug_logger.cloudwatch_log_group_name} --expand"
34
}

examples/terraform.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
name = "events_logger"
2+
service_name = "ec2"
3+
14
tags = {
25
name = "eventbridge_debug_logger"
36
managed_by = "terraform"

examples/variables.tf

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,120 @@ variable "tags" {
22
description = "A map of tags to add to all resources."
33
type = map(string)
44
}
5+
6+
variable "name" {
7+
type = string
8+
description = "Common name shared between resources."
9+
}
10+
11+
variable "service_name" {
12+
type = string
13+
description = <<-DESC
14+
Name of the service to create a catch-all eventbridge rule for.
15+
16+
See variables.tf for a complete list of input options.
17+
DESC
18+
19+
validation {
20+
condition = contains([
21+
"access-analyzer",
22+
"forecast",
23+
"apigateway",
24+
"appflow",
25+
"application-autoscaling",
26+
"athena",
27+
"autoscaling",
28+
"codestar",
29+
"connect",
30+
"databrew",
31+
"xray",
32+
"backup",
33+
"batch",
34+
"acm",
35+
"acm-pca",
36+
"clouddirectory",
37+
"cloudformation",
38+
"cloudhsm",
39+
"cloudsearch",
40+
"cloudtrail",
41+
"cloudwatch",
42+
"applicationinsights",
43+
"logs",
44+
"synthetics",
45+
"codeartifact",
46+
"codebuild",
47+
"codecommit",
48+
"codedeploy",
49+
"codepipeline",
50+
"config",
51+
"controltower",
52+
"dataexchange",
53+
"dlm",
54+
"datapipeline",
55+
"dms",
56+
"datasync",
57+
"directconnect",
58+
"ds",
59+
"dynamodb",
60+
"ec2",
61+
"ec2fleet",
62+
"ec2spotfleet",
63+
"elasticbeanstalk",
64+
"ecr",
65+
"ecs",
66+
"elasticloadbalancing",
67+
"elasticmapreduce",
68+
"elastictranscoder",
69+
"elasticache",
70+
"es",
71+
"mediapackage",
72+
"emr",
73+
"events",
74+
"schemas",
75+
"gamelift",
76+
"glacier",
77+
"glue",
78+
"greengrass",
79+
"groundstation",
80+
"guardduty",
81+
"health",
82+
"iotanalytics",
83+
"kms",
84+
"kinesis",
85+
"lambda",
86+
"macie",
87+
"mediaconvert",
88+
"medialive",
89+
"mediastore",
90+
"metering-marketplace",
91+
"monitoring",
92+
"opsworks",
93+
"redshift",
94+
"redshift-data",
95+
"rds",
96+
"ram",
97+
"s3-outposts",
98+
"sagemaker",
99+
"secretsmanager",
100+
"securityhub",
101+
"sts",
102+
"sms",
103+
"servicecatalog",
104+
"signer",
105+
"sns",
106+
"sqs",
107+
"s3",
108+
"swf",
109+
"states",
110+
"storagegateway",
111+
"ssm",
112+
"tag",
113+
"transcribe",
114+
"waf",
115+
"workdocs",
116+
"workspaces", ],
117+
var.service_name
118+
)
119+
error_message = "The provided value is not supported for service_name, consult the module variables.tf for the possible input values."
120+
}
121+
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ go 1.16
44

55
require (
66
github.com/aws/aws-lambda-go v1.23.0
7+
github.com/aws/aws-sdk-go v1.27.1
8+
github.com/aws/aws-sdk-go-v2/config v1.1.6
9+
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.3.1
10+
github.com/gruntwork-io/terratest v0.33.0
711
github.com/sirupsen/logrus v1.8.1
12+
github.com/stretchr/testify v1.6.1
813
)

0 commit comments

Comments
 (0)