Hello there,
Just wonder if someone faced such issue before and have some clear explanation.
I can’t find exact cause in documentation, sorry…
Context:
Doing code migration from 0.14.11
directly to 1.1.2
.
We have 140ish modules so bypassing 0.15 and 1.0.0.
During planning faced following issue struggling to explain.
Issue:
- Have working module on
0.14.11
version resulting intoPlan: 0 to add, 14 to change, 0 to destroy
- Running same code on
1.1.2
result intoInconsistent conditional result types
error:
Error: Inconsistent conditional result types
│
│ on main.tf line 71, in locals:
│ 71: detail = type_key == "sfn" ? {
│ 72: status = state
│ 73: stateMachineArn = type.event_template.detail.stateMachineArn
│ 74: } : type_key == "codebuild" ? {
│ 75: build-status = state
│ 76: project-name = type.event_template.detail.project-name
│ 77: } : {}
│ ├────────────────
│ │ type.event_template.detail.stateMachineArn is tuple with 1 element
│
│ The true result value has the wrong type: element types must all match for conversion to map.
- Flattening is kind odd but don’t judge me on that
cw_notify_events = flatten([
for type_key, type in local.notification_types : [
for state_key, state in type.states : [
for index in range(0, lookup(var.event_rules_count, type_key, 1)) : {
type = type_key
name = join("-", [type_key, state_key, index])
template = {
source = type.event_template.source
detail-type = type.event_template.detail-type
detail = type_key == "sfn" ? {
status = state
stateMachineArn = type.event_template.detail.stateMachineArn
} : type_key == "codebuild" ? {
build-status = state
project-name = type.event_template.detail.project-name
} : {}
}
}
]
]
])
- indeed notification_types holds stateMachineArn as list with one element.
notification_types = {
sfn = {
states = {
start = ["RUNNING"]
success = ["SUCCEEDED"]
failure = [
"ABORTED",
"FAILED",
"TIMED_OUT"
]
}
event_template = {
source = ["aws.states"]
detail-type = ["Step Functions Execution Status Change"]
detail = {
status = []
stateMachineArn = [local.stub_sfn_arn]
}
}
}
codebuild = {
states = {
start = ["IN_PROGRESS"]
success = ["SUCCEEDED"]
failure = [
"FAILED",
"STOPPED"
]
}
event_template = {
source = ["aws.codebuild"]
detail-type = ["CodeBuild Build State Change"]
detail = {
build-status = []
project-name = [local.stub_codebild_project]
}
}
}
}
Question
With new version 1.1.2
clear exception, to remediate you need access by index.
But how it works on 0.14.11
?
Don’t want to catch some pitfall in production
Thanks,
Serhii