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.5k stars 1.17k forks source link

Bug: sam deploy - KeyError #7255

Closed fszostak closed 2 months ago

fszostak commented 2 months ago

During a deploy process my hard disk is full. and then this error started to occur.

❯ sam deploy --config-env qas --profile xxx-qas --region us-east-1 --guided --debug 2024-07-17 19:27:09,113 | No config file found in this directory.
2024-07-17 19:27:09,118 | OSError occurred while reading TOML file:
[Errno 2] No such file or directory:
'/storage/Workspaces/myapp/xxx-dashboard/app/samconfig.toml'
2024-07-17 19:27:09,120 | Config file location:
/storage/Workspaces/myapp/xxx-dashboard/app/samconfig.toml
2024-07-17 19:27:09,121 | Config file
'/storage/Workspaces/myapp/xxx-dashboard/app/samconfig.toml' does
not exist
2024-07-17 19:27:09,128 | Using SAM Template at
/storage/Workspaces/myapp/xxx-dashboard/app/.aws-sam/build/template. yaml
2024-07-17 19:27:09,163 | OSError occurred while reading TOML file:
[Errno 2] No such file or directory:
'/storage/Workspaces/myapp/xxx-dashboard/app/samconfig.toml'
2024-07-17 19:27:09,169 | Using config file: samconfig.toml, config
environment: qas
2024-07-17 19:27:09,171 | Expand command line arguments to:
2024-07-17 19:27:09,172 | --guided
--template_file=/storage/Workspaces/myapp/xxx-dashboard/app/.aws-sam /build/template.yaml --fail_on_empty_changeset --on_failure=ROLLBACK
--stack_name=sam-app
2024-07-17 19:27:09,518 | Sam customer defined id is more priority
than other IDs. Customer defined id for resource XxxAppStackFunction
is XxxAppStackFunction
2024-07-17 19:27:09,519 | OSError occurred while reading TOML file:
[Errno 2] No such file or directory:
'/storage/Workspaces/myapp/xxx-dashboard/app/samconfig.toml'
2024-07-17 19:27:09,521 | OSError occurred while reading TOML file:
[Errno 2] No such file or directory:
'/storage/Workspaces/myapp/xxx-dashboard/app/samconfig.toml'

Configuring SAM deploy

    Looking for config file [samconfig.toml] :  Not found

    Setting default arguments for 'sam deploy'
    =========================================
    Stack Name [sam-app]: 
    AWS Region [us-east-1]: 

2024-07-17 19:27:11,778 | No Parameters detected in the template
2024-07-17 19:27:11,815 | Sam customer defined id is more priority
than other IDs. Customer defined id for resource XxxAppStackFunction
is XxxAppStackFunction
2024-07-17 19:27:11,816 | There is no customer defined id or cdk path defined for resource ServerlessHttpApi, so we will use the resource
logical id as the resource id
2024-07-17 19:27:11,819 | 0 stacks found in the template

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]: 
    #Preserves the state of previously provisioned resources when an operation fails
    Disable rollback [y/N]: 

2024-07-17 19:27:14,230 | No Parameters detected in the template
2024-07-17 19:27:14,262 | Sam customer defined id is more priority
than other IDs. Customer defined id for resource XxxAppStackFunction
is XxxAppStackFunction
2024-07-17 19:27:14,263 | There is no customer defined id or cdk path defined for resource ServerlessHttpApi, so we will use the resource
logical id as the resource id
2024-07-17 19:27:14,265 | 2 resources found in the stack
2024-07-17 19:27:14,267 | Found Serverless function with
name='XxxAppStackFunction' and ImageUri='xxxappstackfunction:v2'
2024-07-17 19:27:14,268 | --base-dir is not presented, adjusting uri
/storage/Workspaces/myapp/xxx-dashboard/app relative to
/storage/Workspaces/myapp/xxx-dashboard/app/.aws-sam/build/template. yaml
2024-07-17 19:27:14,270 | --base-dir is not presented, adjusting uri . relative to
/storage/Workspaces/myapp/xxx-dashboard/app/.aws-sam/build/template. yaml
2024-07-17 19:27:14,271 | Detected Inline Swagger definition
2024-07-17 19:27:14,272 | Auth checks done on swagger are not
exhaustive!
XxxAppStackFunction has no authentication. Is this okay? [y/N]: y 2024-07-17 19:27:22,115 | 2 resources found in the stack
2024-07-17 19:27:22,117 | Found Serverless function with
name='XxxAppStackFunction' and ImageUri='xxxappstackfunction:v2'
2024-07-17 19:27:22,118 | --base-dir is not presented, adjusting uri
/storage/Workspaces/myapp/xxx-dashboard/app relative to
/storage/Workspaces/myapp/xxx-dashboard/app/.aws-sam/build/template. yaml
2024-07-17 19:27:22,120 | --base-dir is not presented, adjusting uri . relative to
/storage/Workspaces/myapp/xxx-dashboard/app/.aws-sam/build/template. yaml
2024-07-17 19:27:22,121 | No function or layer definition found with
code sign config, skipping
Save arguments to configuration file [Y/n]: SAM configuration file [samconfig.toml]: SAM configuration environment [qas]:

    Looking for resources needed for deployment:

