You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Lambda Console page](https://console.aws.amazon.com/lambda/home) after
@@ -47,26 +47,26 @@ services (that seems to expand every week) so the best way to get around
47
47
is to select the search text box and search for "lambda" as shown in the
48
48
following screenshot.
49
49
50
-
<imgsrc="/img/170428-aws-lambda-python-2-7/search-for-lambda.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Search for lambda in the dashboard text box.">
50
+
<imgsrc="/img/170428-aws-lambda-python-2-7/search-for-lambda.jpg"width="100%"class="shot rnd outl"alt="Search for lambda in the dashboard text box.">
51
51
52
52
Press the "Create a Lambda function" button and you'll see the
53
53
"Select Blueprint" page.
54
54
55
-
<imgsrc="/img/170428-aws-lambda-python-2-7/select-blueprint.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="The select blueprint Lambda screen, where you should select Blank Function.">
55
+
<imgsrc="/img/170428-aws-lambda-python-2-7/select-blueprint.jpg"width="100%"class="shot rnd outl"alt="The select blueprint Lambda screen, where you should select Blank Function.">
56
56
57
57
Choose "Blank Function". The next screen gives the option to select a
58
58
"trigger", which is how the Lambda function gets executed. A trigger is
59
59
some event that is integrated with other AWS services and can be exposed
60
60
externally via an API or device such as Alexa.
61
61
62
-
<imgsrc="/img/170428-aws-lambda-python-2-7/configure-triggers.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Configure trigger screen, which we will not use for now because we will manually kick off our Lambda.">
62
+
<imgsrc="/img/170428-aws-lambda-python-2-7/configure-triggers.jpg"width="100%"class="shot rnd outl"alt="Configure trigger screen, which we will not use for now because we will manually kick off our Lambda.">
63
63
64
64
However, we aren't going to set up a trigger for this function because
65
65
we can manually test the Lambda later before connecting it to a trigger.
66
66
Leave the trigger icon blank and click the "Next" button to move along
Now we're on the screen where we can enter our specific configuration
72
72
and code for our new Lambda.
@@ -77,7 +77,7 @@ Start by entering a name for your Lambda function, such as "my_first_python_lamb
77
77
when you start using Lambda regularly to keep all your functions straight.
78
78
In the Runtime drop-down, select Python 2.7 as the execution language.
79
79
80
-
<imgsrc="/img/170428-aws-lambda-python-2-7/first-python-lambda.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Enter a name, description and select Python 2.7 on the Lambda configuration screen.">
80
+
<imgsrc="/img/170428-aws-lambda-python-2-7/first-python-lambda.jpg"width="100%"class="shot rnd outl"alt="Enter a name, description and select Python 2.7 on the Lambda configuration screen.">
81
81
82
82
Below the Runtime drop-down you'll see a large text box for writing code.
83
83
We can also choose to upload a ZIP file with our Python application which
@@ -124,7 +124,7 @@ whole number above 0 for `how_many_times`. Our Python code's error handling
124
124
is not very robust so a value other than a number in the `how_many_times`
125
125
variable will cause the script to throw an error when it is executed.
126
126
127
-
<imgsrc="/img/170428-aws-lambda-python-2-7/environment-variables.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Enter the exact keys of what_to_print and how_many_times along with corresponding values as environment variables.">
127
+
<imgsrc="/img/170428-aws-lambda-python-2-7/environment-variables.jpg"width="100%"class="shot rnd outl"alt="Enter the exact keys of what_to_print and how_many_times along with corresponding values as environment variables.">
128
128
129
129
Our code and environment variables are in place and we just need to set
130
130
a few more AWS-specific settings before we can test the Lambda function.
@@ -139,7 +139,7 @@ be `lambda_function.lambda_handler`. Select
139
139
"Role name" field enter "dynamodb_permissions". Under "Policy templates"
140
140
select the "Simple Microservice permissions".
141
141
142
-
<imgsrc="/img/170428-aws-lambda-python-2-7/lambda-handler-and-role.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="For the final configuration, keep the default handler, create a new role from a template for Simple Microservice permissions and save it with a unique name.">
142
+
<imgsrc="/img/170428-aws-lambda-python-2-7/lambda-handler-and-role.jpg"width="100%"class="shot rnd outl"alt="For the final configuration, keep the default handler, create a new role from a template for Simple Microservice permissions and save it with a unique name.">
143
143
144
144
The "Simple Microservice permissions" gives our Lambda access to
145
145
[AWS DynamoDB](https://aws.amazon.com/dynamodb/). We won't use DynamoDB in
@@ -149,29 +149,29 @@ storage when working with Lambda.
149
149
Now that our code and configuration is in place, click the "Next" button
150
150
at the bottom right corner of the page.
151
151
152
-
<imgsrc="/img/170428-aws-lambda-python-2-7/review-lambda.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="We can review the values set during our configuration.">
152
+
<imgsrc="/img/170428-aws-lambda-python-2-7/review-lambda.jpg"width="100%"class="shot rnd outl"alt="We can review the values set during our configuration.">
153
153
154
154
The review screen will show us our configuration settings. Scroll down
155
155
to the bottom and click the "Create function" button to continue.
156
156
157
-
<imgsrc="/img/170428-aws-lambda-python-2-7/create-function.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Click the create function button to continue.">
157
+
<imgsrc="/img/170428-aws-lambda-python-2-7/create-function.jpg"width="100%"class="shot rnd outl"alt="Click the create function button to continue.">
158
158
159
159
We should see a success message on the next page just below the
160
160
"Save and test" button.
161
161
162
-
<imgsrc="/img/170428-aws-lambda-python-2-7/save-and-test.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Save and test button.">
162
+
<imgsrc="/img/170428-aws-lambda-python-2-7/save-and-test.jpg"width="100%"class="shot rnd outl"alt="Save and test button.">
163
163
164
164
Press the "Test" button to execute the Lambda. Lambda prompts us for
165
165
some data to simulate an event that would trigger our function. Select
166
166
the "Hello World" sample event template, which contains some example keys.
167
167
Our Lambda will not those keys in its execution so it does not matter what
168
168
they are. Click the "Save and test" button at the bottom of the modal.
169
169
170
-
<imgsrc="/img/170428-aws-lambda-python-2-7/sample-event-template.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Sample event template for our Lambda execution.">
170
+
<imgsrc="/img/170428-aws-lambda-python-2-7/sample-event-template.jpg"width="100%"class="shot rnd outl"alt="Sample event template for our Lambda execution.">
171
171
172
172
Scroll down to the "Execution result" section where we can see our output.
173
173
174
-
<imgsrc="/img/170428-aws-lambda-python-2-7/execution-results.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Execution results from running our Lambda function.">
174
+
<imgsrc="/img/170428-aws-lambda-python-2-7/execution-results.jpg"width="100%"class=""alt="Execution results from running our Lambda function.">
175
175
176
176
We get the log output that shows us the return value of our function. In
177
177
this case it is the string message from `what_to_print`. We can also see
Copy file name to clipboardExpand all lines: content/posts/170429-python-3-6-aws-lambda.markdown
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,20 +43,20 @@ If using Python 2 is still your jam rather than Python 3, take a look at
43
43
Sign up for a new [Amazon Web Services account](https://aws.amazon.com/),
44
44
which provides a generous free tier, or use your existing AWS account.
45
45
46
-
<imgsrc="/img/170429-aws-lambda-python-3-6/aws-amazon-com.jpg"width="100%"class="technical-diagram img-rounded"alt="AWS Lambda landing and sign in screen.">
46
+
<imgsrc="/img/170429-aws-lambda-python-3-6/aws-amazon-com.jpg"width="100%"class="shot outl rnd"alt="AWS Lambda landing and sign in screen.">
47
47
48
48
After signing up a few tutorials may pop up, but skip past them and
49
49
go to the main Console. AWS has tons of services, with more being added
50
50
every month, so using the search box is the best way to get around.
51
51
Select the search text box, enter "lambda" and select "Lambda" to get to
52
52
the Lambda starting page.
53
53
54
-
<imgsrc="/img/170429-aws-lambda-python-3-6/search-for-lambda.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Search for lambda in the dashboard text box.">
54
+
<imgsrc="/img/170429-aws-lambda-python-3-6/search-for-lambda.jpg"width="100%"class="shot rnd outl"alt="Search for lambda in the dashboard text box.">
55
55
56
56
Click the "Create a Lambda function" button. The "Select Blueprint" page
Next we get to the "Configure function" screen where we can finally write
77
77
some code!
@@ -84,7 +84,7 @@ when you have a dozens or hundreds of different Lambda functions and
84
84
need to keep them straight. In the Runtime drop-down, select Python 3.6 for
85
85
the programming language.
86
86
87
-
<imgsrc="/img/170429-aws-lambda-python-3-6/python-3-6-lambda.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Enter a name, description and use Python 3.6 for the Lambda.">
87
+
<imgsrc="/img/170429-aws-lambda-python-3-6/python-3-6-lambda.jpg"width="100%"class="shot outl rnd"alt="Enter a name, description and use Python 3.6 for the Lambda.">
88
88
89
89
Beneath the Runtime drop-down there is a large text box for code,
90
90
prepopulated with a `lambda_handler` function definition. The
@@ -137,7 +137,7 @@ is not very robust so a value other than a number in the `how_many_times`
137
137
variable will cause the script to throw an error when it is executed due
138
138
to the forced casting of `how_many_times` via the `int()` function.
139
139
140
-
<imgsrc="/img/170429-aws-lambda-python-3-6/environment-variables.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Section to set environment variables for the Lambda function.">
140
+
<imgsrc="/img/170429-aws-lambda-python-3-6/environment-variables.jpg"width="100%"class="shot rnd outl"alt="Section to set environment variables for the Lambda function.">
141
141
142
142
The Python 3.6 code and the environment variables are now in place. We
143
143
just need to handle a few more AWS-specific settings before we can test the
@@ -159,34 +159,34 @@ The "Simple Microservice permissions" allows our Lambda to access
159
159
this tutorial but the service is commonly used either as permanent or
160
160
temporary storage for Lambda functions.
161
161
162
-
<imgsrc="/img/170429-aws-lambda-python-3-6/lambda-handler-and-role.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="For the final configuration, keep the default handler, create a new role from a template for Simple Microservice permissions and save it with a unique name.">
162
+
<imgsrc="/img/170429-aws-lambda-python-3-6/lambda-handler-and-role.jpg"width="100%"class="shot rnd outl"alt="For the final configuration, keep the default handler, create a new role from a template for Simple Microservice permissions and save it with a unique name.">
163
163
164
164
Our code and configuration is in place so click the "Next" button
The review screen shows us our configuration settings to make sure we
170
170
selected the appropriate values for our new Lambda function. Scroll down
171
171
press "Create function".
172
172
173
-
<imgsrc="/img/170429-aws-lambda-python-3-6/create-function.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Click the create function button to continue.">
173
+
<imgsrc="/img/170429-aws-lambda-python-3-6/create-function.jpg"width="100%"class="shot rnd outl"alt="Click the create function button to continue.">
174
174
175
175
Success message should appear on the next page below the "Test" button.
176
176
177
-
<imgsrc="/img/170429-aws-lambda-python-3-6/test.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Test button on the execution screen.">
177
+
<imgsrc="/img/170429-aws-lambda-python-3-6/test.jpg"width="100%"class="shot outl rnd"alt="Test button on the execution screen.">
178
178
179
179
Click the "Test" button to execute the Lambda. Lambda will prompt us for
180
180
some data to simulate an event that would kick off our function. Select
181
181
the "Hello World" sample event template, which contains some keys but our
182
182
Lambda will not use that in its execution. Click the "Save and test" button
183
183
at the bottom of the modal.
184
184
185
-
<imgsrc="/img/170429-aws-lambda-python-3-6/sample-event-template.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Sample event template for Lambda execution.">
185
+
<imgsrc="/img/170429-aws-lambda-python-3-6/sample-event-template.jpg"width="100%"class="shot outl rnd"alt="Sample event template for Lambda execution.">
186
186
187
187
Scroll down to the "Execution result" section where we can see our output.
188
188
189
-
<imgsrc="/img/170429-aws-lambda-python-3-6/execution-results.jpg"width="100%"class="technical-diagram img-rounded bordered"alt="Results from executing our new Lambda function.">
189
+
<imgsrc="/img/170429-aws-lambda-python-3-6/execution-results.jpg"width="100%"class="shot outl rnd"alt="Results from executing our new Lambda function.">
190
190
191
191
The log output shows us the return value of our function, which in this
192
192
execution was the string message from `what_to_print`. We can also see
0 commit comments