Version 5 (V5) of the Amazon Tools for PowerShell has been released!
For information about breaking changes and migrating your applications, see the migration topic.
Amazon OpsWorks examples using Tools for PowerShell V5
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Tools for PowerShell V5 with Amazon OpsWorks.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use New-OPSDeployment
.
- Tools for PowerShell V5
-
Example 1: This command creates a new app deployment on all of the Linux-based instances in a layer in Amazon OpsWorks Stacks. Even if you specify a layer ID, you must specify a stack ID, too. The command lets the deployment restart the instances if required.
New-OPSDeployment -StackID "724z93zz-zz78-4zzz-8z9z-1290123zzz1z" -LayerId "511b99c5-ec78-4caa-8a9d-1440116ffd1b" -AppId "0f7a109c-bf68-4336-8cb9-d37fe0b8c61d" -Command_Name deploy -Command_Arg @{Name="allow_reboot";Value="true"}
Example 2: This command deploys the
appsetup
recipe from thephpapp
cookbook, and thesecbaseline
recipe from thetestcookbook
cookbook. The deployment target is one instance, but the stack ID and layer ID are also required. The Command_Arg parameterallow_reboot
attribute is set totrue
, which lets the deployment restart the instances if required.$commandArgs = '{ "Name":"execute_recipes", "Args"{ "recipes":["phpapp::appsetup","testcookbook::secbaseline"] } }' New-OPSDeployment -StackID "724z93zz-zz78-4zzz-8z9z-1290123zzz1z" -LayerId "511b99c5-ec78-4caa-8a9d-1440116ffd1b" -InstanceId "d89a6118-0007-4ccf-a51e-59f844127021" -Command_Name $commandArgs -Command_Arg @{Name="allow_reboot";Value="true
-
For API details, see CreateDeployment
in Amazon Tools for PowerShell Cmdlet Reference (V5).
-