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

Creating a lambda with lambda_role_arn instead of role_name is failing #370

Closed
himanshu-agarwl opened this issue Oct 31, 2022 · 2 comments · Fixed by #371
Closed

Creating a lambda with lambda_role_arn instead of role_name is failing #370

himanshu-agarwl opened this issue Oct 31, 2022 · 2 comments · Fixed by #371

Comments

@himanshu-agarwl
Copy link

Description

Hi Team,

The change merged today 7df6bbf seems to break lambda creation when the IAM role is not getting created via module. We do pass

lambda_role   = data.aws_iam_role.service.arn
create_role   = false

and getting error

╷
│ Error: Error in function call
│ 
│   on .terraform/modules/braze_webhook_lambda/iam.tf line 15, in locals:
│   15:   policy_name = coalesce(var.policy_name, local.role_name)
│     ├────────────────
│     │ local.role_name is null
│     │ var.policy_name is null
│ 
│ Call to function "coalesce" failed: no non-null, non-empty-string
│ arguments.

This is because we don't expect module to create the role and thus don't pass role_name or policy_name and both of them are null which coalesce is complaining about.

Versions

  • Module version [Required]:

  • Terraform version:
    Terraform v1.2.8
    on darwin_amd64

  • Provider version(s):

  • provider registry.terraform.io/hashicorp/aws v4.37.0
  • provider registry.terraform.io/hashicorp/external v2.2.2
  • provider registry.terraform.io/hashicorp/local v2.2.3
  • provider registry.terraform.io/hashicorp/null v3.2.0

Reproduction Code [Required]

module "braze_consumer_lambda" {
  source = "terraform-aws-modules/lambda/aws"

  function_name = <name of function>
  description   = "Sends events to braze"
  handler       = "main.lambda_handler"
  runtime       = "python3.8"
  lambda_role   = <role-arn>
  create_role   = false

  timeout                = 30
  create_package         = false
  local_existing_package = <path>

  tags = {
    Name = local.braze_consumer_lambda_name
  }
}

Steps to reproduce the behavior:

yes yes running terraform apply with latest module and reproducible code should reproduce the issue.

Expected behavior

Expected to set policy_name to null when create_role is false.

Actual behavior

Applying the module errors out with

╷
│ Error: Error in function call
│ 
│   on .terraform/modules/braze_webhook_lambda/iam.tf line 15, in locals:
│   15:   policy_name = coalesce(var.policy_name, local.role_name)
│     ├────────────────
│     │ local.role_name is null
│     │ var.policy_name is null
│ 
│ Call to function "coalesce" failed: no non-null, non-empty-string
│ arguments.

Terminal Output Screenshot(s)

Additional context

@antonbabenko
Copy link
Member

This issue has been resolved in version 4.4.1 🎉

@github-actions
Copy link

github-actions bot commented Dec 1, 2022

I'm going to lock this issue 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 similar to this, 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 Dec 1, 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 a pull request may close this issue.

2 participants