Skip to content

Commit 8327b61

Browse files
committed
Fixing race condition issue in cw queries
1 parent 199a8bb commit 8327b61

3 files changed

Lines changed: 2 additions & 26 deletions

File tree

infrastructure/stacks/blue-green-link/cloudwatch-queries.tf

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
// Introduce a short sleep BEFORE creating query definitions to allow
2-
// recently-created log groups (from other modules in the same apply)
3-
// to propagate. Note: This does NOT guarantee post-create consistency
4-
// of the query definitions themselves, but can reduce immediate read
5-
// failures when the provider plans many resources concurrently.
6-
resource "time_sleep" "wait_for_propagation" {
7-
create_duration = "45s"
8-
}
9-
101
resource "aws_cloudwatch_query_definition" "search_for_errors" {
11-
depends_on = [time_sleep.wait_for_propagation]
122
name = "${var.project_id}/${var.blue_green_environment}/search-for-errors"
133

144
log_group_names = [
@@ -33,7 +23,6 @@ EOF
3323
}
3424

3525
resource "aws_cloudwatch_query_definition" "search_by_correlation_id" {
36-
depends_on = [aws_cloudwatch_query_definition.search_for_errors]
3726
name = "${var.project_id}/${var.blue_green_environment}/search-by-correlation-id"
3827

3928
log_group_names = [
@@ -58,7 +47,6 @@ EOF
5847
}
5948

6049
resource "aws_cloudwatch_query_definition" "search_by_correlation_id_expanded" {
61-
depends_on = [aws_cloudwatch_query_definition.search_by_correlation_id]
6250
name = "${var.project_id}/${var.blue_green_environment}/search-by-correlation-id-expanded"
6351

6452
log_group_names = [
@@ -83,7 +71,6 @@ EOF
8371
}
8472

8573
resource "aws_cloudwatch_query_definition" "search_by_odscode" {
86-
depends_on = [aws_cloudwatch_query_definition.search_by_correlation_id_expanded]
8774
name = "${var.project_id}/${var.blue_green_environment}/search-by-odscode"
8875

8976
log_group_names = [
@@ -108,7 +95,6 @@ EOF
10895
}
10996

11097
resource "aws_cloudwatch_query_definition" "search_by_odscode_expanded" {
111-
depends_on = [aws_cloudwatch_query_definition.search_by_odscode]
11298
name = "${var.project_id}/${var.blue_green_environment}/search-by-odscode-expanded"
11399

114100
log_group_names = [
@@ -133,7 +119,6 @@ EOF
133119
}
134120

135121
resource "aws_cloudwatch_query_definition" "search_for_invalid_postcode" {
136-
depends_on = [aws_cloudwatch_query_definition.search_by_odscode_expanded]
137122
name = "${var.project_id}/${var.blue_green_environment}/search-for-invalid-postcode"
138123

139124
log_group_names = [
@@ -152,7 +137,6 @@ EOF
152137
}
153138

154139
resource "aws_cloudwatch_query_definition" "search_for_invalid_opening_times" {
155-
depends_on = [aws_cloudwatch_query_definition.search_for_invalid_postcode]
156140
name = "${var.project_id}/${var.blue_green_environment}/search-for-invalid-opening-times"
157141

158142
log_group_names = [
@@ -171,7 +155,6 @@ EOF
171155
}
172156

173157
resource "aws_cloudwatch_query_definition" "search_by_email_correlation_id" {
174-
depends_on = [aws_cloudwatch_query_definition.search_for_invalid_opening_times]
175158
name = "${var.project_id}/${var.blue_green_environment}/search-by-email-correlation-id"
176159

177160
log_group_names = [
@@ -191,7 +174,6 @@ EOF
191174
}
192175

193176
resource "aws_cloudwatch_query_definition" "search_by_update_request_success" {
194-
depends_on = [aws_cloudwatch_query_definition.search_by_email_correlation_id]
195177
name = "${var.project_id}/${var.blue_green_environment}/update-request-success"
196178

197179
log_group_names = [
@@ -210,7 +192,6 @@ EOF
210192
}
211193

212194
resource "aws_cloudwatch_query_definition" "search_by_update_request_failed" {
213-
depends_on = [aws_cloudwatch_query_definition.search_by_update_request_success]
214195
name = "${var.project_id}/${var.blue_green_environment}/update-request-failed"
215196

216197
log_group_names = [
@@ -229,7 +210,6 @@ EOF
229210
}
230211

231212
resource "aws_cloudwatch_query_definition" "search_by_dos_data_item_updates" {
232-
depends_on = [aws_cloudwatch_query_definition.search_by_update_request_failed]
233213
name = "${var.project_id}/${var.blue_green_environment}/dos-data-item-updates"
234214

235215
log_group_names = [
@@ -250,7 +230,6 @@ EOF
250230
}
251231

252232
resource "aws_cloudwatch_query_definition" "search_for_report_warnings" {
253-
depends_on = [aws_cloudwatch_query_definition.search_by_dos_data_item_updates]
254233
name = "${var.project_id}/${var.blue_green_environment}/search-for-report-warnings"
255234

256235
log_group_names = [
@@ -277,7 +256,6 @@ EOF
277256

278257

279258
resource "aws_cloudwatch_query_definition" "search_for_quality_checker_logs_with_odscode" {
280-
depends_on = [aws_cloudwatch_query_definition.search_for_report_warnings]
281259
name = "${var.project_id}/${var.blue_green_environment}/search-for-quality-checker-logs-with-odscode"
282260

283261
log_group_names = [

infrastructure/stacks/blue-green-link/terraform.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ terraform {
77
source = "hashicorp/aws"
88
version = "~> 6.14.1"
99
}
10-
time = {
11-
source = "hashicorp/time"
12-
version = "~> 0.13.1"
13-
}
1410
}
1511
}

infrastructure/stacks/common/common-provider.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
provider "aws" {
22
region = var.aws_region
3+
retry_mode = "adaptive"
4+
max_retries = 25
35
default_tags {
46
tags = {
57
"DataClassification" = var.data_classification

0 commit comments

Comments
 (0)