While creating a sample application using AWS Cloud9, getting an error, not able to create application.

0

I am working on AWS Lambda workshop, while creating sample application in AWS Cloud9 I am getting error Error

Command to create sample application: sam init --runtime python3.7 --name sam-app

Here is a log: environment $ sam init --runtime python3.7 --name sam-app Which template source would you like to use? 1 - AWS Quick Start Templates 2 - Custom Template Location Choice: 1 Traceback (most recent call last): File "/usr/local/bin/sam", line 8, in <module> sys.exit(cli()) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in call return self.main(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/init.py", line 128, in wrapped return func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/samcli/lib/telemetry/metric.py", line 166, in wrapped raise exception # pylint: disable=raising-bad-type File "/usr/local/lib/python3.7/site-packages/samcli/lib/telemetry/metric.py", line 124, in wrapped return_value = func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/samcli/lib/utils/version_checker.py", line 41, in wrapped actual_result = func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/samcli/cli/main.py", line 87, in wrapper return func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/init.py", line 274, in cli extra_context, File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/init.py", line 359, in do_cli no_input, File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/interactive_init_flow.py", line 65, in do_interactive location_opt_choice, File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/interactive_init_flow.py", line 94, in generate_application architecture, File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/interactive_init_flow.py", line 134, in _generate_from_use_case runtime_or_base_image, app_template, package_type_filter_value, dependency_manager File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/init_templates.py", line 176, in get_preprocessed_manifest manifest_body = self._get_manifest() File "/usr/local/lib/python3.7/site-packages/samcli/commands/init/init_templates.py", line 221, in _get_manifest manifest_body = json.loads(body) File "/usr/lib64/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.7/json/decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 4 (char 3)

Any help is appreaciated.

asked 9 months ago377 views
2 Answers
1

I had been facing the same issue. I started off with this Lambda lab in the AWS Workshops and came across the same error.

I would just like to add that the answer was helpful. For me, the first option - updating the SAM CLI version - worked and the rest of the lab went on without a hitch.

pip install aws-sam-cli --upgrade

The other possible reasons could also affect the outcome of the lab.

answered 6 months ago
  • Thanks for posting this , AWS really needs to allow create bugs/ issues for the AWS workshops , Other day i was struggling for one of the other workshops related to AWS Glue

0
  • SAM CLI Version: Check the version of the SAM CLI you are using. AWS updates these tools frequently and sometimes older versions may not work as expected. To check the version, run sam --version. If your SAM CLI is not up-to-date, consider updating it using pip: pip install aws-sam-cli --upgrade.

  • JSON File: Check the JSON file that's being parsed. It appears the JSON file may have been improperly formatted, with some "extra" data. JSON files are particularly sensitive to correct syntax, so even a trailing comma or a misplaced bracket could cause an issue. You can use an online JSON validator to verify the file is properly formatted.

  • Internet Connection: SAM CLI downloads the templates from the internet. So, ensure you have a stable internet connection. If your network is unstable or slow, the downloaded JSON might be incomplete leading to the error.

  • Access rights: SAM CLI needs appropriate permissions to be able to create necessary resources for your app. Ensure you have the necessary permissions on your AWS account.

  • Cloud9 Environment: Sometimes, issues can arise from the specific Cloud9 environment. If everything else appears to be in order, you might try creating a new environment and running the command there.

profile picture
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions