File tree 3 files changed +77
-0
lines changed
examples/timezone-scheduler
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Deploy two lambda for testing with awspec
2
+ resource "random_pet" "suffix" {}
3
+
4
+ module "aws-stop-friday" {
5
+ source = " ../.."
6
+ name = " stop-aws-${ random_pet . suffix . id } "
7
+ schedule_expression = " cron(0 23 ? * FRI *)"
8
+ schedule_expression_timezone = " Europe/Paris"
9
+ schedule_action = " stop"
10
+ autoscaling_schedule = " true"
11
+ ec2_schedule = " true"
12
+ rds_schedule = " true"
13
+
14
+ scheduler_tag = {
15
+ key = " tostop"
16
+ value = " true-${ random_pet . suffix . id } "
17
+ }
18
+ }
19
+
20
+ module "aws-start-monday" {
21
+ source = " ../.."
22
+ name = " start-aws-${ random_pet . suffix . id } "
23
+ schedule_expression = " cron(0 07 ? * MON *)"
24
+ schedule_expression_timezone = " Europe/Berlin"
25
+ schedule_action = " start"
26
+ autoscaling_schedule = " true"
27
+ ec2_schedule = " true"
28
+ rds_schedule = " true"
29
+
30
+ scheduler_tag = {
31
+ key = " tostop"
32
+ value = " true-${ random_pet . suffix . id } "
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ run "create_test_infrastructure" {
2
+ command = apply
3
+
4
+ assert {
5
+ condition = module. aws-stop-friday . scheduler_lambda_name == " stop-aws-${ random_pet . suffix . id } "
6
+ error_message = " Invalid Stop lambda name"
7
+ }
8
+
9
+ assert {
10
+ condition = module. aws-start-monday . scheduler_lambda_name == " start-aws-${ random_pet . suffix . id } "
11
+ error_message = " Invalid Start lambda name"
12
+ }
13
+
14
+ assert {
15
+ condition = module. aws-stop-friday . scheduler_expression == " cron(0 23 ? * FRI *)"
16
+ error_message = " Invalid scheduler expression"
17
+ }
18
+
19
+ assert {
20
+ condition = module. aws-start-monday . scheduler_expression == " cron(0 07 ? * MON *)"
21
+ error_message = " Invalid scheduler expression"
22
+ }
23
+
24
+ assert {
25
+ condition = module. aws-stop-friday . scheduler_timezone == " Europe/Paris"
26
+ error_message = " Invalid scheduler timezone"
27
+ }
28
+
29
+ assert {
30
+ condition = module. aws-start-monday . scheduler_timezone == " Europe/Berlin"
31
+ error_message = " Invalid scheduler timezone"
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_version = " >= 1.0"
3
+
4
+ required_providers {
5
+ aws = {
6
+ source = " hashicorp/aws"
7
+ version = " >= 5.94.1"
8
+ }
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments