Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

Note: You are viewing the documentation for an older major version of the AWS CLI (version 1).

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.

[ aws . opsworks ]

create-deployment

Description

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

See 'aws help' for descriptions of global parameters.

Synopsis

  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>]

Options

--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 an Args parameter named recipes to the list of recipes to be executed. For example, to execute phpapp::appsetup , set Args 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 optional Args parameter named migrate . Set Args 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, AWS 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 desired Amazon Linux version for instances whose OS you want to upgrade, such as Amazon Linux 2016.09 . You must also set the allow_reboot argument to true.
  • allow_reboot - Specifies whether to allow AWS OpsWorks Stacks to reboot the instances if necessary, after installing the updates. This argument can be set to either true or false . The default value is false .

For example, to upgrade an instance to Amazon Linux 2016.09, set Args to the following.

{ "upgrade_os_to":["Amazon Linux 2016.09"], "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.

See 'aws help' for descriptions of global parameters.

Examples

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.

Output

DeploymentId -> (string)

The deployment ID, which can be used with other requests to identify the deployment.