Skip to content

Commit ab843b8

Browse files
author
awstools
committed
feat(clients): update command documentation examples as of 2024-09-20
1 parent cdacf56 commit ab843b8

File tree

48 files changed

+1330
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1330
-0
lines changed

clients/client-lambda/src/commands/AddLayerVersionPermissionCommand.ts

+21
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ export interface AddLayerVersionPermissionCommandOutput extends AddLayerVersionP
9999
* <p>Base exception class for all service exceptions from Lambda service.</p>
100100
*
101101
* @public
102+
* @example To add permissions to a layer version
103+
* ```javascript
104+
* // The following example grants permission for the account 223456789012 to use version 1 of a layer named my-layer.
105+
* const input = {
106+
* "Action": "lambda:GetLayerVersion",
107+
* "LayerName": "my-layer",
108+
* "Principal": "223456789012",
109+
* "StatementId": "xaccount",
110+
* "VersionNumber": 1
111+
* };
112+
* const command = new AddLayerVersionPermissionCommand(input);
113+
* const response = await client.send(command);
114+
* /* response ==
115+
* {
116+
* "RevisionId": "35d87451-f796-4a3f-a618-95a3671b0a0c",
117+
* "Statement": "{\"Sid\":\"xaccount\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::223456789012:root\"},\"Action\":\"lambda:GetLayerVersion\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:layer:my-layer:1\"}"
118+
* }
119+
* *\/
120+
* // example id: to-add-permissions-to-a-layer-version-1586479797163
121+
* ```
122+
*
102123
*/
103124
export class AddLayerVersionPermissionCommand extends $Command
104125
.classBuilder<

clients/client-lambda/src/commands/AddPermissionCommand.ts

+40
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,46 @@ export interface AddPermissionCommandOutput extends AddPermissionResponse, __Met
114114
* <p>Base exception class for all service exceptions from Lambda service.</p>
115115
*
116116
* @public
117+
* @example To grant Amazon S3 permission to invoke a function
118+
* ```javascript
119+
* // The following example adds permission for Amazon S3 to invoke a Lambda function named my-function for notifications from a bucket named my-bucket-1xpuxmplzrlbh in account 123456789012.
120+
* const input = {
121+
* "Action": "lambda:InvokeFunction",
122+
* "FunctionName": "my-function",
123+
* "Principal": "s3.amazonaws.com",
124+
* "SourceAccount": "123456789012",
125+
* "SourceArn": "arn:aws:s3:::my-bucket-1xpuxmplzrlbh/*",
126+
* "StatementId": "s3"
127+
* };
128+
* const command = new AddPermissionCommand(input);
129+
* const response = await client.send(command);
130+
* /* response ==
131+
* {
132+
* "Statement": "{\"Sid\":\"s3\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"s3.amazonaws.com\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:function:my-function\",\"Condition\":{\"StringEquals\":{\"AWS:SourceAccount\":\"123456789012\"},\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:s3:::my-bucket-1xpuxmplzrlbh\"}}}"
133+
* }
134+
* *\/
135+
* // example id: add-permission-1474651469455
136+
* ```
137+
*
138+
* @example To grant another account permission to invoke a function
139+
* ```javascript
140+
* // The following example adds permission for account 223456789012 invoke a Lambda function named my-function.
141+
* const input = {
142+
* "Action": "lambda:InvokeFunction",
143+
* "FunctionName": "my-function",
144+
* "Principal": "223456789012",
145+
* "StatementId": "xaccount"
146+
* };
147+
* const command = new AddPermissionCommand(input);
148+
* const response = await client.send(command);
149+
* /* response ==
150+
* {
151+
* "Statement": "{\"Sid\":\"xaccount\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::223456789012:root\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:us-east-2:123456789012:function:my-function\"}"
152+
* }
153+
* *\/
154+
* // example id: add-permission-1474651469456
155+
* ```
156+
*
117157
*/
118158
export class AddPermissionCommand extends $Command
119159
.classBuilder<

clients/client-lambda/src/commands/CreateAliasCommand.ts

