You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Event-Driven Architecture with AWS Lambda and SQS
2
2
3
-
This project demonstrates an event-driven architecture using **AWS Lambda**, **Amazon SQS**, and **AWS CloudWatch** for building a simple event-based processing system. The infrastructure is managed using **Terraform**, and the deployment pipeli## Project Overview
3
+
This project demonstrates an event-driven architecture using **AWS Lambda**, **Amazon SQS**, and **AWS CloudWatch** for building a simple event-based processing system. The infrastructure is managed using **Terraform**, and the deployment pipeline is set up using **GitHub Actions** for CI/CD.
4
+
5
+
---
6
+
7
+
## Project Overview
4
8
5
9
The project contains:
6
10
@@ -9,6 +13,8 @@ The project contains:
9
13
-**Terraform Configuration**: Terraform scripts to deploy the Lambda function, SQS queue, and related IAM roles and policies.
10
14
-**CI/CD Pipeline**: GitHub Actions pipeline to automatically deploy infrastructure and Lambda code changes.
11
15
16
+
---
17
+
12
18
## Architecture
13
19
14
20
1.**SQS Queue**:
@@ -26,49 +32,177 @@ The project contains:
26
32
- GitHub Actions is used for Continuous Integration and Continuous Deployment. It triggers on commits to the `main` branch or when changes are made to infrastructure files (`modules`, `environments`, `lambda_src`).
27
33
- Terraform manages infrastructure deployment, and Lambda updates are automatically deployed via GitHub Actions.
28
34
29
-
## Prerequisitesne is set up using **GitHub Actions** for CI/CD.
35
+
---
30
36
31
-
## Project Overview
37
+
## Prerequisites
32
38
33
-
The project contains:
39
+
To get started with this project, make sure you have the following installed:
34
40
35
-
***AWS Lambda Function**: A Python-based Lambda function that processes messages from an SQS queue and logs details to CloudWatch.
36
-
***SQS Queue**: An SQS queue that triggers the Lambda function on receiving messages.
37
-
***Terraform Configuration**: Terraform scripts to deploy the Lambda function, SQS queue, and related IAM roles and policies.
38
-
***CI/CD Pipeline**: GitHub Actions pipeline to automatically deploy infrastructure and Lambda code changes.
41
+
-**Terraform** (v1.5.5 or later)
42
+
-**AWS CLI** (configured with the necessary permissions)
43
+
-**GitHub** (to push and manage code)
44
+
-**Node.js** (for running the Lambda function locally, if needed)
39
45
40
-
## Architecture
46
+
---
41
47
42
-
1.**SQS Queue**:
43
-
* The SQS queue receives event messages such as "build_succeeded".
44
-
* The queue triggers the Lambda function when a new message is pushed.
48
+
## Setup
45
49
46
-
2.**Lambda Function**:
47
-
* The Lambda function processes the messages from SQS, logs the message details to CloudWatch, and performs any additional processing (e.g., triggering other services).
48
-
* The function is triggered every time a new message is added to the queue.
50
+
### 1. Clone the Repository
49
51
50
-
3.**CloudWatch Logs**:
51
-
* The Lambda function logs detailed information about the received message in CloudWatch for monitoring and debugging.
52
+
First, clone the repository to your local machine:
52
53
53
-
4.**CI/CD Pipeline**:
54
-
* GitHub Actions is used for Continuous Integration and Continuous Deployment. It triggers on commits to the `main` branch or when changes are made to infrastructure files (`modules`, `environments`, `lambda_src`).
55
-
* Terraform manages infrastructure deployment, and Lambda updates are automatically deployed via GitHub Actions.
After pushing changes to the main branch or opening a pull request, GitHub Actions will automatically trigger the pipeline. You can view the pipeline logs in GitHub under the "Actions" tab.
120
+
121
+
---
122
+
123
+
## Manual Testing via Console
124
+
125
+
-**Lambda Function**: You can test the Lambda function directly in the AWS Lambda console by sending sample event data.
126
+
-**SQS Queue**: Messages can be sent to the SQS queue using the AWS CLI or via the AWS Console.
127
+
128
+
---
129
+
130
+
## Folder Structure
131
+
132
+
```
133
+
Project-Event_driven_Arch/
134
+
├── environments
135
+
│ ├── dev
136
+
│ │ ├── main.tf
137
+
│ │ ├── outputs.tf
138
+
│ │ ├── terraform.tfvars
139
+
│ │ └── variables.tf
140
+
│ └── prod
141
+
│ ├── main.tf
142
+
│ ├── terraform.tfvars
143
+
│ └── variables.tf
144
+
├── lambda_src
145
+
│ ├── index.py
146
+
│ └── lambda.zip
147
+
├── modules
148
+
│ ├── event_mapping
149
+
│ │ ├── main.tf
150
+
│ │ ├── outputs.tf
151
+
│ │ └── variables.tf
152
+
│ ├── iam
153
+
│ │ ├── main.tf
154
+
│ │ ├── outputs.tf
155
+
│ │ └── variables.tf
156
+
│ ├── lambda
157
+
│ │ ├── main.tf
158
+
│ │ ├── outputs.tf
159
+
│ │ └── variables.tf
160
+
│ ├── sg
161
+
│ │ ├── main.tf
162
+
│ │ ├── outputs.tf
163
+
│ │ └── variables.tf
164
+
│ ├── sqs
165
+
│ │ ├── main.tf
166
+
│ │ ├── outputs.tf
167
+
│ │ └── variables.tf
168
+
│ └── vpc
169
+
│ ├── main.tf
170
+
│ ├── outputs.tf
171
+
│ └── variables.tf
172
+
└── README.md
173
+
174
+
12 directories, 28 files
175
+
176
+
```
177
+
178
+
---
179
+
180
+
## Troubleshooting
181
+
182
+
### Common Issues:
183
+
184
+
-**No CloudWatch logs**: Ensure the Lambda function has the necessary IAM permissions to create and write to CloudWatch Logs.
185
+
-**Lambda not triggered**: Verify the SQS queue and Lambda trigger are correctly configured. Ensure the Lambda function is subscribed to the SQS queue.
186
+
-**Terraform apply issues**: Ensure that Terraform is configured with the correct AWS credentials, and that you are running it in the correct region.
187
+
188
+
### Logs:
189
+
190
+
-**Lambda logs**: Access them in the CloudWatch console or via AWS CLI:
191
+
192
+
```bash
193
+
aws logs tail /aws/lambda/ci-event-processor
194
+
```
195
+
196
+
- **GitHub Actions pipeline logs**: Available in the "Actions" tab in your GitHub repository.
197
+
198
+
---
199
+
200
+
## Contributing
201
+
202
+
Feel free to fork the repository, make changes, and submit pull requests. Please ensure all changes are well-documented and have corresponding tests.
203
+
204
+
---
205
+
206
+
## License
207
+
208
+
This project is licensed under the MIT License - see the LICENSE file for details.
0 commit comments