CodeDeploy client

This page contains examples with the CodeDeploy client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.

The CodeDeploy package could be installed with Composer.

composer require async-aws/code-deploy

A new client object may be instantiated by:

use AsyncAws\CodeDeploy\CodeDeployClient; $codeDeploy = new CodeDeployClient();

The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:

use AsyncAws\CodeDeploy\CodeDeployClient; $codeDeploy = new CodeDeployClient([ 'accessKeyId' => 'my_access_key', 'accessKeySecret' => 'my_access_secret', 'region' => 'eu-central-1', ]);

For all available options, see the configuration reference.

Usage

Create deployment

use AsyncAws\CodeDeploy\CodeDeployClient; use AsyncAws\CodeDeploy\Enum\RevisionLocationType; use AsyncAws\CodeDeploy\Input\CreateDeploymentInput; $codeDeploy = new CodeDeployClient(); $deployment = $codeDeploy->createDeployment(new CreateDeploymentInput([ 'applicationName' => 'my-app', 'deploymentGroupName' => 'my-deployment-group', 'revision' => [ 'revisionType' => RevisionLocationType::GIT_HUB, 'gitHubLocation' => [ 'repository' => 'repo', 'commitId' => 'commit', ] ], ])); echo 'DepoymentId: '. $deployment->getDeploymentId();

Sets the result of a Lambda validation function

use AsyncAws\CodeDeploy\CodeDeployClient; use AsyncAws\CodeDeploy\Enum\LifecycleEventStatus; use AsyncAws\CodeDeploy\Input\PutLifecycleEventHookExecutionStatusInput; $codeDeploy = new CodeDeployClient(); $event = []; // fetched from lambda $status = $codeDeploy->putLifecycleEventHookExecutionStatus(new PutLifecycleEventHookExecutionStatusInput([ 'deploymentId' => $event['deploymentId'], 'lifecycleEventHookExecutionId' => $event['lifecycleEventHookExecutionId'], 'status' => LifecycleEventStatus::SUCCEEDED ])); echo 'ExecutionId: '. $status->getLifecycleEventHookExecutionId();

The source code to this page is found on GitHub.