Skip to content

Commit ab843b8

Browse files
author
awstools
committedSep 20, 2024
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<

0 commit comments

Comments
 (0)
Please sign in to comment.