{"id":4716,"date":"2016-05-17T08:06:27","date_gmt":"2016-05-17T08:06:27","guid":{"rendered":"http:\/\/blog.cloudthat.com\/?p=4716"},"modified":"2024-06-25T11:12:39","modified_gmt":"2024-06-25T11:12:39","slug":"install-wordpress-using-aws-codepipeline","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/install-wordpress-using-aws-codepipeline","title":{"rendered":"Install WordPress using AWS Codepipeline"},"content":{"rendered":"<p>In this blog we are going to show how we can install a WordPress with AWS Codepipeline.<\/p>\n<p>Before we begin the demo, let us brief you about the services which will be used.<\/p>\n<p>Amazon Web Services (AWS) is providing three services namely CodeCommit, CodeDeploy, CodePipeline as Developer Tools for the developers, which lets them to focus more on their application rather than deployment.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/blog-cover-image1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4798\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/blog-cover-image1.png\" alt=\"blog-cover-image\" width=\"831\" height=\"509\" \/><\/a><\/p>\n<h2><strong>CodeCommit <\/strong><\/h2>\n<p>CodeCommit<strong>\u00a0<\/strong>hosts private Git repositories, lets we\u00a0to store code securely. You can store anything, anytime and integrate with other AWS &amp; third-party services. Files can be easily migrated from any Git-based repository to AWS CodeComit.<\/p>\n<h2><strong>CodeDeploy<\/strong><\/h2>\n<p>CodeDeploy is developers service, which allows the users to deploy application (contains content such as code, web, scripts, etc). It helps in automated deployments, reduces downtime, have centralized control and easy to adopt.<\/p>\n<h2><strong>CodePipeline<\/strong><\/h2>\n<p>CodePipeline is a continuous delivery service, which lets you to automate your release process using your favorite tools such as Amazon S3, CodeCommit, AWS Elastic Beanstalk, AWS CodeDeploy and Jenkins as well. You can view the progress at a glance. It helps in speeding up delivery while improving quality. It contains many stages to test your code before releasing.<\/p>\n<p>Let\u2019s begin with pre-requisites<\/p>\n<p>Working knowledge of Linux, Amazon EC2, SNS, IAM, RDS &amp; Git.<\/p>\n<p>Region : N.Virginia<\/p>\n<p><strong>Pre-requisites <\/strong><\/p>\n<p>We need to have two IAM roles: a Service Role and an Instance Profile Role.<\/p>\n<p>Create a role named as <strong>Service Role <\/strong>and paste the below policy.<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">{\r\n    \"Version\": \"2012-10-17\",\r\n    \"Statement\": [\r\n        {\r\n            \"Action\": [\r\n                \"autoscaling:PutLifecycleHook\",\r\n                \"autoscaling:DeleteLifecycleHook\",\r\n                \"autoscaling:RecordLifecycleActionHeartbeat\",\r\n                \"autoscaling:CompleteLifecycleAction\",\r\n                \"autoscaling:DescribeAutoscalingGroups\",\r\n                \"autoscaling:PutInstanceInStandby\",\r\n                \"autoscaling:PutInstanceInService\",\r\n                \"ec2:Describe*\",\r\n                \"sns:*\",\r\n                \"codecommit:*\",\r\n                \"codedeploy:*\",\r\n                \"codepipeline:*\",\r\n                \"codecommit:GetBranch\",\r\n                \"codecommit:GetCommit\",\r\n                \"codecommit:UploadArchive\",\r\n                \"codecommit:GetUploadArchiveStatus\",\r\n                \"codecommit:CancelUploadArchive\",\r\n                \"s3:*\"\r\n            ],\r\n            \"Effect\": \"Allow\",\r\n            \"Resource\": \"*\"\r\n        }\r\n    ]\r\n}\r\n<\/pre>\n<p>Once the IAM role is created, we need to establish a trusted relationship for this role with AWSCodeDeploy. Modify trust relationship policy for this particular role and set it to below mentioned policy :<\/p>\n<pre class=\"lang:default decode:true \">{ \r\n\"Version\": \"2012-10-17\", \r\n\"Statement\": [    \r\n    {      \r\n    \"Sid\": \"\",      \r\n    \"Effect\": \"Allow\",      \r\n    \"Principal\": {       \r\n    \"Service\": [            \r\n        \"codedeploy.us-east-1.amazonaws.com\",            \r\n        \"codedeploy.us-west-2.amazonaws.com\"        \r\n    ]      \r\n    },      \r\n    \"Action\": \"sts:AssumeRole\"    \r\n    }  \r\n] \r\n}\r\n<\/pre>\n<p><strong>Instance Profile Role<\/strong>: EC2 instances needs to be launched with proper permissions to access files from S3 buckets.<\/p>\n<pre class=\"lang:default decode:true\">{  \r\n    \"Version\": \"2012-10-17\",  \r\n    \"Statement\": [    \r\n    {      \r\n        \"Action\": [        \r\n            \"s3:Get*\",        \r\n            \"s3:List*\"      \r\n        ],      \r\n        \"Effect\": \"Allow\",      \r\n        \"Resource\": \"*\"    \r\n    }  \r\n    ] \r\n} \r\n<\/pre>\n<p><strong>Note:\u00a0<\/strong>Go to IAM (Identity Access Management), select the Role named <b>AWS-Codepipeline-Service\u00a0<\/b>and paste the below conditions in the policy.<\/p>\n<pre class=\"lang:default decode:true \">{\r\n  \"Action\": [  \r\n      \"codecommit:GetBranch\",\r\n      \"codecommit:GetCommit\",\r\n      \"codecommit:UploadArchive\",\r\n      \"codecommit:GetUploadArchiveStatus\",      \r\n      \"codecommit:CancelUploadArchive\"\r\n            ],\r\n  \"Resource\": \"*\",\r\n  \"Effect\": \"Allow\"\r\n},<\/pre>\n<p><b><span lang=\"EN-US\">Step 1<\/span><\/b><span lang=\"EN-US\">: Launch an EC2 instance with the Instance Profile role. While launching the instance Under <b>Configure Instance Details <\/b>page, expand Advanced Details, and in the User data field, type the following:<\/span><\/p>\n<pre class=\"lang:default decode:true \">sudo yum update \r\nsudo yum install aws-cli \r\ncd \/home\/ec2-user \r\naws s3 cp s3:\/\/aws-codedeploy-us-east-1\/latest\/install . --region us-east-1 \r\nchmod +x .\/install \r\nsudo .\/install auto\r\n<\/pre>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4738\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-1.png\" alt=\"wp-1\" width=\"940\" height=\"189\" \/><\/a><\/p>\n<p><strong>Step -2<\/strong> Go to AWS management console, select CodeCommit.<\/p>\n<p><strong>Step -3<\/strong> Click Create new repository to create a repository<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4740\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-21.png\" alt=\"wp-2\" width=\"291\" height=\"195\" \/><\/a><\/p>\n<p><strong>Step \u2013 4 <\/strong>Create a repository by filling name and description.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4741\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-31.png\" alt=\"wp-3\" width=\"673\" height=\"445\" \/><\/a><\/p>\n<p><strong>Step \u2013 6 <\/strong>Click <strong>Clone URL<\/strong>, then select <strong>SSH<\/strong> we will get url for cloning the repo in our local machine. Copy <strong>url,<\/strong> will be useful later in the process.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-41.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4742\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-41.png\" alt=\"wp-4\" width=\"735\" height=\"302\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step \u2013 7 <\/strong>In your local system (Linux), do <strong>AWS configure. <\/strong>Move to <em>\/tmp\/ <\/em>and clone the codecommit repository.<\/p>\n<p><strong>Step \u2013 8 <\/strong>Move to cloned repo, keep the zip file here containing your WordPress installation. Make changes in <strong>wp-config.php<\/strong> (like \u2018DB_HOST\u2019, \u2018localhost\u2019). After commiting push it into repo.<\/p>\n<p>For verification, go to CodeCommit console, there you can find the details.<\/p>\n<p><strong>Step \u2013 9 <\/strong>Now it\u2019s time to create a CodeDeploy application. Switch to CodeDeploy console and select Create \u00a0New Application.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-51.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4743\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-51.png\" alt=\"wp-5\" width=\"513\" height=\"192\" \/><\/a><\/p>\n<p><strong>Step \u2013 10 <\/strong>Fill the required details and attach the EC2 instance launched in the beginning.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-61.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4744\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-61.png\" alt=\"wp-6\" width=\"978\" height=\"652\" \/><\/a><\/p>\n<p><strong>Step \u2013 11 <\/strong>Select the Deployment Configuration according to our requirement. Then click <strong>Create trigger<\/strong>, it will allow us to make configuration for AWS SNS (Simple Notification Services).<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-71.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4745\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-71.png\" alt=\"wp-7\" width=\"940\" height=\"468\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step \u2013 12 <\/strong>Assign the Trigger name and Events we want to trigger. Then select the SNS topic for getting alerts of your deployment.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-81.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4746\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-81.png\" alt=\"wp-8\" width=\"748\" height=\"743\" \/><\/a><\/p>\n<p><strong>Step \u2013 13 <\/strong>Select the <strong>Service-Role\u00a0<\/strong>for deployment. Then click <strong>Create Application <\/strong>and our application will be ready.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-91.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4747\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-91.png\" alt=\"wp-9\" width=\"956\" height=\"279\" \/><\/a><\/p>\n<p><strong>Step \u2013 14 <\/strong>Navigate to AWS CodePipeline, where we can create a pipeline. Give a name to pipeline then click <strong>Next step.<\/strong><\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-101.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4748\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-101.png\" alt=\"wp-10\" width=\"940\" height=\"341\" \/><\/a><\/p>\n<p><strong>Step \u201315 <\/strong>Select the Source provider as <strong>AWS CodeCommit <\/strong>\u00a0and fill the required details.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-111.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4749\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-111.png\" alt=\"wp-11\" width=\"1015\" height=\"524\" \/><\/a><\/p>\n<p><strong>Step -16 <\/strong>Select Deployment provider as <strong>AWS CodeDeploy <\/strong>and fill the required fields.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-121.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4751\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-121.png\" alt=\"wp-12\" width=\"1021\" height=\"563\" \/><\/a><\/p>\n<p><strong>Step \u2013 17 <\/strong>Select the Role name as <strong>AWS-CodePipeline-Service<\/strong> and then click <strong>Next step<\/strong>. It will navigate us to the review page, after reviewing details click <strong>Create Pipeline.<\/strong> We will get a pipeline created.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-131.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4752\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-131.png\" alt=\"wp-13\" width=\"940\" height=\"328\" \/><\/a><\/p>\n<p>We will get three stages of the deployment, namely <strong>No executions yet<\/strong>, <strong>In Progress<\/strong>, <strong>Succeeded<\/strong> or <strong>Failed<\/strong>.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-141.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4753\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-141.png\" alt=\"wp-14\" width=\"170\" height=\"262\" \/><\/a><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-151.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4754\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-151.png\" alt=\"wp-15\" width=\"160\" height=\"263\" \/><\/a><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-161.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4755\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-161.png\" alt=\"wp-16\" width=\"182\" height=\"263\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>1<sup>st<\/sup> Output<\/strong><\/p>\n<p>Now paste the Public IP of EC2 in browser.<\/p>\n<p>We will get output as <strong>database error connection<\/strong>. As in the <strong>wp-config.php<\/strong> database is mentioned as local.<a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-171.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4756\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-171.png\" alt=\"wp-17\" width=\"604\" height=\"122\" \/><\/a><\/p>\n<p>Now, change \u2018DB_HOST\u2019 from local to RDS by providing the end-point of RDS in <strong>wp-config.php<\/strong>. Then commit and push back to repo.<\/p>\n<p>Navigate to CodePipeline then click <strong>Release change. <\/strong>Wait for the Deployment to be succeeded. Paste the Public IP of the EC2 in browser.<\/p>\n<p><strong>2<sup>nd<\/sup> Output<\/strong><\/p>\n<p>We will see WordPress installation page.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-181.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4757\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/wp-181.png\" alt=\"wp-18\" width=\"853\" height=\"847\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>In short, we can say that AWS Codepipeline allows you to deploy WordPress on multiple servers without any downtime. Whenever we make changes to the configuration according to requirement, AWS Codepipeline lets you to release the change in no time.<\/p>\n<p>In case of any questions, please feel free to post your comments. You could also share your experience installing WordPress using AWS Codepipeline here.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"author":219,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3606,3607,3624],"user_email":"prarthitm@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/4716"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/219"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=4716"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/4716\/revisions"}],"predecessor-version":[{"id":46094,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/4716\/revisions\/46094"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=4716"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=4716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}