+23
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@ export interface CreateAliasCommandOutput extends AliasConfiguration, __Metadata
9393
* <p>Base exception class for all service exceptions from Lambda service.</p>
9494
*
9595
* @public
96+
* @example To create an alias for a Lambda function
97+
* ```javascript
98+
* // The following example creates an alias named LIVE that points to version 1 of the my-function Lambda function.
99+
* const input = {
100+
* "Description": "alias for live version of function",
101+
* "FunctionName": "my-function",
102+
* "FunctionVersion": "1",
103+
* "Name": "LIVE"
104+
* };
105+
* const command = new CreateAliasCommand(input);
106+
* const response = await client.send(command);
107+
* /* response ==
108+
* {
109+
* "AliasArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:LIVE",
110+
* "Description": "alias for live version of function",
111+
* "FunctionVersion": "1",
112+
* "Name": "LIVE",
113+
* "RevisionId": "873282ed-xmpl-4dc8-a069-d0c647e470c6"
114+
* }
115+
* *\/
116+
* // example id: to-create-an-alias-for-a-lambda-function-1586480324259
117+
* ```
118+
*
96119
*/
97120
export class CreateAliasCommand extends $Command
98121
.classBuilder<

clients/client-lambda/src/commands/CreateEventSourceMappingCommand.ts

+24
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,30 @@ export interface CreateEventSourceMappingCommandOutput extends EventSourceMappin
322322
* <p>Base exception class for all service exceptions from Lambda service.</p>
323323
*
324324
* @public
325+
* @example To create a mapping between an event source and an AWS Lambda function
326+
* ```javascript
327+
* // The following example creates a mapping between an SQS queue and the my-function Lambda function.
328+
* const input = {
329+
* "BatchSize": 5,
330+
* "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:my-queue",
331+
* "FunctionName": "my-function"
332+
* };
333+
* const command = new CreateEventSourceMappingCommand(input);
334+
* const response = await client.send(command);
335+
* /* response ==
336+
* {
337+
* "BatchSize": 5,
338+
* "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:my-queue",
339+
* "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
340+
* "LastModified": 1569284520.333,
341+
* "State": "Creating",
342+
* "StateTransitionReason": "USER_INITIATED",
343+
* "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE"
344+
* }
345+
* *\/
346+
* // example id: to-create-a-mapping-between-an-event-source-and-an-aws-lambda-function-1586480555467
347+
* ```
348+
*
325349
*/
326350
export class CreateEventSourceMappingCommand extends $Command
327351
.classBuilder<

clients/client-lambda/src/commands/CreateFunctionCommand.ts

+64
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,70 @@ export interface CreateFunctionCommandOutput extends FunctionConfiguration, __Me
300300
* <p>Base exception class for all service exceptions from Lambda service.</p>
301301
*
302302
* @public
303+
* @example To create a function
304+
* ```javascript
305+
* // The following example creates a function with a deployment package in Amazon S3 and enables X-Ray tracing and environment variable encryption.
306+
* const input = {
307+
* "Code": {
308+
* "S3Bucket": "my-bucket-1xpuxmplzrlbh",
309+
* "S3Key": "function.zip"
310+
* },
311+
* "Description": "Process image objects from Amazon S3.",
312+
* "Environment": {
313+
* "Variables": {
314+
* "BUCKET": "my-bucket-1xpuxmplzrlbh",
315+
* "PREFIX": "inbound"
316+
* }
317+
* },
318+
* "FunctionName": "my-function",
319+
* "Handler": "index.handler",
320+
* "KMSKeyArn": "arn:aws:kms:us-west-2:123456789012:key/b0844d6c-xmpl-4463-97a4-d49f50839966",
321+
* "MemorySize": 256,
322+
* "Publish": true,
323+
* "Role": "arn:aws:iam::123456789012:role/lambda-role",
324+
* "Runtime": "nodejs12.x",
325+
* "Tags": {
326+
* "DEPARTMENT": "Assets"
327+
* },
328+
* "Timeout": 15,
329+
* "TracingConfig": {
330+
* "Mode": "Active"
331+
* }
332+
* };
333+
* const command = new CreateFunctionCommand(input);
334+
* const response = await client.send(command);
335+
* /* response ==
336+
* {
337+
* "CodeSha256": "YFgDgEKG3ugvF1+pX64gV6tu9qNuIYNUdgJm8nCxsm4=",
338+
* "CodeSize": 5797206,
339+
* "Description": "Process image objects from Amazon S3.",
340+
* "Environment": {
341+
* "Variables": {
342+
* "BUCKET": "my-bucket-1xpuxmplzrlbh",
343+
* "PREFIX": "inbound"
344+
* }
345+
* },
346+
* "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
347+
* "FunctionName": "my-function",
348+
* "Handler": "index.handler",
349+
* "KMSKeyArn": "arn:aws:kms:us-west-2:123456789012:key/b0844d6c-xmpl-4463-97a4-d49f50839966",
350+
* "LastModified": "2020-04-10T19:06:32.563+0000",
351+
* "LastUpdateStatus": "Successful",
352+
* "MemorySize": 256,
353+
* "RevisionId": "b75dcd81-xmpl-48a8-a75a-93ba8b5b9727",
354+
* "Role": "arn:aws:iam::123456789012:role/lambda-role",
355+
* "Runtime": "nodejs12.x",
356+
* "State": "Active",
357+
* "Timeout": 15,
358+
* "TracingConfig": {
359+
* "Mode": "Active"
360+
* },
361+
* "Version": "1"
362+
* }
363+
* *\/
364+
* // example id: to-create-a-function-1586492061186
365+
* ```
366+
*
303367
*/
304368
export class CreateFunctionCommand extends $Command
305369
.classBuilder<

