-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(documentdb): add an example of docdb scheduler
This commit introduces a new test for the documentdb module, specifically focusing on the addition of an example for the docdb scheduler. The test is designed to validate the functionality and reliability of the scheduler, ensuring that it performs as expected and meets the required specifications.
- Loading branch information
1 parent
17f2a85
commit 7f8a896
Showing
3 changed files
with
99 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Deploy two lambda for testing with awspec | ||
|
||
resource "aws_kms_key" "scheduler" { | ||
description = "test kms option on scheduler module" | ||
deletion_window_in_days = 7 | ||
} | ||
|
||
resource "aws_docdb_cluster" "scheduled" { | ||
cluster_identifier = "docdb-cluster-scheduled" | ||
engine = "docdb" | ||
master_username = "foo" | ||
master_password = "mustbeeightchars" | ||
skip_final_snapshot = true | ||
tags = { | ||
tostop = "true" | ||
terratest_tag = var.random_tag | ||
} | ||
} | ||
|
||
resource "aws_docdb_cluster_instance" "scheduled" { | ||
identifier = "docdb-instance-scheduled" | ||
cluster_identifier = aws_docdb_cluster.scheduled.id | ||
instance_class = "db.r5.large" | ||
tags = { | ||
tostop = "true" | ||
terratest_tag = var.random_tag | ||
} | ||
} | ||
|
||
resource "aws_docdb_cluster" "not_scheduled" { | ||
cluster_identifier = "docdb-cluster-not-scheduled" | ||
engine = "docdb" | ||
master_username = "foo" | ||
master_password = "mustbeeightchars" | ||
skip_final_snapshot = true | ||
tags = { | ||
tostop = "false" | ||
terratest_tag = var.random_tag | ||
} | ||
} | ||
|
||
resource "aws_docdb_cluster_instance" "not_scheduled" { | ||
identifier = "docdb-instance-not-scheduled" | ||
cluster_identifier = aws_docdb_cluster.not_scheduled.id | ||
instance_class = "db.r5.large" | ||
tags = { | ||
tostop = "false" | ||
terratest_tag = var.random_tag | ||
} | ||
} | ||
|
||
|
||
module "documentdb-stop-friday" { | ||
source = "../.." | ||
name = "stop-documentdb" | ||
kms_key_arn = aws_kms_key.scheduler.arn | ||
cloudwatch_schedule_expression = "cron(0 23 ? * FRI *)" | ||
schedule_action = "stop" | ||
documentdb_schedule = "true" | ||
|
||
scheduler_tag = { | ||
key = "tostop" | ||
value = "true" | ||
} | ||
} | ||
|
||
module "documentdb-start-monday" { | ||
source = "../.." | ||
name = "start-documentdb" | ||
cloudwatch_schedule_expression = "cron(0 07 ? * MON *)" | ||
schedule_action = "start" | ||
documentdb_schedule = "true" | ||
|
||
scheduler_tag = { | ||
key = "tostop" | ||
value = "true" | ||
} | ||
} |
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,17 @@ | ||
# Terraform documentdb-scheduler outputs | ||
|
||
output "lambda_stop_name" { | ||
value = module.documentdb-stop-friday.scheduler_lambda_name | ||
} | ||
|
||
output "lambda_stop_arn" { | ||
value = module.documentdb-stop-friday.scheduler_lambda_arn | ||
} | ||
|
||
output "lambda_start_name" { | ||
value = module.documentdb-start-monday.scheduler_lambda_name | ||
} | ||
|
||
output "lambda_start_arn" { | ||
value = module.documentdb-start-monday.scheduler_lambda_arn | ||
} |
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,4 @@ | ||
variable "random_tag" { | ||
description = "aws tag use during integration tests" | ||
default = "terratest_random_tag" | ||
} |