Execute a Recipe (create-deployment) - AWS OpsWorks

Execute a Recipe (create-deployment)

Important

AWS OpsWorks Stacks is no longer accepting new customers. Existing customers will be able to use the OpsWorks console, API, CLI, and CloudFormation resources as normal until May 26, 2024, at which time they will be discontinued. To prepare for this transition, we recommend you transition your stacks to AWS Systems Manager as soon as possible. For more information, see AWS OpsWorks Stacks End of Life FAQs and Migrating your AWS OpsWorks Stacks applications to AWS Systems Manager Application Manager.

Use the create-deployment command to execute stack commands and deployment commands. The following example executes a stack command to run a custom recipe on a specified stack.

aws opsworks --region us-west-1 create-deployment --stack-id 935450cc-61e0-4b03-a3e0-160ac817d2bb --command "{\"Name\":\"execute_recipes\", \"Args\":{\"recipes\":[\"phpapp::appsetup\"]}}"

The command argument takes a JSON object that is formatted as follows:

  • Name - Specifies the command name. The execute_recipes command used for this example executes a specified recipe on the stack's instances.

  • Args - Specifies a list of arguments and their values. This example has one argument, recipes, which is set to the recipe to be executed, phpapp::appsetup.

Notice that the " characters in the JSON object are all escaped. Otherwise, the command might return an error that the JSON is invalid.

The command returns a deployment ID, which you can use to identify the command for other CLI commands such as describe-commands.

{ "DeploymentId": "5cbaa7b9-4e09-4e53-aa1b-314fbd106038" }