clients/client-lambda/src/commands/DeleteAliasCommand.ts

+12
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ export interface DeleteAliasCommandOutput extends __MetadataBearer {}
6767
* <p>Base exception class for all service exceptions from Lambda service.</p>
6868
*
6969
* @public
70+
* @example To delete a Lambda function alias
71+
* ```javascript
72+
* // The following example deletes an alias named BLUE from a function named my-function
73+
* const input = {
74+
* "FunctionName": "my-function",
75+
* "Name": "BLUE"
76+
* };
77+
* const command = new DeleteAliasCommand(input);
78+
* await client.send(command);
79+
* // example id: to-delete-a-lambda-function-alias-1481660370804
80+
* ```
81+
*
7082
*/
7183
export class DeleteAliasCommand extends $Command
7284
.classBuilder<

clients/client-lambda/src/commands/DeleteEventSourceMappingCommand.ts

+22
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,28 @@ export interface DeleteEventSourceMappingCommandOutput extends EventSourceMappin
150150
* <p>Base exception class for all service exceptions from Lambda service.</p>
151151
*
152152
* @public
153+
* @example To delete a Lambda function event source mapping
154+
* ```javascript
155+
* // The following example deletes an event source mapping. To get a mapping's UUID, use ListEventSourceMappings.
156+
* const input = {
157+
* "UUID": "14e0db71-xmpl-4eb5-b481-8945cf9d10c2"
158+
* };
159+
* const command = new DeleteEventSourceMappingCommand(input);
160+
* const response = await client.send(command);
161+
* /* response ==
162+
* {
163+
* "BatchSize": 5,
164+
* "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:my-queue",
165+
* "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function",
166+
* "LastModified": "${timestamp}",
167+
* "State": "Enabled",
168+
* "StateTransitionReason": "USER_INITIATED",
169+
* "UUID": "14e0db71-xmpl-4eb5-b481-8945cf9d10c2"
170+
* }
171+
* *\/
172+
* // example id: to-delete-a-lambda-function-event-source-mapping-1481658973862
173+
* ```
174+
*
153175
*/
154176
export class DeleteEventSourceMappingCommand extends $Command
155177
.classBuilder<

clients/client-lambda/src/commands/DeleteFunctionCommand.ts

+12
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ export interface DeleteFunctionCommandOutput extends __MetadataBearer {}
7474
* <p>Base exception class for all service exceptions from Lambda service.</p>
7575
*
7676
* @public
77+
* @example To delete a version of a Lambda function
78+
* ```javascript
79+
* // The following example deletes version 1 of a Lambda function named my-function.
80+
* const input = {
81+
* "FunctionName": "my-function",
82+
* "Qualifier": "1"
83+
* };
84+
* const command = new DeleteFunctionCommand(input);
85+
* await client.send(command);
86+
* // example id: to-delete-a-lambda-function-1481648553696
87+
* ```
88+
*
7789
*/
7890
export class DeleteFunctionCommand extends $Command
7991
.classBuilder<

clients/client-lambda/src/commands/DeleteFunctionConcurrencyCommand.ts

+11
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ export interface DeleteFunctionConcurrencyCommandOutput extends __MetadataBearer
6969
* <p>Base exception class for all service exceptions from Lambda service.</p>
7070
*
7171
* @public
72+
* @example To remove the reserved concurrent execution limit from a function
73+
* ```javascript
74+
* // The following example deletes the reserved concurrent execution limit from a function named my-function.
75+
* const input = {
76+
* "FunctionName": "my-function"
77+
* };
78+
* const command = new DeleteFunctionConcurrencyCommand(input);
79+
* await client.send(command);
80+
* // example id: to-remove-the-reserved-concurrent-execution-limit-from-a-function-1586480714680
81+
* ```
82+
*
7283
*/
7384
export class DeleteFunctionConcurrencyCommand extends $Command
7485
.classBuilder<

