question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SAM local commands misbehave for CDK Templates synthesized in PowerShell

See original GitHub issue

Description

Operating on a Windows machine and using a Powershell terminal, when a user synthesizes a template from an AWS-CDK application, the output template does not behave as expected when invoking sam local commands.

Steps to reproduce

  1. Open a Powershell terminal
  2. Set the default out file encoding to utf8. See #1628 for details.

$PSDefaultParameterValues[‘Out-File:Encoding’] = ‘utf8’

  1. Synthesize a template from a CDK application.

cdk synth > template.yml

  1. Invoke a sam local command

sam local invoke MyFunction3BAA72D1 --debug

Observed result

The sam local commands fail with the error message

Error: [InvalidTemplateException(“‘Resources’ section is required”)] ‘Resources’ section is required

image

Expected result

I expected the lambda function to be executed in a container.

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

  1. OS: Windows 10 Enterprise
  2. sam --version: 0.41.0
  3. node: 12.14.1
  4. python 3.6.5

Interestingly when I synthesized the template from Git Bash instead of PowerShell, the sam local commands appeared to work as expected.

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
CoshUScommented, Jul 29, 2020

Possible Causes: Error: [InvalidTemplateException(“‘Resources’ section is required”)] ‘Resources’ section is required

UTF-8 BOM is included in the first line with “Resources”. The section name becomes “0xEF 0xBB 0xBF Resources:”.

Error: Failed to parse template: unacceptable character #x0000: special characters are not allowed in “<unicode string>”, position 3

Template is encoded in UTF-16 instead of UTF-8

1reaction
conork-datacomcommented, Jul 15, 2020

Any update on this? I get the following error when synthesizing a CDK template to be consumed by AWS SAM with Powershell via VSCode (on Win10)

Error: Failed to parse template: unacceptable character #x0000: special characters are not allowed in "<unicode string>", position 3

Works fine running the same commands in command prompt

SAM version : 0.49.0 CDK version: 1.51.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAM local commands misbehave for CDK Templates ...
Operating on a Windows machine and using a Powershell terminal, when a user synthesizes a template from an AWS-CDK application, the output ...
Read more >
Locally testing AWS CDK applications
Use the sam local command to locally test AWS CDK applications.
Read more >
devops | Noise | Page 2
A local installation of and experience using the AWS CDK. Create a baseline AWS CDK application. In this section you will create and...
Read more >
upF
Seducing drake palma pop fiction, Straw flag blank template, El perro opositor. ... Liverpool vs shamrock rovers squad, Boilermakers local 28, ...
Read more >
vocab
... 245 amazon.com 246 area 247 shop 248 pool 249 card 250 white 251 time 252 i 253 system 254 john 255 maps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found