> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Understanding Deployment Approach

> This article explores a deployment strategy for CI/CD pipelines, covering feature branch deployment, pull request validation, and main branch production deployment.

In this article, we’ll explore a robust deployment strategy that takes your code from feature branches all the way to a production-ready, serverless environment. By integrating continuous integration (CI), automated deployment, and security testing, you get fast feedback and confidence at every stage.

<Frame>
  ![The image is a flowchart illustrating a deployment approach, detailing stages of continuous integration, deployment, and delivery, along with post-build processes.](https://kodekloud.com/kk-media/image/upload/v1752870530/notes-assets/images/Certified-Jenkins-Engineer-Understanding-Deployment-Approach/deployment-approach-flowchart-ci-cd.jpg)
</Frame>

## 1. Feature Branch Deployment to AWS EC2

When a new commit is pushed to any feature branch, the CI pipeline automatically:

1. Executes build, unit tests, and lint checks.
2. Builds a Docker image and pushes it to a container registry.
3. Connects to a designated AWS EC2 instance via SSH.
4. Pulls and deploys the updated Docker image.
5. Runs integration tests against the EC2-hosted service.

<Callout icon="lightbulb" color="#1CB2FE">
  Ensure your AWS credentials and SSH keys are securely stored in your CI/CD environment variables.
</Callout>

This end-to-end validation on EC2 guarantees that new features won’t break existing functionality before merging.

## 2. Pull Request Validation with Kubernetes & DAST

On opening a pull request, we spin up an ephemeral preview environment:

1. Argo CD syncs the Docker image to a Kubernetes namespace.
2. Dynamic Application Security Testing (DAST) is performed using [OWASP ZAP](https://www.zaproxy.org/) against the running application.

<Callout icon="triangle-alert" color="#FF6B6B">
  DAST scans can produce false positives—review findings carefully and tune your OWASP ZAP policies.
</Callout>

This stage provides rapid feedback on both functionality and security before code merges into `main`.

## 3. Main Branch Deployment to AWS Lambda

Once pull requests are merged into `main`, the pipeline proceeds to production:

1. Packages the application as an AWS Lambda deployment package.
2. Updates Lambda configuration (environment variables, memory allocation, timeouts).
3. Deploys via the AWS CLI or Infrastructure as Code tool.
4. Invokes the function to confirm successful deployment and correct behavior.

This serverless approach ensures scalability and cost-efficiency in your production environment.

## Workflow Summary

| Stage                         | Trigger                | Environment          | Deployment Target       | Tests                            |
| ----------------------------- | ---------------------- | -------------------- | ----------------------- | -------------------------------- |
| Feature Branch Deployment     | Push to `feature/*`    | AWS EC2              | Docker container on EC2 | Integration tests                |
| Pull Request Validation       | Open PR against `main` | Kubernetes (Argo CD) | Synced pods/services    | OWASP ZAP DAST scans             |
| Main Branch Production Deploy | Merge into `main`      | AWS Lambda           | Serverless function     | Post-deployment invocation check |

## Links and References

* [AWS EC2](https://aws.amazon.com/ec2/)
* [AWS Lambda](https://aws.amazon.com/lambda/)
* [Argo CD](https://argo-cd.readthedocs.io/)
* [OWASP ZAP](https://www.zaproxy.org/)
* [CI/CD Best Practices](https://www.redhat.com/en/topics/devops/what-is-ci-cd)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/certified-jenkins-engineer/module/e16e4b93-31c4-479b-96b8-f0d26cde31cd/lesson/91f5171d-f6ae-4b70-bf8f-b68473bc01f0" />
</CardGroup>
