[ aws . topics ]

AWS CLI Return Codes

These are the following return codes returned at the end of execution of a CLI command:

  • 0 – Command was successful. There were no errors thrown by either the CLI or by the service the request was made to.

  • 1 – Limited to s3 commands, at least one or more s3 transfers failed for the command executed.

  • 2 – The meaning of this return code depends on the command being run.

    The primary meaning is that the command entered on the command line failed to be parsed. Parsing failures can be caused by, but are not limited to, missing any required subcommands or arguments or using any unknown commands or arguments. Note that this return code meaning is applicable to all CLI commands.

    The other meaning is only applicable to s3 commands. It can mean at least one or more files marked for transfer were skipped during the transfer process. However, all other files marked for transfer were successfully transferred. Files that are skipped during the transfer process include: files that do not exist, files that are character special devices, block special device, FIFOs, or sockets, and files that the user cannot read from.

  • 130 – The process received a SIGINT (Ctrl-C).

  • 252 – Command syntax was invalid, an unknown parameter was provided, or a parameter value was incorrect and prevented the command from running.

  • 253 – The system environment or configuration was invalid. While the command provided may be syntactically valid, missing configuration or credentials prevented the command from running.

  • 254 – The command was successfully parsed and a request was made to the specified service but the service returned an error. This will generally indicate incorrect API usage or other service specific issues.

  • 255 – General catch-all error. The command may have parsed correctly but an unspecified runtime error occurred when running the command. Because this is a general error code, an error may change from 255 to a more specific return code. A return code of 255 should not be relied on to determine a specific error case.

amplifygen3 commands also return the following codes. Codes 252, 253, 254 and 255 keep the meanings listed above.

  • 10 – The command succeeded, but the resource or change it reports on has not reached its final state yet. For example, domain verify found a domain that is still being verified, or a command stopped waiting before a change finished. Nothing failed. Wait and check again, or run the command with --watch. In a CI environment, a --watch without --timeout can stop waiting after 60 seconds and return this code. Pass --timeout to wait longer.
  • 11 – The command succeeded, and the resource is being deleted. For example, domain verify found a domain that is being removed.
  • 243 – No response was received from the service, so the outcome is unknown. The request may already have taken effect. Check the state of the resource before you retry a command that makes a change.
  • 244 – The service could not be reached, so it did not receive the request. For example, the connection was refused or timed out, or the endpoint could not be resolved. Retrying is safe. If the error says that the service is not available in the Region, use a different Region.
  • 245 – The service failed internally. Retrying may succeed.
  • 246 – The service throttled the request. Retrying after a delay may succeed.
  • 247 – A service quota was reached. Retrying does not help until the quota is increased.
  • 248 – The resource already exists, or its current state does not allow the request.
  • 249 – A resource named in the command, such as an app, environment or domain, was not found.
  • 250 – The service accepted the credentials but denied permission for the operation. Unlike 253, the credentials themselves were valid.
  • 251 – The service rejected the request, usually because a parameter value failed the service’s validation. Unlike 252, the request reached the service.

Codes 10 and 11 report a state, not an error, but they are non-zero. A command chained with && does not run, and a script that uses set -e stops. To branch on the state itself, read it from the --output json output instead of the return code.

For a service error not listed above, amplifygen3 commands return 254. A command that needs confirmation returns 252 when it cannot prompt and --yes was not passed. Commands that run another program exit with that program’s code: local run with the dev server’s code, and local db connect and backend db connect with the code of psql.

To determine the return code of a command, run the following right after running a CLI command. Note that this will work only on POSIX systems:

$ echo $?

Output (if successful):

0

On Windows PowerShell, the return code can be determined by running:

> echo $lastexitcode

Output (if successful):

0

On Windows Command Prompt, the return code can be determined by running:

> echo %errorlevel%

Output (if successful):

0