2024-07-17 19:27:25,874 | Telemetry endpoint configured to be
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics 2024-07-17 19:27:25,885 | Telemetry endpoint configured to be
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics 2024-07-17 19:27:25,886 | Sending Telemetry: {'metrics':
[{'commandRun': {'requestId': 'e5d69999-931b-48c3-a5db-735d70c627ae', 'installationId': '1aa0f353-70ea-4f8c-85f2-33b37045cb5c', 'sessionId': 'b9d9c19c-782e-4a24-8a14-f1f11e8ab714', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.8', 'samcliVersion': '1.120.0',
'awsProfileProvided': True, 'debugFlagProvided': True, 'region':
'us-east-1', 'commandName': 'sam deploy', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName':
'a172cedcae47474b615c54d510a5d84a8dea3032e958587430b413538be3f333',
'initialCommit': None}, 'duration': 16704, 'exitReason': 'KeyError',
'exitCode': 255}}]}
2024-07-17 19:27:25,886 | Unable to find Click Context for getting
session_id.
2024-07-17 19:27:25,893 | Sending Telemetry: {'metrics': [{'events':
{'requestId': '115045f4-f3bb-4963-b791-40206dc2f035',
'installationId': '1aa0f353-70ea-4f8c-85f2-33b37045cb5c', 'sessionId': 'b9d9c19c-782e-4a24-8a14-f1f11e8ab714', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.8', 'samcliVersion': '1.120.0',
'commandName': 'sam deploy', 'metricSpecificAttributes': {'events':
[{'event_name': 'SamConfigFileExtension', 'event_value': '.toml',
'thread_id': 'eefef0db83a4496da55dea18a034d391', 'time_stamp':
'2024-07-17 22:27:09.120', 'exception_name': None}, {'event_name':
'SamConfigFileExtension', 'event_value': '.toml', 'thread_id':
'8c0e13c292ad4593a505de1bb1af436f', 'time_stamp': '2024-07-17
22:27:09.164', 'exception_name': None}, {'event_name':
'SamConfigFileExtension', 'event_value': '.toml', 'thread_id':
'f27efbd68496441397103d8e2e9087c2', 'time_stamp': '2024-07-17
22:27:09.520', 'exception_name': None}]}}}]}
2024-07-17 19:27:26,620 |
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.ama zonaws.com', port=443): Read timed out. (read timeout=0.1)
2024-07-17 19:27:26,676 |
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.ama zonaws.com', port=443): Read timed out. (read timeout=0.1)

Error: '1c483978ad07893b430e5d0e5c472b4499ed37c5' Traceback: File "click/core.py", line 1078, in main File "click/core.py", line 1688, in invoke File "click/core.py", line 1434, in invoke File "click/core.py", line 783, in invoke File "samcli/cli/cli_config_file.py", line 347, in wrapper File "samcli/lib/cli_validation/image_repository_validation.py", line 111, in wrapped File "click/decorators.py", line 92, in new_func File "click/core.py", line 783, in invoke File "samcli/lib/telemetry/metric.py", line 185, in wrapped File "samcli/lib/telemetry/metric.py", line 150, in wrapped File "samcli/lib/utils/version_checker.py", line 43, in wrapped File "samcli/cli/main.py", line 95, in wrapper File "samcli/commands/_utils/cdk_support_decorators.py", line 40, in wrapped File "samcli/commands/_utils/command_exception_handler.py", line 89, in wrapper_command_exception_handler File "samcli/commands/_utils/command_exception_handler.py", line 69, in wrapper_command_exception_handler File "samcli/commands/deploy/command.py", line 201, in cli File "samcli/commands/deploy/command.py", line 295, in do_cli File "samcli/commands/deploy/guided_context.py", line 576, in run File "samcli/commands/deploy/guided_context.py", line 184, in guided_prompts File "samcli/lib/bootstrap/bootstrap.py", line 23, in manage_stack File "samcli/lib/utils/managed_cloudformation_stack.py", line 146, in manage_stack File "samcli/lib/utils/managed_cloudformation_stack.py", line 157, in _create_or_get_stack File "botocore/client.py", line 565, in _api_call File "botocore/client.py", line 1001, in _make_api_call File "botocore/client.py", line 1027, in _make_request File "botocore/endpoint.py", line 119, in make_request File "botocore/endpoint.py", line 198, in _send_request File "botocore/endpoint.py", line 134, in create_request File "botocore/hooks.py", line 412, in emit File "botocore/hooks.py", line 256, in emit File "botocore/hooks.py", line 239, in _emit File "botocore/signers.py", line 105, in handler File "botocore/signers.py", line 190, in sign File "botocore/signers.py", line 310, in get_auth_instance File "botocore/credentials.py", line 634, in get_frozen_credentials File "botocore/credentials.py", line 522, in _refresh File "botocore/credentials.py", line 538, in _protected_refresh File "botocore/credentials.py", line 685, in fetch_credentials File "botocore/credentials.py", line 693, in _get_cached_credentials File "botocore/credentials.py", line 711, in _load_from_cache File "botocore/utils.py", line 3511, in getitem

An unexpected error was encountered while executing "sam deploy". Search for an existing issue: https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20deploy%20-%20KeyError Or create a bug report: https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20deploy%20-%20KeyError

HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com ', port=443): Read timed out. (read timeout=0.1)

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

  1. OS: Ubuntu 24.04
  2. sam --version: SAM CLI, version 1.120.0
  3. AWS region: us-east-1
{
  "version": "1.120.0",
  "system": {
    "python": "3.11.8",
    "os": "Linux-6.8.0-38-generic-x86_64-with-glibc2.39"
  },
  "additional_dependencies": {
    "docker_engine": "27.0.3",
    "aws_cdk": "Not available",
    "terraform": "1.9.2"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
fszostak commented 2 months ago

I solve this clean cache with

rm ~/.aws/boto/cache/*

github-actions[bot] commented 2 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.