Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The false result value has the wrong type #27

Closed
wants to merge 2 commits into from

Conversation

faresz
Copy link

@faresz faresz commented Dec 3, 2021

Description

Whenever you define your service_integrations and set create_role && attach_policies_for_integrations to false, you expect to have an empty map to skip the appropriate blocks and resources to be created within the module.
Therefore Terraform will throw an exception for not accepting different map structure within the same condition. The first one with your key/values you are providing and the second one is an empty map.

When executing terraform plan the below error appears:

│   on .terraform/modules/step_function/main.tf line 123, in resource "aws_iam_policy_attachment" "service":
│  85:   for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
│ 
│ The false result value has the wrong type: map has no element for required attribute "lambda".

Used variables in order to reproduce it.


module "step_function" {
  . . . 

  create_role = false 
  attach_policies_for_integrations = false

  service_integrations = {

    lambda = {
      lambda = [. . . .]
    }

    xray = {
      xray = true
    }
}

. . . 

}

Motivation and Context

This change keeps the same logic behind the conditions and resources creation, it's simply a different way of using values and condition with the for_each.
With this solution we create our map whenever we have values, and it skips the block when the condition is not met.

Breaking Changes

There no really breaking changes

TF condition cannot accept different map structures from the left and right results of the condition.
var.service_integrations expected to be dynamic
@github-actions
Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Jan 11, 2022
@faresz faresz changed the title Fix: The false result value has the wrong type fix: The false result value has the wrong type Jan 11, 2022
@faresz
Copy link
Author

faresz commented Jan 11, 2022

Remove stale label

@antonbabenko
Copy link
Member

Fixed in #30.

Thank you very much!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants