AWS Chalice Introduction
Tags: aws, serverless, awslambda
Published: 2024-02-01 21:38:52

First of all, it’s worth starting with the definition “serverless” actually simply; “It’s a native in the cloud that allows developers to build and run applications without having to manage servers development model. “[1]

In this series, I will only talk about AWS from providers and try to tell as much as I can. Missing etc necessarily happens if you say aa look here is very important how did you skip let’s get in touch. First of all, let’s start with which languages/languages are written? In fact, almost most languages are supported by NodeJS, Go, Python, Rust, Java, etc.

The question of which language should be written is, it remains to me, write with it if you know what you know well, but if it comes to performance and speed, there are a lot of benchmarks made I see as far as I read Rust and Go They’re going head to head right now, and Node vs Python is coming, I think the last ones are Java and C# [2]. In this article series, we will go through Chalice simply Chalice, a Serverless framework derived from the Flask framework. So why I love this is actually the reason of simplicity. As someone who used AWS SAM, Zappa or Serverless Framework, I will say that if you want to do something serverless through python, your man is Chalice!

`pip install chalice`

If we want to create a project, we just say `chalice new-project` and choose what works for us from the options.

 

![welcome](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aw05bfgqb7zho2fk9yi2.png)

The screen you have seen is in fact the introduction of a project called podtube that I created, my goal is to use milk from flesh as much as I can in this article series and scribble something about chalice.

I’m starting with deploy, realizing that our AWS Credentials are ready, all we have to do is;

    `chalice deploy`

yes we really deploy in such a simple way

    `chalice delete`

We can delete it by saying. Here you may come up with a question to say “what are we going to do if we want to deploy separately for separate prod for testing?” or “we need to push this in a different Aws account, but this is constantly going to our default account, what should we do?” Let’s try to quickly answer these questions first we need the config.json file so that we can distinguish the test/prod part.

When we go in .chalice you will see the config file here we can actually divide it into test and prod we can specify which lambda will run with how many rams or here env I will write a config in which they are all included in terms of being a random example in a complex way for now we are able to define.

```
{
  "version": "2.0",
  "app_name": "podtube",
  "automatic_layer": true,
  "stages": {
    "dev": {
      "lambda_memory_size": 10240,
      "reserved_concurrency": 100,
      "lambda_timeout": 900,
      "api_gateway_stage": "api",
      "autogen_policy": false,
      "api_gateway_policy_file": "policy-dev.json",
        "environment_variables": {
          "AWS_ACCESS_KEY_ID_IG": "BLA",
          "AWS_ACCESS_SECRET_KEY_IG": "SECRET-BLA"
      }
    },
    "test": {
      "lambda_memory_size": 1024,
      "reserved_concurrency": 100,
      "lambda_timeout": 900,
      "api_gateway_policy_file": "policy-test.json"
    }
  }
}
```

What you saw above is that I have allocated the application to 2 stages on the dev side specifically reserved concurrency and set memory to you where api_gateway_policy file is again simply to which AWS services Let the relevant example lambda S3 access to SNS, just like you listen to this.

Now we can use this command line

`chalice deploy --stage test`

Here is the most important point:

If you say Automatic Layer True, all the libraries that you use in the application chalice zips and pushups there by creating a layer under lambda.

Another question is that the work of switching between users is actually the point that we have to do there is even simpler let’s say you went through the terminal

`tail -100 ~/.aws/credentials`

you have seen your registered accounts if your company/person or institution you are consulting is not using AWS and you are only using it as a hobby/your own business, most likely just default account If you will see, otherwise you will also have seen the accounts you added. Here, all we have to do is

`chalice deploy --profile profile-name`

This post was a bit short, but it can be called the ideal length for the start. In the next post, we will look at the concepts of endpoint, pure lambda, and chalice schedule cron. Pleasurable days.