Showing posts with label cloud. Show all posts
Showing posts with label cloud. Show all posts

Dec 19, 2019

AWS Lambda Functions

Create Lambda function

Go to AWS Lambda homepage and login to console.
Press "Create Function" button.
Enter function name.
Select a language (environment) from Runtime dropdown. I will use node.js 8.10.
For the first time you can create a new role for permissions. Select "Create a custom role" from Role dropdown box.
A new page will be shown. Select "Create a new IAM Role" from IMA Role dropdown and then give a name. Press "Allow" button.
This will create a new role and browser will return back to "Create function" page.
Press "Create function" button.
It will redirect you to function page.
Initially the page adds a template code which returns success code and a hello message. We will continue with this code.
 

exports.handler = async (event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
};

2. AWS CLI to call the function

Download AWS CLI setup to your computer. For Windows download link is here. For other operating systems you can find links at the same page.
After installation go to aws cli folder and run following command to start configuration.
aws configure
We need following info.
AWS Access Key ID [None]: "Your Access Key"
AWS Secret Access Key [None]: "Your Secret Key"
Default region name [None]: 
Default output format [None]: 
To get keys go to AWS console
Click to your name and select "My Security Credentials".
On "Access keys" section click to "Create New Access Key" button to create new keys. You have to save your secret key because it will displayed only once.
Now return back to aws cli console and enter Access Key ID and Secret Access Key.
Enter region name like "us-west-2".
Enter json for default output format.
Now you can run your functions.
We need our function name as a parameter. In lambda function page copy arn.
Run aws command to run function. The lines between "{ }" is the response from our lambda function. You can see hello message inside txt file which we passed as a parameter.
aws lambda invoke --function-name arn:aws:lambda:us-west-2:123456780315:function:FirstLambda "c:\aws.txt"

{
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
}
aws.txt file content
{"statusCode":200,"body":"\"Hello from Lambda!\""}

Feb 4, 2010

Cloud Computing

There are many discussions on the internet about cloud computing. Cloud is internet. But computing is a fuzzy word with cloud.
The best definition that i've seen is on wiki page. Please read it to get detailed explanation.
What i understand from Cloud Computing is "software as a service" concept.

The problems with software set up are:
  • installing an application,
  • downloading updates,
  • buying server to host application,
  • providing office spaces for server,
  • paying to set up server (physical set up-hardware, network-, software set up)
  • worrying about security,
  • buying expensive licences,
  • hiring experts with high costs.
These problems are general. But the question is which applications should we use as a service. Many applications need to be installed on the local of the corporation becasue they worry about their security especially about data security. What cloud computing offer is an alternative solution to use technology. It is a model and growing concept. We must take it into consideration.

If corporations use this model wisely then they will reduce costs. All of the problems that i mentioned above consume resources. Why do we buy Microsoft Office? Do we use all features? In the future we will use office as a service. Google started a big challenge with many services. Google Docs is a very sophisticated service. I use especially "service" keyword. Because we don't install anything. We don't keep any application files. We only use it.

I hope we will see many alternative services soon. Mail applications and office packages are only examples. We can connect those services together and reach them from everywhere.