Menu
AWS CodeDeploy
User Guide (API Version 2014-10-06)

Step 4: Deploy Your WordPress Application

Now you will deploy the sample WordPress application revision you uploaded to Amazon S3. You will use the AWS CLI or the AWS CodeDeploy console to deploy the revision and monitor the deployment's progress. After the application revision is successfully deployed, you will check the results.

Deploy Your Application Revision with AWS CodeDeploy

To deploy your application revision (CLI)

  1. First, the deployment will need a corresponding deployment group. However, before you create the deployment group, you will need a service role ARN. A service role is an IAM role that gives a service permission to act on your behalf. In this case, the service role will give AWS CodeDeploy permission to access your Amazon EC2 instances to expand (read) their Amazon EC2 instance tags.

    You should have already followed the instructions in Create a Service Role (CLI) to create a service role. To get the ARN of the service role, see Get the Service Role ARN (CLI) .

  2. Now that you have the ARN, call the create-deployment-group command to create a deployment group named WordPress_DepGroup, associated with the application named WordPress_App, using the Amazon EC2 tag named CodeDeployDemo and deployment configuration named CodeDeployDefault.OneAtATime, with the service role ARN:

    Copy
    aws deploy create-deployment-group \ --application-name WordPress_App \ --deployment-group-name WordPress_DepGroup \ --deployment-config-name CodeDeployDefault.OneAtATime \ --ec2-tag-filters Key=Name,Value=CodeDeployDemo,Type=KEY_AND_VALUE \ --service-role-arn serviceRoleARN

    Note

    The create-deployment-group command provides support for creating triggers that result in the sending of Amazon SNS notifications to topic subscribers about specified events in deployments and instances. The command also supports options for automatically rolling back deployments and setting up alarms to stop deployments when certain monitoring thresholds are met in Amazon CloudWatch Alarms. Commands for these actions are excluded from the sample in this tutorial.

  3. Now call the create-deployment command to create a deployment associated with the application named WordPress_App, the deployment configuration named CodeDeployDefault.OneAtATime, and the deployment group named WordPress_DepGroup, using the application revision named WordPressApp.zip in the bucket named codedeploydemobucket:

    Copy
    aws deploy create-deployment \ --application-name WordPress_App \ --deployment-config-name CodeDeployDefault.OneAtATime \ --deployment-group-name WordPress_DepGroup \ --s3-location bucket=codedeploydemobucket,bundleType=zip,key=WordPressApp.zip

To deploy your application revision (console)

  1. Before you use the AWS CodeDeploy console to deploy your application revision, you will need a service role ARN. A service role is an IAM role that gives a service permission to act on your behalf. In this case, the service role will give AWS CodeDeploy permission to access your Amazon EC2 instances to expand (read) their Amazon EC2 instance tags.

    You should have already followed the instructions in Create a Service Role (Console) to create a service role. To get the ARN of the service role, see Get the Service Role ARN (Console) .

  2. Now that you have the ARN, you use the AWS CodeDeploy console to deploy your application revision:

    Sign in to the AWS Management Console and open the AWS CodeDeploy console at https://console.aws.amazon.com/codedeploy.

    Note

    Sign in with the same account or IAM user information you used in Getting Started.

  3. If the Applications page is not displayed, on the AWS CodeDeploy menu, choose Applications.

  4. In the list of applications, choose WordPress_App.

  5. Under Deployment groups, choose Create deployment group.

  6. In the Deployment group name box, type WordPress_DepGroup.

  7. Under Deployment type, choose In-place deployment.

  8. Under Add instances, in the list of tags, choose Amazon EC2 from the Tag type drop-down list.

  9. In the Key box, type Name.

  10. In the Value box, type CodeDeployDemo.

    Note

    After you type CodeDeployDemo, a 1 should appear under Instances to confirm AWS CodeDeploy found one matching Amazon EC2 instance.

  11. In the Deployment configuration drop-down list, choose CodeDeployDefault.OneAtATime.

  12. In the Service role ARN drop-down list, choose the service role ARN, and then choose Create deployment group.

  13. On the Application details page, select the button next to the new deployment group. In the Actions menu, choose Deploy new revision.

  14. In the Application drop-down list, choose WordPress_App.

  15. In the Deployment group drop-down list, choose WordPress_DepGroup.

  16. Next to Repository type, choose My application is stored in Amazon S3. In the Revision location box, type the location of the sample WordPress application revision you previously uploaded to Amazon S3. To get the location:

    1. Open the Amazon S3 console at https://console.aws.amazon.com/s3/.

    2. In the list of buckets, choose codedeploydemobucket (or the name of the bucket where you uploaded your application revision).

    3. In the list of objects, choose WordPressApp.zip.

    4. Choose the Properties tab.

    5. Copy the value of the Link field to your clipboard.

      It might look something like this:

      https://s3.amazonaws.com/codedeploydemobucket/WordPressApp.zip

    6. Return to the AWS CodeDeploy console, and in the Revision location box, paste the Link field value.

  17. If a message appears in the File type list stating the file type could not be detected, choose .zip in the list of file types.

  18. (Optional) Type a comment in the Deployment description box.

  19. From the Deployment configuration drop-down list, choose CodeDeployDefault.OneAtATime.

  20. Choose Deploy. Information about your newly created deployment will appear on the Deployments page.

    Note

    To get the current status of the deployment, choose the Refresh button next to the table.

Monitor and Troubleshoot Your Deployment

To monitor and troubleshoot your deployment (CLI)

  1. Get the deployment's ID by calling the list-deployments command against the application named WordPress_App and the deployment group named WordPress_DepGroup:

    Copy
    aws deploy list-deployments --application-name WordPress_App --deployment-group-name WordPress_DepGroup --query 'deployments' --output text
  2. Call the get-deployment command with the deployment ID:

    Copy
    aws deploy get-deployment --deployment-id deploymentID --query 'deploymentInfo.status' --output text
  3. The command will return the deployment's overall status. If successful, the value will be Succeeded.

    If the overall status is Failed, you can call commands such as list-deployment-instances and get-deployment-instance to troubleshoot. For more troubleshooting options, see Analyzing log files to investigate deployment failures on instances.

To monitor and troubleshoot your deployment (console)

On the Deployments page in the AWS CodeDeploy console, you can monitor your deployment's status in the Status column.

Note

To get the current status of the deployment, choose the Refresh button above the table.

To get more information about your deployment, especially if the Status column value has any value other than Succeeded:

  1. In the Deployments table, choose the arrow next to the deployment ID. After a deployment fails, a message that describes the reason for the failure will appear in Details.

  2. In Instances, choose View all instances. More information about the deployment will be displayed. After a deployment fails, you may be able to determine on which Amazon EC2 instances and at which step the deployment failed.

    Note

    If you don't see Instances, choose the Refresh button above the table. After the Status column changes from In progress to Created, Instances should appear.

  3. If you want to do more troubleshooting, you can use a technique like the one described in View Instance Details. You can also analyze the deployment log files on an Amazon EC2 instance. For more information, see Analyzing log files to investigate deployment failures on instances.

Verify Your Deployment

After your deployment is successful, verify your WordPress installation is working. Use the public DNS address of the Amazon EC2 instance, followed by /WordPress, to view your site in a web browser. (To get the public DNS value, in the Amazon EC2 console, choose the Amazon EC2 instance, and on the Description tab, look for the value of Public DNS.)

For example, if the public DNS address of your Amazon EC2 instance is ec2-01-234-567-890.compute-1.amazonaws.com, you would use the following URL:

Copy
http://ec2-01-234-567-890.compute-1.amazonaws.com/WordPress