@@ -21,12 +21,12 @@ resource "aws_subnet" "secondary" {
2121}
2222
2323resource "aws_db_subnet_group" "aurora" {
24- name = " aurora-subnet"
24+ name = " aurora-subnet- ${ random_pet . suffix . id } "
2525 subnet_ids = [aws_subnet . primary . id , aws_subnet . secondary . id ]
2626}
2727
2828resource "aws_rds_cluster" "aurora_scheduled" {
29- cluster_identifier = " test-to-stop-${ random_pet . suffix . id } "
29+ cluster_identifier = " test-to-stop-aurora-cluster- ${ random_pet . suffix . id } "
3030 engine = " aurora-mysql"
3131 db_subnet_group_name = aws_db_subnet_group. aurora . id
3232 database_name = " aurorawithtag"
@@ -40,7 +40,7 @@ resource "aws_rds_cluster" "aurora_scheduled" {
4040}
4141
4242resource "aws_rds_cluster_instance" "aurora_scheduled" {
43- identifier = " test-to-stop-instance-${ random_pet . suffix . id } "
43+ identifier = " test-to-stop-aurora- instance-${ random_pet . suffix . id } "
4444 engine = aws_rds_cluster. aurora_scheduled . engine
4545 engine_version = aws_rds_cluster. aurora_scheduled . engine_version
4646 db_subnet_group_name = aws_db_subnet_group. aurora . id
@@ -52,9 +52,8 @@ resource "aws_rds_cluster_instance" "aurora_scheduled" {
5252 }
5353}
5454
55- # Create rds mariadb instance with tag
5655resource "aws_db_instance" "mariadb_scheduled" {
57- identifier = " test-to-stop-${ random_pet . suffix . id } "
56+ identifier = " test-to-stop-mariadb-instance- ${ random_pet . suffix . id } "
5857 db_name = " mariadbwithtag"
5958 db_subnet_group_name = aws_db_subnet_group. aurora . id
6059 allocated_storage = 10
@@ -71,9 +70,8 @@ resource "aws_db_instance" "mariadb_scheduled" {
7170 }
7271}
7372
74- # Create rds mysql instance with tag
7573resource "aws_db_instance" "mysql_not_scheduled" {
76- identifier = " test-not-to-stop-${ random_pet . suffix . id } "
74+ identifier = " test-not-to-stop-mysql-instance- ${ random_pet . suffix . id } "
7775 db_name = " mysqlwithouttag"
7876 db_subnet_group_name = aws_db_subnet_group. aurora . id
7977 allocated_storage = 10
@@ -124,3 +122,17 @@ module "rds-start-monday" {
124122 value = " true"
125123 }
126124}
125+
126+ module "test-execution" {
127+ count = var. test_mode ? 1 : 0
128+ source = " ./test-execution"
129+
130+ lambda_stop_name = module. rds-stop-friday . scheduler_lambda_name
131+ rds_aurora_cluster_to_scheduled_name = aws_rds_cluster. aurora_scheduled . cluster_identifier
132+ rds_mariadb_instance_to_scheduled_name = aws_db_instance. mariadb_scheduled . identifier
133+ rds_mysql_instance_to_not_scheduled_name = aws_db_instance. mysql_not_scheduled . identifier
134+
135+ depends_on = [
136+ aws_rds_cluster_instance . aurora_scheduled
137+ ]
138+ }
0 commit comments