AWS OpsWorks to Deploy an Application
Tags: aws, devops, community, opsworks
Published: 2023-05-15 14:21:04


## AWS OpsWorks to Deploy an Application

### AWS Cloud Hands on Lab Practice Series
>  **Project Overview —**

To deploy an PHP application using AWS OpsWorks. Building Layers, and in one of the Layers we will deploy an application instance.
>  **SOLUTIONS ARCHITECTURE OVERVIEW -**

![](https://cdn-images-1.medium.com/max/2000/1*oGLTWB1Bl8zgxFvW86XuCQ.png)
>  **First Let’s understand the real world use case -**

 1. **Application Lifecycle Management:** OpsWorks can be used to automate the entire application lifecycle, including provisioning, deployment, scaling, and monitoring. It allows you to define the desired state of your application environment and automates the process of bringing it to that state, making it easier to manage and update applications.

 2. **Continuous Integration and Continuous Deployment (CI/CD):** OpsWorks can integrate with popular CI/CD tools like AWS Code Pipeline and Jenkins. This enables you to automate the build, test, and deployment processes for your applications, ensuring a streamlined and efficient CI/CD pipeline.

 3. **Microservices Architecture:** OpsWorks can be leveraged to manage and deploy microservices-based architectures. With OpsWorks, you can define individual stacks for each microservice, enabling independent deployment and scaling of different components of your application.

 4. **Configuration Management:** OpsWorks integrates with popular configuration management tools like Chef and Puppet, enabling you to define and manage infrastructure configurations as code. This simplifies the process of configuring and maintaining your resources consistently across multiple instances.

 5. **Technology Industries** — Gaming, Video Streaming and Media, Education and E-Learning, Fintech and Financial Services, Healthcare and Life Sciences, Travel and Hospitality etc.

### AWS OpsWorks Stacks Benefits :

**AWS OpsWorks** is a configuration management service that provides managed instances of Chef and Puppet. Chef and Puppet are automation platforms that allow you to use code to automate the configurations of your servers. OpsWorks lets you use Chef and Puppet to automate how servers are configured, deployed, and managed across your Amazon EC2 instances or on-premises compute environments. OpsWorks has three offerings, AWS OpsWorks for Chef Automate, AWS OpsWorks for Puppet Enterprise, and AWS OpsWorks Stacks.

![](https://cdn-images-1.medium.com/max/2000/1*yawdCB0DORp1dEW6hYNDlw.jpeg)
>  **STEP BY STEP GUIDE -**

we will learn more about the foundational element of OpsWorks, and use it to deploy an application. We will start with the stack, then build Layers, and in one of the Layers we will deploy an instance. Then on that instance, we will deploy an application.

>  **PREREQUISITE —**

* AWS Account with Admin Access.

* An Internet facing ELB.

* Use this GitHub repository during the Add Application step: [https://github.com/Kunal-Shah107/OpsworksDemo](https://github.com/Kunal-Shah107/OpsworksDemo)

>  **AWS Services Usage —**

AWS OpsWorks, EC2, ELB, IAM, VPC

**STEP 1** :

* Log into AWS Console & Search for AWS OpsWorks.

* Navigate to **OpsWorks Stack**. Click Go to OpsWorks Stacks.

![](https://cdn-images-1.medium.com/max/2254/1*Q3Z5kxwSqXYxM5sk7hP60A.jpeg)

**STEP 2** :

![](https://cdn-images-1.medium.com/max/2000/1*utV-zn6p0QrJitNvusHseA.jpeg)

* Click Add Your First Stack.

* Choose Chef 11 stack, and then fill out the form below:

* **Stack name** = Opsworks-stack-demo
- **Region** = US East (your choice)
- **VPC** = Default VPC CIDR.
- **Default Subnet** = Public Subnet
- **Default Operating System** = Amazon Linux 2018.03
- The rest we can leave set to the defaults.

* Click Add Stack.

![](https://cdn-images-1.medium.com/max/2000/1*ijrg54OON9mN1xvZxehCsw.jpeg)

**STEP 3** :

* Create a First Layer by clicking Add a Layer.

* Select the Layer type (PHP App Server) from the dropdown.

* In the Elastic Load Balancers dropdown, choose the one that is provided.

* Leave Instance Shutdown Behavior set to Wait for an instance’s connections to drain.

* Click Add layer.

![](https://cdn-images-1.medium.com/max/2000/1*zZelyDpZLXX-_Tel3WffyQ.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*PbyMJhdxfu3I69xgpLTnPA.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*ejpC0ibDF949RD_uZ1czFw.jpeg)

**STEP 4** :

* Create a Second Layer by clicking Add a Layer.

* Select the Layer type (MySQL) from the dropdown.

* Leave rest of the form set to its defaults, and click Add layer.

![](https://cdn-images-1.medium.com/max/2000/1*nFvzJA6KoAOHjRXUf-oBEA.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*cMz1fuU3BljlZgwf2aP0oA.jpeg)

**STEP 5** :

* Click on PHP App Server & edit the settings.

* In the Network area set the Public IP addresses to Yes & Click Save.

![](https://cdn-images-1.medium.com/max/2000/1*YyJBMkLb2Z2RHXoto4uHGQ.jpeg)

**STEP 6** :

* Scroll back up and click on Instances in the left-hand menu.

* Down near the bottom of this page, in the PHP App Server section, click Add an instance.

* In the New tab, change the Size to t2.micro.

* Click Add Instance.

* With the instance created, click the start button that’s over in the Actions column.

* Wait until it has a Status of online before moving on.

* **TIP** — Check New EC2 Instance getting provisioned.

![](https://cdn-images-1.medium.com/max/2000/1*aW8gpm-wTJz9h79S7Q7O0A.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*aonxVF2kV29VrrSWK5f09g.jpeg)

**STEP 7** :

* Choose Apps in left navigation & Click Add app.

* In the web form that appears, set the Name to **phpdemo** and set the Data Source Type to None.

* Select Git from the Repository type dropdown, and in the Repository URL, paste the URL from the Prerequisites.

* [https://github.com/Kunal-Shah107/OpsworksDemo](https://github.com/Kunal-Shah107/OpsworksDemo)

* We’ll see our new app in the lower part of the screen. Click deploy in the Actions column. On the next screen, click the Deploy button.

* Wait until we have a green successful appear as a status before moving on.

![](https://cdn-images-1.medium.com/max/2000/1*ZdpdyfwRn9b-O8lcktFK1g.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*LoBE1mKuSOPbOzeMCO3k0Q.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*0UY1ISNMWRRzy_TSTbWsXw.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*0iyLCaLXw4FrRMhYiaUnmQ.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*L9Sgt0i5Ybx7c5PWFjyayg.jpeg)

**STEP 8** :

* In the left navigation click on Instances.

* Scroll down and click on our php-app1 instance.

* Scroll farther down and right click on the public IP address (to open it in a new browser tab).

* In that new tab, we should see a message reading “**AWS OpsWorks Demo by acloudguy.in!**”

* Congratulations !! That message means that we’ve completed the hands-on lab.

![](https://cdn-images-1.medium.com/max/2000/1*xzneHH-woSkVqXknFdqHAw.jpeg)

**Pro Tip** : Try Changing the application headings & do the redeployment. This will help you understand the benefits of CI/CD with AWS OpsWorks.

**IMP NOTE** — This DEMO/POC might incur some charges if kept active for long time. So please make sure to clean up the environment once done.

*I am Kunal Shah, AWS Certified Solutions Architect, helping clients to achieve optimal solutions on the Cloud. Cloud Enabler by choice, DevOps Practitioner having 7+ Years of overall experience in the IT industry.*

*I love to talk about Cloud Technology, DevOps, Digital Transformation, Analytics, Infrastructure, Dev Tools, Operational efficiency, Serverless, Cost Optimization, Cloud Networking & Security.*

#aws #community #builders #devops #OpsWorks #infrastructure #Management #CICD #Chef #Puppet #Configurations

*You can reach out to me @ [acloudguy.in](https://acloudguy.in/)*