@@ -98,3 +98,75 @@ data "http" "call_workflows_setup" {
98
98
google_service_account_iam_member . workflow_auth_function
99
99
]
100
100
}
101
+
102
+ # Sleep for 120 seconds to allow the workflow to execute and finish setup
103
+ resource "time_sleep" "wait_after_workflow_execution" {
104
+ create_duration = " 120s"
105
+ depends_on = [
106
+ data . http . call_workflows_setup ,
107
+ ]
108
+ }
109
+
110
+ # # Trigger the execution of the setup workflow with an API call
111
+ data "http" "call_workflows_state_1" {
112
+ url = " https://workflowexecutions.googleapis.com/v1/projects/${ module . project-services . project_id } /locations/${ var . region } /workflows/${ google_workflows_workflow . workflow . name } /executions"
113
+ method = " GET"
114
+ request_headers = {
115
+ Accept = " application/json"
116
+ Authorization = " Bearer ${ data . google_client_config . current . access_token } " }
117
+ depends_on = [
118
+ time_sleep . wait_after_workflow_execution ,
119
+ ]
120
+ }
121
+
122
+ data "http" "retry_workflows_1" {
123
+ count = data. http . call_workflows_state_1 . executions [0 ]. state == " SUCCEEDED" || data. http . call_workflows_state_1 . executions [0 ]. state == " ACTIVE" ? 0 : 1
124
+ url = " https://workflowexecutions.googleapis.com/v1/projects/${ module . project-services . project_id } /locations/${ var . region } /workflows/${ google_workflows_workflow . workflow . name } /executions"
125
+ method = " POST"
126
+ request_headers = {
127
+ Accept = " application/json"
128
+ Authorization = " Bearer ${ data . google_client_config . current . access_token } " }
129
+ depends_on = [
130
+ data . http . call_workflows_state_1 ]
131
+ }
132
+
133
+ # # Sleep for 30 seconds to recheck the workflow state
134
+ # resource "time_sleep" "wait_to_recheck_workflow" {
135
+ # create_duration = "30s"
136
+ # depends_on = [
137
+ # data.http.retry_workflows_1,
138
+ # ]
139
+ # }
140
+
141
+ # ## Trigger the execution of the setup workflow with an API call
142
+ # data "http" "call_workflows_state_2" {
143
+ # count = data.http.call_workflows_state_2.executions[0].state == "SUCCEEDED" || data.http.call_workflows_state_2.executions[0].state == "ACTIVE" ? 0 : 1
144
+ # url = "https://workflowexecutions.googleapis.com/v1/projects/${module.project-services.project_id}/locations/${var.region}/workflows/${google_workflows_workflow.workflow.name}/executions"
145
+ # method = "GET"
146
+ # request_headers = {
147
+ # Accept = "application/json"
148
+ # Authorization = "Bearer ${data.google_client_config.current.access_token}" }
149
+ # depends_on = [
150
+ # time_sleep.wait_to_recheck_workflow,
151
+ # ]
152
+ # }
153
+
154
+ # data "http" "retry_workflows_2" {
155
+ # count = data.http.call_workflows_state.executions[0].state == "SUCCEEDED" || data.http.call_workflows_state.executions[0].state == "ACTIVE" ? 0 : 1
156
+ # url = "https://workflowexecutions.googleapis.com/v1/projects/${module.project-services.project_id}/locations/${var.region}/workflows/${google_workflows_workflow.workflow.name}/executions"
157
+ # method = "POST"
158
+ # request_headers = {
159
+ # Accept = "application/json"
160
+ # Authorization = "Bearer ${data.google_client_config.current.access_token}" }
161
+ # depends_on = [
162
+ # data.http.call_workflows_state_2]
163
+ # }
164
+
165
+ # Sleep for 120 seconds to allow the workflow to execute and finish setup
166
+ resource "time_sleep" "complete_workflow" {
167
+ count = data. http . call_workflows_state_1 . executions [0 ]. state == " SUCCEEDED" ? 0 : 1
168
+ create_duration = " 120s"
169
+ depends_on = [
170
+ data . http . retry_workflows_1 ,
171
+ ]
172
+ }
0 commit comments