Skip to content

Commit a106493

Browse files
committed
New CLI Examples for AWS Lambda service
1 parent 3058c5f commit a106493

38 files changed

Lines changed: 1013 additions & 0 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
**To add permissions to a layer version**
2+
3+
The following ``add-layer-version-permission`` example grants permission for the specified account to use version 1 of the layer ``my-layer``. ::
4+
5+
aws lambda add-layer-version-permission \
6+
--layer-name my-layer \
7+
--statement-id xaccount \
8+
--action lambda:GetLayerVersion \
9+
--principal 123456789012 \
10+
--version-number 1
11+
12+
Output::
13+
14+
{
15+
"RevisionId": "35d87451-f796-4a3f-a618-95a3671b0a0c",
16+
"Statement":
17+
{
18+
"Sid":"xaccount",
19+
"Effect":"Allow",
20+
"Principal":{
21+
"AWS":"arn:aws:iam::210987654321:root"
22+
},
23+
"Action":"lambda:GetLayerVersion",
24+
"Resource":"arn:aws:lambda:us-east-2:123456789012:layer:my-layer:1"
25+
}
26+
}
27+
28+
For more information, see `AWS Lambda Layers <https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
**To add permissions to an existing Lambda function**
2+
3+
The following ``add-permission`` example grants the Amazon SNS service permission to invoke a function named ``my-function``. ::
4+
5+
aws lambda add-permission \
6+
--function-name my-function \
7+
--action lambda:InvokeFunction \
8+
--statement-id sns \
9+
--principal sns.amazonaws.com
10+
11+
Output::
12+
13+
{
14+
"Statement":
15+
{
16+
"Sid":"sns",
17+
"Effect":"Allow",
18+
"Principal":{
19+
"Service":"sns.amazonaws.com"
20+
},
21+
"Action":"lambda:InvokeFunction",
22+
"Resource":"arn:aws:lambda:us-east-2:123456789012:function:my-function"
23+
}
24+
}
25+
26+
For more information, see `Using Resource-based Policies for AWS Lambda <https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
**To create an alias for a Lambda function**
2+
3+
The following ``create-alias`` example creates an alias named ``LIVE`` that points to version 1 of the ``my-function`` Lambda function. ::
4+
5+
aws lambda create-alias \
6+
--function-name my-function \
7+
--description "alias for live version of function" \
8+
--function-version 1 \
9+
--name LIVE
10+
11+
Output::
12+
13+
{
14+
"FunctionVersion": "1",
15+
"Name": "LIVE",
16+
"AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:LIVE",
17+
"RevisionId": "873282ed-4cd3-4dc8-a069-d0c647e470c6",
18+
"Description": "alias for live version of function"
19+
}
20+
21+
For more information, see `Configuring AWS Lambda Function Aliases <https://docs.aws.amazon.com/lambda/latest/dg/aliases-intro.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
**To create a mapping between an event source and an AWS Lambda function**
2+
3+
The following ``create-event-source-mapping`` example creates a mapping between an SQS queue and the ``my-function`` Lambda function. ::
4+
5+
aws lambda create-event-source-mapping \
6+
--function-name my-function \
7+
--batch-size 5 \
8+
--event-source-arn arn:aws:sqs:us-west-2:123456789012:mySQSqueue
9+
10+
Output::
11+
12+
{
13+
"UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
14+
"StateTransitionReason": "USER_INITIATED",
15+
"LastModified": 1569284520.333,
16+
"BatchSize": 5,
17+
"State": "Creating",
18+
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
19+
"EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue"
20+
}
21+
22+
For more information, see `AWS Lambda Event Source Mapping <https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
**To create a Lambda function**
2+
3+
The following ``create-function`` example creates a Lambda function named ``my-function``. ::
4+
5+
aws lambda create-function \
6+
--function-name my-function \
7+
--runtime nodejs10.x \
8+
--zip-file fileb://my-function.zip \
9+
--handler my-function.handler \
10+
--role arn:aws:iam::123456789012:role/service-role/MyTestFunction-role-tges6bf4
11+
12+
Contents of ``my-function.zip``:
13+
This file is a deployment package that contains your function code and any dependencies.
14+
15+
Output::
16+
17+
{
18+
"TracingConfig": {
19+
"Mode": "PassThrough"
20+
},
21+
"CodeSha256": "PFn4S+er27qk+UuZSTKEQfNKG/XNn7QJs90mJgq6oH8=",
22+
"FunctionName": "my-function",
23+
"CodeSize": 308,
24+
"RevisionId": "873282ed-4cd3-4dc8-a069-d0c647e470c6",
25+
"MemorySize": 128,
26+
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
27+
"Version": "$LATEST",
28+
"Role": "arn:aws:iam::123456789012:role/service-role/MyTestFunction-role-zgur6bf4",
29+
"Timeout": 3,
30+
"LastModified": "2019-08-14T22:26:11.234+0000",
31+
"Handler": "my-function.handler",
32+
"Runtime": "nodejs10.x",
33+
"Description": ""
34+
}
35+
36+
For more information, see `AWS Lambda Function Configuration <https://docs.aws.amazon.com/lambda/latest/dg/resource-model.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**To delete an alias of a Lambda function**
2+
3+
The following ``delete-alias`` example deletes the alias named ``LIVE`` from the ``my-function`` Lambda function. ::
4+
5+
aws lambda delete-alias \
6+
--function-name my-function \
7+
--name LIVE
8+
9+
This command produces no output.
10+
11+
For more information, see `Configuring AWS Lambda Function Aliases <https://docs.aws.amazon.com/lambda/latest/dg/aliases-intro.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
**To delete the mapping between an event source and an AWS Lambda function**
2+
3+
The following ``delete-event-source-mapping`` example deletes the mapping between an SQS queue and the ``my-function`` Lambda function. ::
4+
5+
aws lambda delete-event-source-mapping \
6+
--uuid a1b2c3d4-5678-90ab-cdef-11111EXAMPLE
7+
8+
Output::
9+
10+
{
11+
"UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE",
12+
"StateTransitionReason": "USER_INITIATED",
13+
"LastModified": 1569285870.271,
14+
"BatchSize": 5,
15+
"State": "Deleting",
16+
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
17+
"EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue"
18+
}
19+
20+
For more information, see `AWS Lambda Event Source Mapping <https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**To remove the reserved concurrent execution limit from a function**
2+
3+
The following ``delete-function-concurrency`` example deletes the reserved concurrent execution limit from the ``my-function`` function. ::
4+
5+
aws lambda delete-function-concurrency \
6+
--function-name my-function
7+
8+
This command produces no output.
9+
10+
For more information, see `Reserving Concurrency for a Lambda Function <https://docs.aws.amazon.com/lambda/latest/dg/per-function-concurrency.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**To delete a Lambda function**
2+
3+
The following ``delete-function`` example deletes the Lambda function named ``my-function``. ::
4+
5+
aws lambda delete-function \
6+
--function-name my-function
7+
8+
This command produces no output.
9+
10+
For more information, see `AWS Lambda Function Configuration <https://docs.aws.amazon.com/lambda/latest/dg/resource-model.html>`__ in the *AWS Lambda Developer Guide*.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**To delete a version of a Lambda layer**
2+
3+
The following ``delete-layer-version`` example deletes version 2 of the layer named ``my-layer``. ::
4+
5+
aws lambda delete-layer-version \
6+
--layer-name my-layer \
7+
--version-number 2
8+
9+
This command produces no output.
10+
11+
For more information, see `AWS Lambda Layers <https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html>`__ in the *AWS Lambda Developer Guide*.

0 commit comments

Comments
 (0)