aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.51k stars 1.17k forks source link

Bug: CLI can not interpret AWS Terraform conditional statements. #6407

Closed yemi-gbenebor closed 11 months ago

yemi-gbenebor commented 11 months ago

Description:

I have followed the suggested setup using: https://github.com/aws-samples/aws-sam-terraform-examples/blob/main/ga/api_gateway_v1/tf-resources/functions.tf

When I run sam local start-lambda, I get the following error:

Error: An error occurred when attempting to link two resources: Could not use the value each.value.authorizer.enabled as a destination for the source resource module.api.aws_apigatewayv2_route.route. The expected destination resources should be of destination resource type aws_apigatewayv2_authorizer. using id property.

This is due to a TF conditional statement, I would expect SAM CLI to download the TD module used and correctly interpret conditional instead, it thinks the conditional is the input value.

Steps to reproduce:

Observed result:

Expected result:

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS:
  2. sam --version:
  3. AWS region:
# Paste the output of `sam --info` here

Add --debug flag to command you are running

github-actions[bot] commented 11 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.