Skip to content

Commit bcb22b0

Browse files
committed
ELI-597: Adding metadata to emails for rotation
1 parent ac259aa commit bcb22b0

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

infrastructure/stacks/api-layer/step_functions.tf

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ resource "aws_sfn_state_machine" "rotation_machine" {
2424
Resource = "arn:aws:states:::sns:publish.waitForTaskToken",
2525
TimeoutSeconds = 86400,
2626
Parameters = {
27+
Subject = "Action required: AWSPENDING secret created (Environment: ${var.environment})",
2728
TopicArn = aws_sns_topic.secret_rotation.arn,
2829
"Message.$" = local.add_jobs_message
2930
},
@@ -44,6 +45,7 @@ resource "aws_sfn_state_machine" "rotation_machine" {
4445
Resource = "arn:aws:states:::sns:publish.waitForTaskToken",
4546
TimeoutSeconds = 86400,
4647
Parameters = {
48+
Subject = "Action required: Secret AWSPENDING promoted to AWSCURRENT (Environment: ${var.environment})",
4749
TopicArn = aws_sns_topic.secret_rotation.arn,
4850
"Message.$" = local.delete_jobs_message
4951
},
@@ -59,7 +61,7 @@ resource "aws_sfn_state_machine" "rotation_machine" {
5961
Resource = "arn:aws:states:::sns:publish",
6062
Parameters = {
6163
TopicArn = aws_sns_topic.secret_rotation.arn,
62-
Subject = "WARNING: Secret Rotation Timed Out",
64+
Subject = "Warning: Secret rotation timed out (Environment: ${var.environment})",
6365
"Message.$" = local.timeout_message
6466
},
6567
Next = "Fail_Timeout"
@@ -75,7 +77,7 @@ resource "aws_sfn_state_machine" "rotation_machine" {
7577
Resource = "arn:aws:states:::sns:publish",
7678
Parameters = {
7779
TopicArn = aws_sns_topic.secret_rotation.arn,
78-
Subject = "CRITICAL: Secret Rotation Failed",
80+
Subject = "Critical: Secret Rotation Failed (Environment: ${var.environment})",
7981
"Message.$" = local.failure_message
8082
},
8183
Next = "Fail_Generic"
@@ -91,7 +93,7 @@ locals {
9193
add_jobs_message = <<EOT
9294
States.Format('
9395
======================================================
94-
ACTION REQUIRED: PENDING SECRET CREATED
96+
Action required: AWSPENDING secret created (Environment: ${var.environment})
9597
======================================================
9698
9799
A manual action is required to proceed.
@@ -100,20 +102,19 @@ CONTEXT:
100102
Secret Name: ${module.secrets_manager.aws_hashing_secret_name}
101103
102104
INSTRUCTIONS:
103-
1. Run the "Add New Hashes" job.
105+
1. Run the "Add New Hashes (elid_add_new_salt)" job.
104106
2. Ensure the new hashes are working as expected.
105107
3. Run the command below to approve and resume the workflow:
106108
107-
aws stepfunctions send-task-success --task-token {}
109+
aws stepfunctions send-task-success --task-token $$.Task.Token --task-output {{}}
108110
109111
======================================================
110-
', $$.Task.Token)
111112
EOT
112113

113114
delete_jobs_message = <<EOT
114115
States.Format('
115116
======================================================
116-
ACTION REQUIRED: SECRET AWSPENDING PROMOTED TO AWSCURRENT
117+
Action required: Secret AWSPENDING promoted to AWSCURRENT (Environment: ${var.environment})
117118
======================================================
118119
119120
A manual action is required to proceed.
@@ -122,24 +123,26 @@ CONTEXT:
122123
Secret Name: ${module.secrets_manager.aws_hashing_secret_name}
123124
124125
INSTRUCTIONS:
125-
1. Run the "Delete Old Hashes" job.
126+
1. Run the "Delete Old Hashes (elid_delete_old_salt)" job.
126127
2. Ensure the old hashes have been removed successfully.
127128
3. Run the command below to approve and resume the workflow:
128129
129-
aws stepfunctions send-task-success --task-token {}
130+
aws stepfunctions send-task-success --task-token $$.Task.Token --task-output {{}}
130131
131132
======================================================
132-
', $$.Task.Token)
133133
EOT
134134

135135
failure_message = <<EOT
136136
States.Format('
137137
======================================================
138-
CRITICAL: ROTATION FAILED
138+
Critical: Rotation failed (Environment: ${var.environment})
139139
======================================================
140140
141141
The workflow encountered an error and could not complete.
142142
143+
CONTEXT:
144+
Secret Name: ${module.secrets_manager.aws_hashing_secret_name}
145+
143146
ERROR DETAILS:
144147
{}
145148
@@ -162,7 +165,7 @@ EOT
162165
timeout_message = <<EOT
163166
States.Format('
164167
======================================================
165-
WARNING: ROTATION TIMED OUT
168+
Warning: Rotation timed out (Environment: ${var.environment})
166169
======================================================
167170
168171
The manual verification step was not completed within the 24-hour limit.

0 commit comments

Comments
 (0)