This content originally appeared on DEV Community and was authored by prathamesh gawade
In the chaotic world of cloud and DevOps, it’s easy to get overwhelmed by the sheer number of services and resources available. However, from a developer's perspective, only a few AWS services are practically useful. In this blog, I will share essential AWS services that every developer should be familiar with when working with AWS.
Most AWS services won't need you to own an AWS account but you can use Secret credentials and permissions to access the already-created resources.
1. S3 (Simple Storage Service)
This is the most important and used service. S3 is a storage platform used to store files/videos/images etc. S3 provides the cheapest cloud storage along with website hosting options(more about this in another blog). As a developer, you will be using this service frequently to store the user files.
S3 can be used flexibly to store and fetch the files.
Below is one of the methods to store the files on S3 from your server.
// Access Key and Secret Key are credentials used for accessing AWS resources
// Configure credentials for accessing the bucket
const s3 = new AWS.S3({
accessKeyId: 'your-access-key-id',
secretAccessKey: 'your-secret-access-key',
region: 'your-region'
});
// Use S3.upload method to upload a local file to S3
const uploadParams = {
Bucket: 'your-bucket-name',
Key: 'your/file/path/filename.ext',
Body: fs.createReadStream('path/to/your/local/file')
};
s3.upload(uploadParams).promise();
S3 API Reference - https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-s3/
EC2 - Elastic Cloud Computing
EC2 is a Virtual Machine that allows you to run servers. EC2 is an extremely flexible service to use, You can use VM for almost any requirement hence it is trendy among developers.
You can serve Frontend applications, run backend servers, Install and use Databases, Dockers applications, Remote desktops, and more.
Create EC2 Instance:
Launch an Instance: Login to AWS (You will need an AWS account). Navigate to the EC2 instance and launch a new instance in the Public subnet (Launch an EC2 with an internet gateway attached).
Security Configuration: Required ports should be open (E.g. for SSH, port 22 should be open) and allowed to your IP. You also create a pem key (security key) used as a credential.
Connect to Instance
Once your instance is running, you can connect to it using the following command:
ssh -i key.pem username@ip-of-instance
// which usually looks like - ssh -i DevEC2Key.pem ubuntu@112.33.12.18
3. Lambda
AWS Lambda is a serverless computing service that allows you to run code without provisioning or managing servers. With Lambda, you can Invoke the function as per your requirements, such as changes in S3 buckets, You can offload Memory-intensive tasks to lambda such as Image or video processing.
How to Use Lambda
- Create a lambda function: Login to AWS management console and navigate to lambda, Create a new function
You can create the simplest function such as
exports.handler = async (event) => {
console.log('Received event:', JSON.stringify(event, null, 2));
return 'Hello from Lambda!';
}
Once the lambda function is deployed it is ready to use.
You have to invoke the lambda function
- Invoke Lambda Function
// Configure the AWS SDK with your credentials
// Create an instance of the Lambda service
const lambda = new AWS.Lambda();
// Set up the parameters for invoking the Lambda function
const params = {
FunctionName: 'YourLambdaFunctionName', // Replace with your Lambda function's name
InvocationType: 'RequestResponse', // 'Event' for async, 'RequestResponse' for sync
Payload: JSON.stringify({
key1: 'value1',
})
};
// Invoke the Lambda function
lambda.invoke(params, (err, data) => {
if (err) {
console.error('Error invoking Lambda function:', err);
} else {
console.log('Lambda function invoked successfully. Response:', data.Payload);
}
});
These are the most common services and we have yet to explore many more...
Thank you for your time.
Later.
This content originally appeared on DEV Community and was authored by prathamesh gawade
prathamesh gawade | Sciencx (2024-08-20T04:55:36+00:00) Top 3 AWS Services Every Developer Should know. Retrieved from https://www.scien.cx/2024/08/20/top-3-aws-services-every-developer-should-know/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.