OpsWorks / Client / create_deployment
create_deployment#
- OpsWorks.Client.create_deployment(**kwargs)#
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
Request Syntax
response = client.create_deployment( StackId='string', AppId='string', InstanceIds=[ 'string', ], LayerIds=[ 'string', ], Command={ 'Name': 'install_dependencies'|'update_dependencies'|'update_custom_cookbooks'|'execute_recipes'|'configure'|'setup'|'deploy'|'rollback'|'start'|'stop'|'restart'|'undeploy', 'Args': { 'string': [ 'string', ] } }, Comment='string', CustomJson='string' )
- Parameters:
StackId (string) –
[REQUIRED]
The stack ID.
AppId (string) – The app ID. This parameter is required for app deployments, but not for other deployment commands.
InstanceIds (list) –
The instance IDs for the deployment targets.
(string) –
LayerIds (list) –
The layer IDs for the deployment targets.
(string) –
Command (dict) –
[REQUIRED]
A
DeploymentCommand
object that specifies the deployment command and any associated arguments.Name (string) – [REQUIRED]
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 (dict) –
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"] }
(string) –
(list) –
(string) –
Comment (string) – A user-defined comment.
CustomJson (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.
- Return type:
dict
- Returns:
Response Syntax
{ 'DeploymentId': 'string' }
Response Structure
(dict) –
Contains the response to a
CreateDeployment
request.DeploymentId (string) –
The deployment ID, which can be used with other requests to identify the deployment.
Exceptions
OpsWorks.Client.exceptions.ValidationException
OpsWorks.Client.exceptions.ResourceNotFoundException