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
> The timeout value must be bigger than the time it takes for your function to stream its output. Otherwise, the Lambda control plane will terminate the execution environment before your code has a chance to finish writing the stream. Here, the sample function stream responses during 10 seconds and we set the timeout for 15 seconds.
100
+
98
101
The `--architectures` flag is only required when you build the binary on an Apple Silicon machine (Apple M1 or more recent). It defaults to `x64`.
99
102
100
103
Be sure to set `AWS_ACCOUNT_ID` with your actual AWS account ID (for example: 012345678901).
101
104
102
-
### Invoke your Lambda function
105
+
### Step2: Give permission to invoke that function through an URL
106
+
107
+
Anyone with a valid signature from your AWS account will have permission to invoke the function through its URL.
108
+
109
+
```bash
110
+
aws lambda add-permission \
111
+
--function-name StreamingFromEvent \
112
+
--action lambda:InvokeFunctionUrl \
113
+
--principal ${AWS_ACCOUNT_ID} \
114
+
--function-url-auth-type AWS_IAM \
115
+
--statement-id allowURL
116
+
```
117
+
118
+
### Step3: Create the URL
103
119
104
-
To invoke the Lambda function, use the AWS CLI:
120
+
This creates [a URL with IAM authentication](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Only calls with a valid signature will be authorized.
To invoke the Lambda function, use `curl` with the AWS Sigv4 option to generate the signature.
143
+
144
+
Read the [AWS Credentials and Signature](../README.md/#AWS-Credentials-and-Signature) section for more details about the AWS Sigv4 protocol and how to obtain AWS credentials.
145
+
146
+
When you have the `aws` command line installed and configured, you will find the credentials in the `~/.aws/credentials` file.
Alternatively, you can use [AWS SAM](https://aws.amazon.com/serverless/sam/) to deploy the Lambda function.
184
+
185
+
**Prerequisites** : Install the [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
186
+
187
+
### SAM Template
188
+
189
+
The template file is provided as part of the example in the `template.yaml` file. It defines a Lambda function based on the binary ZIP file. It creates the function url with IAM authentication and sets the function timeout to 15 seconds.
190
+
191
+
```yaml
192
+
AWSTemplateFormatVersion: '2010-09-09'
193
+
Transform: AWS::Serverless-2016-10-31
194
+
Description: SAM Template for StreamingFromEvent Example
0 commit comments