I am trying to import an aws_glue_trigger into my terraform state so I can see how this looks in the state file and create the full resource definition to go with it as a primer for doing all our ETL stuff in terraform.
I have imported the state with an empty resource holder fine, but I am unable to work out how the list syntax is meant to work in the resource definition.
For example in my state I have a trigger with a predicate with 3 conditions and a logical underneath it, which on completion of JOBS 1, 2 & 3 will run EXAMPLE_CRAWLER - relatively straightforward:-
{
"mode": "managed",
"type": "aws_glue_trigger",
"name": "EXAMPLE_TRIGGER",
"provider": "provider.aws",
"instances": [
{
"schema_version": 0,
"attributes": {
"actions": [
{
"arguments": {},
"crawler_name": "EXAMPLE_CRAWLER",
"job_name": "",
"timeout": 0
}
],
"arn": "arn:SOMEARN",
"description": "",
"enabled": true,
"id": "EXAMPLE_TRIGGER",
"name": "EXAMPLE_TRIGGER",
"predicate": [
{
"conditions": [
{
"crawl_state": "",
"crawler_name": "",
"job_name": "JOB1",
"logical_operator": "EQUALS",
"state": "SUCCEEDED"
},
{
"crawl_state": "",
"crawler_name": "",
"job_name": "JOB2",
"logical_operator": "EQUALS",
"state": "SUCCEEDED"
},
{
"crawl_state": "",
"crawler_name": "",
"job_name": "JOB3",
"logical_operator": "EQUALS",
"state": "SUCCEEDED"
}
],
"logical": "AND"
}
],
"schedule": "",
"tags": {},
"timeouts": {
"create": null,
"delete": null
},
"type": "CONDITIONAL",
"workflow_name": "EXAMPLE_WORKFLOW"
},
"private": "some_private_string"
}
]
}
According to docs predicate is defined as:-
predicate – (Optional) A predicate to specify when the new trigger should fire. Required when trigger type is CONDITIONAL. Defined below.
and args for predicate are defined as :-
conditions - (Required) A list of the conditions that determine when the trigger will fire. Defined below.
logical - (Optional) How to handle multiple conditions. Defaults to AND. Valid values are AND or ANY
Which matches the state output fine.
This is my latest iteration of trying to get this through the parser:-
resource "aws_glue_trigger" "EXAMPLE_TRIGGER" {
name = "EXAMPLE_TRIGGER"
type = "CONDITIONAL"
workflow_name = "EXAMPLE_WORKFLOW"
actions {
arguments = {}
crawler_name = "EXAMPLE_CRAWLER"
job_name = ""
timeout = 0
}
predicate {
conditions = [{
crawl_state = ""
crawler_name = ""
job_name = "JOB1"
logical_operator = "EQUALS"
state = "SUCCEEDED"
},
{
crawl_state = ""
crawler_name = ""
job_name = "JOB2"
logical_operator = "EQUALS"
state = "SUCCEEDED"
},
{
crawl_state = ""
crawler_name = ""
job_name = "JOB3"
logical_operator = "EQUALS"
state = "SUCCEEDED"
}]
logical = "AND"
}
}
This is giving me an error "Error: Argument or block definition required" which implies it wants me to put an equals after conditions
An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the argument value.
This is contrary to the docs and examples at the doc page
When I add the equals I get "Error: Unsupported argument"
An argument named "conditions" is not expected here. Did you mean to define a block of type "conditions"?
Asking me to take the equals back out again and define as a block?
Im confused and probably missing something simple - but any help would be much appreciated.