clients/client-lambda/src/commands/DeleteFunctionEventInvokeConfigCommand.ts

+12
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ export interface DeleteFunctionEventInvokeConfigCommandOutput extends __Metadata
7474
* <p>Base exception class for all service exceptions from Lambda service.</p>
7575
*
7676
* @public
77+
* @example To delete an asynchronous invocation configuration
78+
* ```javascript
79+
* // The following example deletes the asynchronous invocation configuration for the GREEN alias of a function named my-function.
80+
* const input = {
81+
* "FunctionName": "my-function",
82+
* "Qualifier": "GREEN"
83+
* };
84+
* const command = new DeleteFunctionEventInvokeConfigCommand(input);
85+
* await client.send(command);
86+
* // example id: to-delete-an-asynchronous-invocation-configuration-1586481102187
87+
* ```
88+
*
7789
*/
7890
export class DeleteFunctionEventInvokeConfigCommand extends $Command
7991
.classBuilder<

clients/client-lambda/src/commands/DeleteLayerVersionCommand.ts

+12
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ export interface DeleteLayerVersionCommandOutput extends __MetadataBearer {}
6363
* <p>Base exception class for all service exceptions from Lambda service.</p>
6464
*
6565
* @public
66+
* @example To delete a version of a Lambda layer
67+
* ```javascript
68+
* // The following example deletes version 2 of a layer named my-layer.
69+
* const input = {
70+
* "LayerName": "my-layer",
71+
* "VersionNumber": 2
72+
* };
73+
* const command = new DeleteLayerVersionCommand(input);
74+
* await client.send(command);
75+
* // example id: to-delete-a-version-of-a-lambda-layer-1586481157547
76+
* ```
77+
*
6678
*/
6779
export class DeleteLayerVersionCommand extends $Command
6880
.classBuilder<

clients/client-lambda/src/commands/DeleteProvisionedConcurrencyConfigCommand.ts

+12
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ export interface DeleteProvisionedConcurrencyConfigCommandOutput extends __Metad
7373
* <p>Base exception class for all service exceptions from Lambda service.</p>
7474
*
7575
* @public
76+
* @example To delete a provisioned concurrency configuration
77+
* ```javascript
78+
* // The following example deletes the provisioned concurrency configuration for the GREEN alias of a function named my-function.
79+
* const input = {
80+
* "FunctionName": "my-function",
81+
* "Qualifier": "GREEN"
82+
* };
83+
* const command = new DeleteProvisionedConcurrencyConfigCommand(input);
84+
* await client.send(command);
85+
* // example id: to-delete-a-provisioned-concurrency-configuration-1586481032551
86+
* ```
87+
*
7688
*/
7789
export class DeleteProvisionedConcurrencyConfigCommand extends $Command
7890
.classBuilder<

clients/client-lambda/src/commands/GetAccountSettingsCommand.ts

+24
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ export interface GetAccountSettingsCommandOutput extends GetAccountSettingsRespo
7070
* <p>Base exception class for all service exceptions from Lambda service.</p>
7171
*
7272
* @public
73+
* @example To get account settings
74+
* ```javascript
75+
* // This operation takes no parameters and returns details about storage and concurrency quotas in the current Region.
76+
* const input = {};
77+
* const command = new GetAccountSettingsCommand(input);
78+
* const response = await client.send(command);
79+
* /* response ==
80+
* {
81+
* "AccountLimit": {
82+
* "CodeSizeUnzipped": 262144000,
83+
* "CodeSizeZipped": 52428800,
84+
* "ConcurrentExecutions": 1000,
85+
* "TotalCodeSize": 80530636800,
86+
* "UnreservedConcurrentExecutions": 1000
87+
* },
88+
* "AccountUsage": {
89+
* "FunctionCount": 4,
90+
* "TotalCodeSize": 9426
91+
* }
92+
* }
93+
* *\/
94+
* // example id: to-get-account-settings-1481657495274
95+
* ```
96+
*
7397
*/
7498
export class GetAccountSettingsCommand extends $Command
7599
.classBuilder<

0 commit comments

Comments
 (0)