Aws-sam-cli: Hello World tutorial deploy error: KeyError: 'Outputs'

Created on 4 Dec 2019  路  11Comments  路  Source: aws/aws-sam-cli

Description

KeyError: 'Outputs' is encountered following the steps in "Tutorial: Deploying a Hello World Application"

Steps to reproduce

$ mkdir test && cd test
$ sam init
Which template source would you like to use?
    1 - AWS Quick Start Templates
    2 - Custom Template Location
Choice: 1

Which runtime would you like to use?
    1 - nodejs12.x
    2 - python3.8
    3 - ruby2.5
    4 - go1.x
    5 - java11
    6 - dotnetcore2.1
    7 - nodejs10.x
    8 - nodejs8.10
    9 - nodejs6.10
    10 - python3.7
    11 - python3.6
    12 - python2.7
    13 - java8
    14 - dotnetcore2.0
    15 - dotnetcore1.0
Runtime: 1

Project name [sam-app]:

Quick start templates may have been updated. Do you want to re-download the latest [Y/n]:

-----------------------
Generating application:
-----------------------
Name: sam-app
Runtime: nodejs12.x
Dependency Manager: npm
Application Template: hello-world
Output Directory: .

Next steps can be found in the README file at ./sam-app/README.md

$ cd sam-app/
$ sam build
Building resource 'HelloWorldFunction'
Running NodejsNpmBuilder:NpmPack
Running NodejsNpmBuilder:CopyNpmrc
Running NodejsNpmBuilder:CopySource
Running NodejsNpmBuilder:NpmInstall
Running NodejsNpmBuilder:CleanUpNpmrc

Build Succeeded

Built Artifacts  : .aws-sam/build
Built Template   : .aws-sam/build/template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided

$ export SAM_CLI_TELEMETRY=0
$ sam deploy --guided --debug

Configuring SAM deploy
======================

    Looking for samconfig.toml :  Not found

    Setting default arguments for 'sam deploy'
    =========================================
    Stack Name [sam-app]:
    AWS Region [us-east-1]: us-east-2
    #Shows you resources changes to be deployed and require a 'Y' to initiate deploy
    Confirm changes before deploy [y/N]:
    #SAM needs permission to be able to create roles to connect to the resources in your template
    Allow SAM CLI IAM role creation [Y/n]:
    Save arguments to samconfig.toml [Y/n]:

    Looking for resources needed for deployment: Found!
Traceback (most recent call last):
  File "/usr/local/bin/sam", line 11, in <module>
    load_entry_point('aws-sam-cli==0.36.0', 'console_scripts', 'sam')()
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/samcli/lib/telemetry/metrics.py", line 48, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/samcli/commands/deploy/command.py", line 187, in cli
    ctx.profile,
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/samcli/commands/deploy/command.py", line 235, in do_cli
    stack_name, s3_bucket, region, profile, confirm_changeset, _parameter_override_keys, parameter_overrides
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/samcli/commands/deploy/command.py", line 335, in guided_deploy
    s3_bucket = manage_stack(profile=profile, region=region)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/samcli/lib/bootstrap/bootstrap.py", line 37, in manage_stack
    return _create_or_get_stack(cloudformation_client)
  File "/usr/local/Cellar/aws-sam-cli/0.36.0/libexec/lib/python3.7/site-packages/samcli/lib/bootstrap/bootstrap.py", line 71, in _create_or_get_stack
    outputs = stack["Outputs"]
KeyError: 'Outputs'

$ echo $SAM_CLI_TELEMETRY
0
$ aws --version
aws-cli/1.16.290 Python/3.7.5 Darwin/17.7.0 botocore/1.13.26

Expected result

Stack is deployed

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

  1. OS: MacOS 10.13.6
    2.
$ sam --version
SAM CLI, version 0.36.0
aredeploy aremanaged-stack

All 11 comments

Do you have the managed stack already deployed on your account, it should be named aws-sam-cli-managed-default

Does that stack have outputs defined that are viewable in cloudformation console?

@TheSriram Yes, aws-sam-cli-managed-default is deployed. It has no outputs listed in the console.

So is aws-sam-cli-managed-default related to the new deploy where I have specified a different stack name? e.g. sam-app-3

The aws-sam-cli-managed-default stack was rolled back a couple of days ago:

2019-12-02 18:54:07 UTC-0500 | SamCliSourceBucket | CREATE_FAILED | API: s3:PutBucketVersioning Access Denied

The member account being used is restricted under an organization service control policy. We have been granting access as needed. I have now just added s3:Put/GetBucketVersioning. Should I delete the aws-sam-cli-managed-default stack?

Ah, it appears that aws-sam-cli-managed-default is used for the improved/auto packaging that sam cli now performs for us.

Correct, that stack needs to be in a state where sam cli can access it. I would delete that stack and let sam cli re-create it, as long as you have the appropriate permissions present.

Important note: if you already have packaged artifacts within that bucket, I would suggest retaining the bucket so that existing deployed SAM apps that are referencing your current bucket do not break.

I deleted the stack. Primarily it appears that adding the required permissions has resolved the issue. Thanks @TheSriram!

For me, this error was caused by using a duplicate StackName in the sam deploy --guided. Once I made the StackName unique, everything just worked.

@ggriffin - Could you tell me what permissions you added? I am facing the same issue.

Me Too!

@adheesh24, @jwilleke adding AdminstratorAccess existing policy to my user fixed it. Not sure if this is the best way to do it.

Was this page helpful?
0 / 5 - 0 ratings