1
00:00:00,420 --> 00:00:06,000
In this video we are going to learn how to use a lambda environment variables.

2
00:00:06,930 --> 00:00:11,660
Amongst variables, very important topics that we can use with the lambda functions.

3
00:00:11,670 --> 00:00:17,400
We can use variables to adjust our functions behavior without updating the code.

4
00:00:17,730 --> 00:00:23,910
An environment variable is a pair of strings that is stored in a function's version specific configuration.

5
00:00:24,270 --> 00:00:30,690
So it is lambda runtime makes environment variables available to our code and set additional environment

6
00:00:30,690 --> 00:00:35,370
variables that contain information about the function and the invocation of the request.

7
00:00:36,030 --> 00:00:41,310
So we can configure environment variables with using a case management console.

8
00:00:41,400 --> 00:00:44,550
Let me show from the management console first.

9
00:00:44,580 --> 00:00:52,470
Go to functions, go to my function three and if you click the configuration, we can set the environment

10
00:00:52,470 --> 00:00:54,390
variables to set and one with variable.

11
00:00:54,420 --> 00:00:59,790
Go to lambda console, open the function page, choose the function, choose the configuration and choose

12
00:00:59,790 --> 00:01:01,040
the environment variables.

13
00:01:01,050 --> 00:01:07,380
Here you can see the materials under the environment variables, we can choose the edit button and we

14
00:01:07,380 --> 00:01:09,630
can add the environment variable in here.

15
00:01:09,660 --> 00:01:12,210
For example, let me add an environment variable.

16
00:01:12,210 --> 00:01:18,360
The key could be the table name and table name will be the product.

17
00:01:19,170 --> 00:01:19,390
Okay.

18
00:01:19,440 --> 00:01:22,860
This will be the ah first environment variable for mind function three.

19
00:01:22,860 --> 00:01:24,780
Let me save here.

20
00:01:24,780 --> 00:01:31,590
You can see that we can add environment variable B using the management console and also we can configure

21
00:01:31,590 --> 00:01:37,710
in one service with Lambda API or a CDK, SLI or SDHC.

22
00:01:37,740 --> 00:01:41,760
So let me show you one example about a SLI.

23
00:01:41,790 --> 00:01:44,010
Please open the OR.

24
00:01:44,040 --> 00:01:50,100
We used to decode and create a Neve folder structure and open the command text file.

25
00:01:50,250 --> 00:01:57,960
You can see in here there's an example about how we can configure a mime to use with using the SQL Command,

26
00:01:57,960 --> 00:02:04,500
a lambda update function configuration and giving the function name and set the environment variables

27
00:02:04,500 --> 00:02:05,190
in here.

28
00:02:05,910 --> 00:02:12,090
So let me copy these lines and paste in here and hit enter.

29
00:02:14,400 --> 00:02:20,720
This will be edit or configuration and we can verify from the these configurations in here.

30
00:02:20,730 --> 00:02:22,950
Let me refresh this page.

31
00:02:25,510 --> 00:02:32,320
And see that the bucket employment variables is added in here and also key and final text value will

32
00:02:32,320 --> 00:02:34,030
be added or configurations.

33
00:02:34,030 --> 00:02:40,180
But you should be careful about that when ah, when we are performing the update function configuration,

34
00:02:40,180 --> 00:02:43,690
this is overriding our previous employment variables.

35
00:02:43,690 --> 00:02:49,360
So that's why we can add again the table name and table name is product.

36
00:02:49,660 --> 00:02:51,130
You should careful about that.

37
00:02:51,520 --> 00:02:52,620
Okay, very good.

38
00:02:52,630 --> 00:02:59,080
So we have seen how we can configure our environment variables with using the same commands.

39
00:02:59,080 --> 00:03:04,030
When you apply implement variable with the update function configuration command, the entire context

40
00:03:04,030 --> 00:03:08,740
of the variable structure is replaced in order to retain existing employment variables.

41
00:03:08,740 --> 00:03:12,520
When you add a new one, include all the existing in your values.

42
00:03:12,520 --> 00:03:19,450
In the request of these CLI or HDC commands, we can also get the current configuration in order to

43
00:03:19,450 --> 00:03:23,230
get the current configurations, use the get function configuration.

44
00:03:23,230 --> 00:03:27,640
You can see in this command a lambda get function configuration.

45
00:03:27,760 --> 00:03:31,480
This will be provide to get all configurations for us.

46
00:03:31,660 --> 00:03:33,700
Of course this will be my function three.

47
00:03:34,240 --> 00:03:35,950
Let's see how we can.

48
00:03:37,740 --> 00:03:41,380
It's all complications from the environment variables.

49
00:03:41,400 --> 00:03:46,370
If you hit the answer, you can see that this time we can see the environment variables.

50
00:03:46,380 --> 00:03:49,680
We have three minus variable table name, bucket and key.

51
00:03:49,800 --> 00:03:55,860
So we can retrieve environment variables with this way, but also we can retrieve these values into

52
00:03:55,860 --> 00:03:57,330
our lambda function code.

53
00:03:57,450 --> 00:04:02,550
This is a very powerful feature that we don't need to change code with using the environment variables.

54
00:04:02,670 --> 00:04:09,380
For example, I think that the table name information could be changed and you can only change the environment

55
00:04:09,390 --> 00:04:11,720
variable without touching any code line.

56
00:04:11,730 --> 00:04:17,340
So how we can retrieve these values in lambda function, you can see example in here.

57
00:04:17,370 --> 00:04:23,580
This is the an example, an example lambda function that we can get environment variables from the process

58
00:04:23,580 --> 00:04:29,880
that envy that the environment variable for example, a region table name and so on.

59
00:04:29,910 --> 00:04:36,750
This will be provided to get a variable in programmatically from the lambda functions and we are using

60
00:04:36,750 --> 00:04:38,810
the environment variable function in it.

61
00:04:38,820 --> 00:04:44,460
So this is the way how we can grab the environment variables in lambda function without touching any

62
00:04:44,460 --> 00:04:49,860
code we can change the table name from the event variables and the code will be reflect with newest

63
00:04:49,860 --> 00:04:51,000
and with variable.

64
00:04:51,750 --> 00:04:55,650
As you can see that we have seen how to use a lambda employment variables.
