diff --git a/src/SUMMARY.md b/src/SUMMARY.md index a334918..fc5eabd 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -45,6 +45,7 @@ - [DynamoDB](./software/cloud-computing/AWS/database-services/DynamoDB/README.md) - [RDS](./software/cloud-computing/AWS/database-services/RDS/README.MD) - [Lambda](./software/cloud-computing/AWS/Lambda/README.MD) + - [CloudWatch](./software/cloud-computing/AWS/CloudWatch/README.md) --- diff --git a/src/software/cloud-computing/AWS/CloudWatch/README.md b/src/software/cloud-computing/AWS/CloudWatch/README.md new file mode 100644 index 0000000..e91ff00 --- /dev/null +++ b/src/software/cloud-computing/AWS/CloudWatch/README.md @@ -0,0 +1,43 @@ +# Amazon CloudWatch + +cloudwatch logo + +## Overview + +Imagine having a magical dashboard where you can see everything happening across your applications and AWS services, in real-time. That’s Amazon CloudWatch, a smart monitoring tool from AWS! + +## Key Features and Benefits + +- **Real-Time Insights**: Monitor metrics and logs across your entire stack. +- **Alarms & Alerts**: Stay ahead with notifications for performance issues. +- **Custom Dashboards**: Visualize key data in a way that makes sense for you. +- **Seamless Integration**: Works with AWS services like EC2, Lambda, and more. +- **Troubleshooting Made Easy**: Explore the logs to pinpoint root causes quickly. + +## Create a log group in CloudWatch Logs + +CloudWatch automatically creates **log groups** while receives log events from AWS services.However, you also have the flexibility to create custom log groups manually for better organization or specific use cases. Here’s how: + +1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. + +2. In the navigation pane, choose Log groups. + +3. Choose Actions, and then choose Create log group. + +4. Enter a name for the log group, and then choose Create log group. + +This is an example of a log group for one my lambda functions called `sign-up` + +lambda logo + +Every time this function is invoked, CloudWatch automatically generates and stores the corresponding logs in a `log stream` in its associated log group. These logs include details about the execution, such as invocation times, errors, and any custom logs you’ve added within the function. + +## 📚 Further Reading + +- **[Amazon CloudWatch Overview](https://aws.amazon.com/cloudwatch/)** + Official AWS documentation on Amazon CloudWatch, its use cases, and features. + +- **[Boto3 CloudWatch Service Reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html)** + Boto3 documentation for interacting with AWS CloudWatch using the AWS SDK for Python (Boto3). + +- **[Working with log groups and log streams](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html)** diff --git a/src/software/cloud-computing/AWS/Lambda/README.MD b/src/software/cloud-computing/AWS/Lambda/README.MD index 59981b0..2b2529c 100644 --- a/src/software/cloud-computing/AWS/Lambda/README.MD +++ b/src/software/cloud-computing/AWS/Lambda/README.MD @@ -1,10 +1,10 @@ # AWS Lambda -lambda logo +lambda logo ## Overview -AWS Lambda is a serverless compute service that allows you to run code in response to events without managing servers. Simply upload your function code, and Lambda handles the patching, and infrastructure management. +AWS Lambda is a serverless compute service that allows you to run code in response to events without managing servers. Simply upload your function code, and Lambda takes care of the rest. ## Functions @@ -33,7 +33,63 @@ In this example, the `boto3` library is used, which is the AWS SDK (Software Dev ## Creating a Lambda Function -To create a Lambda function, you need a deployment package. The deployment package is a .zip file archive or container image that contains your function code and any external libraries used in the code. However, you do not need to include `boto3` in the dependencies, since it is already included in the AWS Lambda Python runtime environment. +To create a Lambda function, you need a deployment package. The deployment package is a .zip file archive or container image that contains your function code and any external libraries used in the code. + +### Steps to Create the `.zip` File + +1. **Save your Python code in a file, for example, `lambda_function.py`.** +2. **Install Dependencies** + If your function has external dependencies, list them in a `requirements.txt` file. To generate `requirements.txt` from an existing project, run: + +```bash +pip freeze > requirements.txt +``` + +`Note`: Exclude boto3 from the file to reduce the package size, since it is already included in the AWS Lambda Python runtime environment. + +```bash +pip uninstall boto3 -y +``` + +3. **Install Dependencies Locally** + Create a directory for your function and install the dependencies into that directory: + +```bash +mkdir my-lambda-function +pip install -r requirements.txt -t my-lambda-function/ +``` + +4. **Add Your Function Code** + Copy your lambda_function.py file into the same directory: + +```bash +cp lambda_function.py my-lambda-function/ +``` + +5. **Create the .zip File** + Package the directory into a .zip file: + +```bash +cd my-lambda-function +zip -r ../my-lambda-function.zip . +cd .. +``` + +### What's Next? + +There are multiple ways to create your Lambda function once the package is ready, including: + +1. **Manually via the AWS Console**: Upload the `.zip` file directly through the AWS Management Console. +2. **AWS Command Line Interface (CLI)**: Use CLI commands to create and deploy your Lambda function. +3. **Infrastructure as Code (IaC) Tools**: Automate the creation of Lambda functions using tools like Terraform, AWS CloudFormation. + +### Why Avoid Manual Deployments via the Console? + +While the AWS Console provides a simple and intaractive interface for creating Lambda functions, it is **not recommended** for production deployments due to the following reasons: + +- **Role Attachments**: Each Lambda function requires an IAM role with appropriate permissions. Configuring roles manually in the console can lead to errors or inconsistent configurations. +- **Reproducibility**: Deploying via the console lacks automation and version control, making it difficult to reproduce configurations across environments. +- **Scalability**: IaC tools simplify managing multiple Lambda functions and their dependencies. ## Installing boto3 diff --git a/src/software/cloud-computing/AWS/database-services/DynamoDB/README.md b/src/software/cloud-computing/AWS/database-services/DynamoDB/README.md index 8a47d25..4ef53bf 100644 --- a/src/software/cloud-computing/AWS/database-services/DynamoDB/README.md +++ b/src/software/cloud-computing/AWS/database-services/DynamoDB/README.md @@ -1,5 +1,7 @@ # Amazon DynamoDB +dynamodb logo + ## Overview Amazon DynamoDB is a fully managed NoSQL database service that provides single-digit millisecond response times, making it ideal for high-traffic applications. DynamoDB supports both key-value and document data models, allowing for flexible and dynamic data structures. diff --git a/src/software/cloud-computing/AWS/database-services/RDS/README.MD b/src/software/cloud-computing/AWS/database-services/RDS/README.MD index fbbbdf0..79129c1 100644 --- a/src/software/cloud-computing/AWS/database-services/RDS/README.MD +++ b/src/software/cloud-computing/AWS/database-services/RDS/README.MD @@ -1,5 +1,7 @@ # Amazon Relational Database Service (RDS) +rds logo + ## Overview Amazon RDS (Relational Database Service) is a fully managed service that simplifies the setup, operation, and scaling of relational databases in the cloud. RDS supports popular database engines, enabling users to choose the one that best fits their application’s needs. diff --git a/src/software/cloud-computing/Terraform/README.md b/src/software/cloud-computing/Terraform/README.md new file mode 100644 index 0000000..3964e22 --- /dev/null +++ b/src/software/cloud-computing/Terraform/README.md @@ -0,0 +1,136 @@ +# Terraform + +terraform logo + +## Overview + +Previously, we mentioned the benefits of using Infrastructure as Code (IaC) for creating and deploying your Lambda functions. One powerful solution for managing IaC is **Terraform**! + +Terraform, developed by HashiCorp, is an open-source tool that enables you to define and provision infrastructure using a simple, human-readable configuration language. With Terraform, you can manage everything from cloud providers like AWS, Azure, and Google Cloud to on-premise resources and even SaaS integrations. + +## Why Choose Terraform? + +- **Declarative Configuration**: Focus on _what_ you want to achieve, and Terraform handles the _how_. +- **Version Control**: Treat infrastructure as code, keeping a record of changes alongside your application code. +- **Automation**: Reduce manual work by automating resource provisioning and updates. +- **State Management**: Terraform keeps track of your infrastructure's state, ensuring changes are safely applied. + +## The Terraform Workflow + +1. **Write**: Define your infrastructure using configuration files written in HCL (HashiCorp Configuration Language). +2. **Plan**: Preview the changes Terraform will make, ensuring predictability before execution. +3. **Apply**: Execute the changes to create, update, or destroy resources as specified in your configuration. +4. **Destroy**: Safely decommission resources when they're no longer required. + +## Most Common Terraform Commands + +Here are some of the most frequently used Terraform commands to get you started: + +### Initialization + +- `terraform init`: Prepares the working directory for other commands by downloading plugins and providers. + +### Planning and Applying + +- `terraform plan`: Generates an execution plan, showing what changes will be made to your infrastructure. +- `terraform apply`: Applies the changes required to reach the desired state defined in your configuration. + +### State Management + +- `terraform show`: Displays information about the Terraform state. +- `terraform state list`: Lists all resources in the current state. + +### Resource Management + +- `terraform validate`: Checks the syntax of your configuration files for errors. +- `terraform fmt`: Formats your configuration files to follow Terraform’s style conventions. + +### Destroying Resources + +- `terraform destroy`: Removes all infrastructure defined in your Terraform configuration. + +## Getting Started with Terraform + +Terraform has a user-friendly [documentation](https://developer.hashicorp.com/terraform/tutorials/aws-get-started?product_intent=terraform) that can guide you step-by-step on how to start with AWS. + +Here is an exmaple `main.tf` on how to deploy an AWS Lambda function from **[spacelift](https://spacelift.io/blog/terraform-aws-lambda)** + +```bash +provider "aws" { + region = "ca-central-1" +} +resource "aws_iam_role" "lambda_role" { +name = "Spacelift_Test_Lambda_Function_Role" +assume_role_policy = <