@@ -319,6 +319,75 @@ output "my_output2" {
319319 },
320320 },
321321
322+ "actions can't be used in depends_on" : {
323+ module : map [string ]string {
324+ "main.tf" : `
325+ action "test_action" "my_action" {
326+ config {
327+ attr = "value"
328+ }
329+ }
330+ resource "test_object" "a" {
331+ depends_on = [action.test_action.my_action]
332+ lifecycle {
333+ action_trigger {
334+ events = [before_create]
335+ actions = [action.test_action.my_action]
336+ }
337+ }
338+ }
339+ ` ,
340+ },
341+ expectValidateDiagnostics : func (m * configs.Config ) tfdiags.Diagnostics {
342+ return tfdiags.Diagnostics {}.Append (
343+ & hcl.Diagnostic {
344+ Severity : hcl .DiagError ,
345+ Summary : "Invalid depends_on reference" ,
346+ Detail : "Actions can not be referenced in depends_on. Use depends_on on the resource that triggers the action instead." ,
347+ Subject : & hcl.Range {
348+ Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
349+ Start : hcl.Pos {Line : 8 , Column : 17 , Byte : 117 },
350+ End : hcl.Pos {Line : 8 , Column : 45 , Byte : 145 },
351+ },
352+ })
353+ },
354+ },
355+
356+ "action instances can't be used in depends_on" : {
357+ module : map [string ]string {
358+ "main.tf" : `
359+ action "test_action" "my_action" {
360+ count = 3
361+ config {
362+ attr = "value"
363+ }
364+ }
365+ resource "test_object" "a" {
366+ depends_on = [action.test_action.my_action[1]]
367+ lifecycle {
368+ action_trigger {
369+ events = [before_create]
370+ actions = [action.test_action.my_action[1]]
371+ }
372+ }
373+ }
374+ ` ,
375+ },
376+ expectValidateDiagnostics : func (m * configs.Config ) tfdiags.Diagnostics {
377+ return tfdiags.Diagnostics {}.Append (
378+ & hcl.Diagnostic {
379+ Severity : hcl .DiagError ,
380+ Summary : "Invalid depends_on reference" ,
381+ Detail : "Actions can not be referenced in depends_on. Use depends_on on the resource that triggers the action instead." ,
382+ Subject : & hcl.Range {
383+ Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
384+ Start : hcl.Pos {Line : 9 , Column : 17 , Byte : 129 },
385+ End : hcl.Pos {Line : 9 , Column : 48 , Byte : 160 },
386+ },
387+ })
388+ },
389+ },
390+
322391 "destroy run" : {
323392 module : map [string ]string {
324393 "main.tf" : `
0 commit comments