AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. For more information see the AWS CLI version 2 installation instructions and migration guide.
Runs deployment or stack commands. For more information, see Deploying Apps and Run Stack Commands .
Required Permissions : To use this action, an IAM user must have a Deploy or Manage permissions level for the stack, or an attached policy that explicitly grants permissions. For more information on user permissions, see Managing User Permissions .
See also: AWS API Documentation
create-deployment
--stack-id <value>
[--app-id <value>]
[--instance-ids <value>]
[--layer-ids <value>]
--command <value>
[--comment <value>]
[--custom-json <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
--stack-id
(string)
The stack ID.
--app-id
(string)
The app ID. This parameter is required for app deployments, but not for other deployment commands.
--instance-ids
(list)
The instance IDs for the deployment targets.
(string)
Syntax:
"string" "string" ...
--layer-ids
(list)
The layer IDs for the deployment targets.
(string)
Syntax:
"string" "string" ...
--command
(structure)
A
DeploymentCommand
object that specifies the deployment command and any associated arguments.Name -> (string)
Specifies the operation. You can specify only one command.
For stacks, the following commands are available:
execute_recipes
: Execute one or more recipes. To specify the recipes, set anArgs
parameter namedrecipes
to the list of recipes to be executed. For example, to executephpapp::appsetup
, setArgs
to{"recipes":["phpapp::appsetup"]}
.install_dependencies
: Install the stack's dependencies.update_custom_cookbooks
: Update the stack's custom cookbooks.update_dependencies
: Update the stack's dependencies.Note
The update_dependencies and install_dependencies commands are supported only for Linux instances. You can run the commands successfully on Windows instances, but they do nothing.For apps, the following commands are available:
deploy
: Deploy an app. Ruby on Rails apps have an optionalArgs
parameter namedmigrate
. SetArgs
to {"migrate":["true"]} to migrate the database. The default setting is {"migrate":["false"]}.rollback
Roll the app back to the previous version. When you update an app, OpsWorks Stacks stores the previous version, up to a maximum of five versions. You can use this command to roll an app back as many as four versions.start
: Start the app's web or application server.stop
: Stop the app's web or application server.restart
: Restart the app's web or application server.undeploy
: Undeploy the app.Args -> (map)
The arguments of those commands that take arguments. It should be set to a JSON object with the following format:
{"arg_name1" : ["value1", "value2", ...], "arg_name2" : ["value1", "value2", ...], ...}
The
update_dependencies
command takes two arguments:
upgrade_os_to
- Specifies the Amazon Linux version that you want instances to run, such asAmazon Linux 2
. You must also set theallow_reboot
argument to true.allow_reboot
- Specifies whether to allow OpsWorks Stacks to reboot the instances if necessary, after installing the updates. This argument can be set to eithertrue
orfalse
. The default value isfalse
.For example, to upgrade an instance to Amazon Linux 2018.03, set
Args
to the following.{ "upgrade_os_to":["Amazon Linux 2018.03"], "allow_reboot":["true"] }
key -> (string)
value -> (list)
(string)
Shorthand Syntax:
Name=string,Args={KeyName1=string,string,KeyName2=string,string}
JSON Syntax:
{
"Name": "install_dependencies"|"update_dependencies"|"update_custom_cookbooks"|"execute_recipes"|"configure"|"setup"|"deploy"|"rollback"|"start"|"stop"|"restart"|"undeploy",
"Args": {"string": ["string", ...]
...}
}
--comment
(string)
A user-defined comment.
--custom-json
(string)
A string that contains user-defined, custom JSON. You can use this parameter to override some corresponding default stack configuration JSON values. The string should be in the following format:
"{\"key1\": \"value1\", \"key2\": \"value2\",...}"
For more information about custom JSON, see Use Custom JSON to Modify the Stack Configuration Attributes and Overriding Attributes With Custom JSON .
--cli-input-json
(string)
Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
--debug
(boolean)
Turn on debug logging.
--endpoint-url
(string)
Override command's default URL with the given URL.
--no-verify-ssl
(boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate
(boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output
(string)
The formatting style for command output.
--query
(string)
A JMESPath query to use in filtering the response data.
--profile
(string)
Use a specific profile from your credential file.
--region
(string)
The region to use. Overrides config/env settings.
--version
(string)
Display the version of this tool.
--color
(string)
Turn on/off color output.
--no-sign-request
(boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle
(string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout
(int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout
(int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal's quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
Example 1: To deploy apps and run stack commands
The following examples show how to use the create-deployment
command to deploy apps and run stack commands. Notice that the quote ("
) characters in the JSON object that specifies the command are all preceded by escape characters (\). Without the escape characters, the command might return an invalid JSON error.
The following create-deployment
example deploys an app to a specified stack.
aws opsworks create-deployment \
--stack-id cfb7e082-ad1d-4599-8e81-de1c39ab45bf \
--app-id 307be5c8-d55d-47b5-bd6e-7bd417c6c7eb
--command "{\"Name\":\"deploy\"}"
Output:
{
"DeploymentId": "5746c781-df7f-4c87-84a7-65a119880560"
}
Example 2: To deploy a Rails App and Migrate the Database
The following create-deployment
command deploys a Ruby on Rails app to a specified stack and migrates the database.
aws opsworks create-deployment \
--stack-id cfb7e082-ad1d-4599-8e81-de1c39ab45bf \
--app-id 307be5c8-d55d-47b5-bd6e-7bd417c6c7eb \
--command "{\"Name\":\"deploy\", \"Args\":{\"migrate\":[\"true\"]}}"
Output:
{
"DeploymentId": "5746c781-df7f-4c87-84a7-65a119880560"
}
For more information on deployment, see Deploying Apps in the AWS OpsWorks User Guide.
Example 3: Run a Recipe
The following create-deployment
command runs a custom recipe, phpapp::appsetup
, on the instances in a specified stack.
aws opsworks create-deployment \
--stack-id 935450cc-61e0-4b03-a3e0-160ac817d2bb \
--command "{\"Name\":\"execute_recipes\", \"Args\":{\"recipes\":[\"phpapp::appsetup\"]}}"
Output:
{
"DeploymentId": "5cbaa7b9-4e09-4e53-aa1b-314fbd106038"
}
For more information, see Run Stack Commands in the AWS OpsWorks User Guide.
Example 4: Install Dependencies
The following create-deployment
command installs dependencies, such as packages or Ruby gems, on the instances in a
specified stack.
aws opsworks create-deployment \
--stack-id 935450cc-61e0-4b03-a3e0-160ac817d2bb \
--command "{\"Name\":\"install_dependencies\"}"
Output:
{
"DeploymentId": "aef5b255-8604-4928-81b3-9b0187f962ff"
}
For more information, see Run Stack Commands in the AWS OpsWorks User Guide.
DeploymentId -> (string)
The deployment ID, which can be used with other requests to identify the deployment.