Skip to content
New issue

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

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

Already on GitHub? # to your account

Template error: Fn::Select cannot select nonexistent value at index... #30308

Open
2 tasks
ThePlenkov opened this issue May 22, 2024 · 4 comments
Open
2 tasks
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@ThePlenkov
Copy link

Describe the feature

Currently when applying template which is using functions like !Select we may have an error like this:

ERROR   2024-05-22 16:14:18    Unexpected error: 
ERROR   2024-05-22 16:14:18    An error occurred (ValidationError) when calling the CreateStack operation: Template error: Fn::Select  cannot select nonexistent value at index 2
ERROR   2024-05-22 16:14:18    CommandExecution failed with exit code: (1)

This is not clear what is going wrong here. We have a large template and it would be great if cdk would print more informative message pointing to the exact place in the file causing the error.

Do you think it's possible? Thanks!

Use Case

Applying published template from yaml file using functions like !Select

Proposed Solution

Printing line number of the template file for the failed function would be already enough. Ideally there must be some debug/trace feature allowing us to debug template execution.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.142.1 (build ed4e152)

Environment details (OS name and version, etc.)

Ubuntu 23.10

@ThePlenkov ThePlenkov added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 22, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label May 22, 2024
@khushail khushail self-assigned this May 22, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels May 22, 2024
@pahud
Copy link
Contributor

pahud commented May 22, 2024

What are you trying to do with that template using CDK? Can you share your CDK code and the commands you executed?

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 22, 2024
@ThePlenkov
Copy link
Author

Well I do something like this:

 new CfnInclude(this, 'solace-task-definition', {
      templateFile: 'solace.template',
      parameters: {
        KeyPairName: keyPairName,
        VPCID: vpc.vpcId,
        PrivateSubnetIDs: taskSubnets.subnetIds,
        PublicSubnetIDs: [],
        SSHSecurityGroupID: sg.securityGroupId,
        RemoteAccessCIDR: '0.0.0.0/0',
        AdminPassword: secret.secretValueFromJson('password').unsafeUnwrap(),
        WorkerNodeInstanceType: `t2.small`,
        MonitorNodeInstanceType: `t2.small`,
        NumberOfAZs: 2,
      },
    });

@ThePlenkov
Copy link
Author

in my case I was already able to read the template manually and find the location of !Select function and to review the logic. Currently I was able to solve the error itself. But this ticket is just about the experience. I would prefer if cdk would already pointed me to the exact place in the file which was causing the error.

@pahud
Copy link
Contributor

pahud commented May 22, 2024

I would prefer if cdk would already pointed me to the exact place in the file which was causing the error.

Totally agree. Let's make it a feature request for CfnInclude for verbose log.

@pahud pahud added p2 effort/medium Medium work item – several days of effort @aws-cdk/core Related to core CDK functionality and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. @aws-cdk/aws-lambda Related to AWS Lambda labels May 22, 2024
@khushail khushail removed their assignment May 22, 2024
@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants