Skip to content

Commit 4ce662f

Browse files
author
awstools
committed
feat(client-dynamodb): This release introduces 3 new APIs ('GetResourcePolicy', 'PutResourcePolicy' and 'DeleteResourcePolicy') and modifies the existing 'CreateTable' API for the resource-based policy support. It also modifies several APIs to accept a 'TableArn' for the 'TableName' parameter.
1 parent 1ddab5a commit 4ce662f

File tree

12 files changed

+1129
-116
lines changed

12 files changed

+1129
-116
lines changed

clients/client-dynamodb/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ DeleteItem
283283

284284
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/DeleteItemCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/DeleteItemCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/DeleteItemCommandOutput/)
285285

286+
</details>
287+
<details>
288+
<summary>
289+
DeleteResourcePolicy
290+
</summary>
291+
292+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/DeleteResourcePolicyCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/DeleteResourcePolicyCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/DeleteResourcePolicyCommandOutput/)
293+
286294
</details>
287295
<details>
288296
<summary>
@@ -443,6 +451,14 @@ GetItem
443451

444452
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/GetItemCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/GetItemCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/GetItemCommandOutput/)
445453

454+
</details>
455+
<details>
456+
<summary>
457+
GetResourcePolicy
458+
</summary>
459+
460+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/GetResourcePolicyCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/GetResourcePolicyCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/GetResourcePolicyCommandOutput/)
461+
446462
</details>
447463
<details>
448464
<summary>
@@ -515,6 +531,14 @@ PutItem
515531

516532
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/PutItemCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/PutItemCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/PutItemCommandOutput/)
517533

534+
</details>
535+
<details>
536+
<summary>
537+
PutResourcePolicy
538+
</summary>
539+
540+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/PutResourcePolicyCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/PutResourcePolicyCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/PutResourcePolicyCommandOutput/)
541+
518542
</details>
519543
<details>
520544
<summary>

clients/client-dynamodb/src/DynamoDB.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ import {
3434
DeleteBackupCommandOutput,
3535
} from "./commands/DeleteBackupCommand";
3636
import { DeleteItemCommand, DeleteItemCommandInput, DeleteItemCommandOutput } from "./commands/DeleteItemCommand";
37+
import {
38+
DeleteResourcePolicyCommand,
39+
DeleteResourcePolicyCommandInput,
40+
DeleteResourcePolicyCommandOutput,
41+
} from "./commands/DeleteResourcePolicyCommand";
3742
import { DeleteTableCommand, DeleteTableCommandInput, DeleteTableCommandOutput } from "./commands/DeleteTableCommand";
3843
import {
3944
DescribeBackupCommand,
@@ -126,6 +131,11 @@ import {
126131
ExportTableToPointInTimeCommandOutput,
127132
} from "./commands/ExportTableToPointInTimeCommand";
128133
import { GetItemCommand, GetItemCommandInput, GetItemCommandOutput } from "./commands/GetItemCommand";
134+
import {
135+
GetResourcePolicyCommand,
136+
GetResourcePolicyCommandInput,
137+
GetResourcePolicyCommandOutput,
138+
} from "./commands/GetResourcePolicyCommand";
129139
import { ImportTableCommand, ImportTableCommandInput, ImportTableCommandOutput } from "./commands/ImportTableCommand";
130140
import { ListBackupsCommand, ListBackupsCommandInput, ListBackupsCommandOutput } from "./commands/ListBackupsCommand";
131141
import {
@@ -147,6 +157,11 @@ import {
147157
ListTagsOfResourceCommandOutput,
148158
} from "./commands/ListTagsOfResourceCommand";
149159
import { PutItemCommand, PutItemCommandInput, PutItemCommandOutput } from "./commands/PutItemCommand";
160+
import {
161+
PutResourcePolicyCommand,
162+
PutResourcePolicyCommandInput,
163+
PutResourcePolicyCommandOutput,
164+
} from "./commands/PutResourcePolicyCommand";
150165
import { QueryCommand, QueryCommandInput, QueryCommandOutput } from "./commands/QueryCommand";
151166
import {
152167
RestoreTableFromBackupCommand,
@@ -223,6 +238,7 @@ const commands = {
223238
CreateTableCommand,
224239
DeleteBackupCommand,
225240
DeleteItemCommand,
241+
DeleteResourcePolicyCommand,
226242
DeleteTableCommand,
227243
DescribeBackupCommand,
228244
DescribeContinuousBackupsCommand,
@@ -243,6 +259,7 @@ const commands = {
243259
ExecuteTransactionCommand,
244260
ExportTableToPointInTimeCommand,
245261
GetItemCommand,
262+
GetResourcePolicyCommand,
246263
ImportTableCommand,
247264
ListBackupsCommand,
248265
ListContributorInsightsCommand,
@@ -252,6 +269,7 @@ const commands = {
252269
ListTablesCommand,
253270
ListTagsOfResourceCommand,
254271
PutItemCommand,
272+
PutResourcePolicyCommand,
255273
QueryCommand,
256274
RestoreTableFromBackupCommand,
257275
RestoreTableToPointInTimeCommand,
@@ -375,6 +393,23 @@ export interface DynamoDB {
375393
cb: (err: any, data?: DeleteItemCommandOutput) => void
376394
): void;
377395

396+
/**
397+
* @see {@link DeleteResourcePolicyCommand}
398+
*/
399+
deleteResourcePolicy(
400+
args: DeleteResourcePolicyCommandInput,
401+
options?: __HttpHandlerOptions
402+
): Promise<DeleteResourcePolicyCommandOutput>;
403+
deleteResourcePolicy(
404+
args: DeleteResourcePolicyCommandInput,
405+
cb: (err: any, data?: DeleteResourcePolicyCommandOutput) => void
406+
): void;
407+
deleteResourcePolicy(
408+
args: DeleteResourcePolicyCommandInput,
409+
options: __HttpHandlerOptions,
410+
cb: (err: any, data?: DeleteResourcePolicyCommandOutput) => void
411+
): void;
412+
378413
/**
379414
* @see {@link DeleteTableCommand}
380415
*/
@@ -687,6 +722,23 @@ export interface DynamoDB {
687722
cb: (err: any, data?: GetItemCommandOutput) => void
688723
): void;
689724

725+
/**
726+
* @see {@link GetResourcePolicyCommand}
727+
*/
728+
getResourcePolicy(
729+
args: GetResourcePolicyCommandInput,
730+
options?: __HttpHandlerOptions
731+
): Promise<GetResourcePolicyCommandOutput>;
732+
getResourcePolicy(
733+
args: GetResourcePolicyCommandInput,
734+
cb: (err: any, data?: GetResourcePolicyCommandOutput) => void
735+
): void;
736+
getResourcePolicy(
737+
args: GetResourcePolicyCommandInput,
738+
options: __HttpHandlerOptions,
739+
cb: (err: any, data?: GetResourcePolicyCommandOutput) => void
740+
): void;
741+
690742
/**
691743
* @see {@link ImportTableCommand}
692744
*/
@@ -810,6 +862,23 @@ export interface DynamoDB {
810862
cb: (err: any, data?: PutItemCommandOutput) => void
811863
): void;
812864

865+
/**
866+
* @see {@link PutResourcePolicyCommand}
867+
*/
868+
putResourcePolicy(
869+
args: PutResourcePolicyCommandInput,
870+
options?: __HttpHandlerOptions
871+
): Promise<PutResourcePolicyCommandOutput>;
872+
putResourcePolicy(
873+
args: PutResourcePolicyCommandInput,
874+
cb: (err: any, data?: PutResourcePolicyCommandOutput) => void
875+
): void;
876+
putResourcePolicy(
877+
args: PutResourcePolicyCommandInput,
878+
options: __HttpHandlerOptions,
879+
cb: (err: any, data?: PutResourcePolicyCommandOutput) => void
880+
): void;
881+
813882
/**
814883
* @see {@link QueryCommand}
815884
*/

clients/client-dynamodb/src/DynamoDBClient.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ import { CreateGlobalTableCommandInput, CreateGlobalTableCommandOutput } from ".
6969
import { CreateTableCommandInput, CreateTableCommandOutput } from "./commands/CreateTableCommand";
7070
import { DeleteBackupCommandInput, DeleteBackupCommandOutput } from "./commands/DeleteBackupCommand";
7171
import { DeleteItemCommandInput, DeleteItemCommandOutput } from "./commands/DeleteItemCommand";
72+
import {
73+
DeleteResourcePolicyCommandInput,
74+
DeleteResourcePolicyCommandOutput,
75+
} from "./commands/DeleteResourcePolicyCommand";
7276
import { DeleteTableCommandInput, DeleteTableCommandOutput } from "./commands/DeleteTableCommand";
7377
import { DescribeBackupCommandInput, DescribeBackupCommandOutput } from "./commands/DescribeBackupCommand";
7478
import {
@@ -120,6 +124,7 @@ import {
120124
ExportTableToPointInTimeCommandOutput,
121125
} from "./commands/ExportTableToPointInTimeCommand";
122126
import { GetItemCommandInput, GetItemCommandOutput } from "./commands/GetItemCommand";
127+
import { GetResourcePolicyCommandInput, GetResourcePolicyCommandOutput } from "./commands/GetResourcePolicyCommand";
123128
import { ImportTableCommandInput, ImportTableCommandOutput } from "./commands/ImportTableCommand";
124129
import { ListBackupsCommandInput, ListBackupsCommandOutput } from "./commands/ListBackupsCommand";
125130
import {
@@ -132,6 +137,7 @@ import { ListImportsCommandInput, ListImportsCommandOutput } from "./commands/Li
132137
import { ListTablesCommandInput, ListTablesCommandOutput } from "./commands/ListTablesCommand";
133138
import { ListTagsOfResourceCommandInput, ListTagsOfResourceCommandOutput } from "./commands/ListTagsOfResourceCommand";
134139
import { PutItemCommandInput, PutItemCommandOutput } from "./commands/PutItemCommand";
140+
import { PutResourcePolicyCommandInput, PutResourcePolicyCommandOutput } from "./commands/PutResourcePolicyCommand";
135141
import { QueryCommandInput, QueryCommandOutput } from "./commands/QueryCommand";
136142
import {
137143
RestoreTableFromBackupCommandInput,
@@ -193,6 +199,7 @@ export type ServiceInputTypes =
193199
| CreateTableCommandInput
194200
| DeleteBackupCommandInput
195201
| DeleteItemCommandInput
202+
| DeleteResourcePolicyCommandInput
196203
| DeleteTableCommandInput
197204
| DescribeBackupCommandInput
198205
| DescribeContinuousBackupsCommandInput
@@ -213,6 +220,7 @@ export type ServiceInputTypes =
213220
| ExecuteTransactionCommandInput
214221
| ExportTableToPointInTimeCommandInput
215222
| GetItemCommandInput
223+
| GetResourcePolicyCommandInput
216224
| ImportTableCommandInput
217225
| ListBackupsCommandInput
218226
| ListContributorInsightsCommandInput
@@ -222,6 +230,7 @@ export type ServiceInputTypes =
222230
| ListTablesCommandInput
223231
| ListTagsOfResourceCommandInput
224232
| PutItemCommandInput
233+
| PutResourcePolicyCommandInput
225234
| QueryCommandInput
226235
| RestoreTableFromBackupCommandInput
227236
| RestoreTableToPointInTimeCommandInput
@@ -252,6 +261,7 @@ export type ServiceOutputTypes =
252261
| CreateTableCommandOutput
253262
| DeleteBackupCommandOutput
254263
| DeleteItemCommandOutput
264+
| DeleteResourcePolicyCommandOutput
255265
| DeleteTableCommandOutput
256266
| DescribeBackupCommandOutput
257267
| DescribeContinuousBackupsCommandOutput
@@ -272,6 +282,7 @@ export type ServiceOutputTypes =
272282
| ExecuteTransactionCommandOutput
273283
| ExportTableToPointInTimeCommandOutput
274284
| GetItemCommandOutput
285+
| GetResourcePolicyCommandOutput
275286
| ImportTableCommandOutput
276287
| ListBackupsCommandOutput
277288
| ListContributorInsightsCommandOutput
@@ -281,6 +292,7 @@ export type ServiceOutputTypes =
281292
| ListTablesCommandOutput
282293
| ListTagsOfResourceCommandOutput
283294
| PutItemCommandOutput
295+
| PutResourcePolicyCommandOutput
284296
| QueryCommandOutput
285297
| RestoreTableFromBackupCommandOutput
286298
| RestoreTableToPointInTimeCommandOutput

clients/client-dynamodb/src/commands/CreateTableCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export interface CreateTableCommandOutput extends CreateTableOutput, __MetadataB
120120
* ],
121121
* TableClass: "STANDARD" || "STANDARD_INFREQUENT_ACCESS",
122122
* DeletionProtectionEnabled: true || false,
123+
* ResourcePolicy: "STRING_VALUE",
123124
* };
124125
* const command = new CreateTableCommand(input);
125126
* const response = await client.send(command);
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { DynamoDBClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../DynamoDBClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { DeleteResourcePolicyInput, DeleteResourcePolicyOutput } from "../models/models_0";
10+
import { de_DeleteResourcePolicyCommand, se_DeleteResourcePolicyCommand } from "../protocols/Aws_json1_0";
11+
12+
/**
13+
* @public
14+
*/
15+
export { __MetadataBearer, $Command };
16+
/**
17+
* @public
18+
*
19+
* The input for {@link DeleteResourcePolicyCommand}.
20+
*/
21+
export interface DeleteResourcePolicyCommandInput extends DeleteResourcePolicyInput {}
22+
/**
23+
* @public
24+
*
25+
* The output of {@link DeleteResourcePolicyCommand}.
26+
*/
27+
export interface DeleteResourcePolicyCommandOutput extends DeleteResourcePolicyOutput, __MetadataBearer {}
28+
29+
/**
30+
* <p>Deletes the resource-based policy attached to the resource, which can be a table or stream.</p>
31+
* <p>
32+
* <code>DeleteResourcePolicy</code> is an idempotent operation; running it multiple times on the same resource <i>doesn't</i> result in an error response, unless you specify an <code>ExpectedRevisionId</code>, which will then return a <code>PolicyNotFoundException</code>.</p>
33+
* <important>
34+
* <p>To make sure that you don't inadvertently lock yourself out of your own resources, the root principal in your Amazon Web Services account can perform <code>DeleteResourcePolicy</code> requests, even if your resource-based policy explicitly denies the root principal's access.
35+
* </p>
36+
* </important>
37+
* <note>
38+
* <p>
39+
* <code>DeleteResourcePolicy</code> is an asynchronous operation. If you issue a <code>GetResourcePolicy</code> request immediately after running the <code>DeleteResourcePolicy</code> request, DynamoDB might still return the deleted policy. This is because the policy for your resource might not have been deleted yet. Wait for a few seconds, and then try the <code>GetResourcePolicy</code> request again.</p>
40+
* </note>
41+
* @example
42+
* Use a bare-bones client and the command you need to make an API call.
43+
* ```javascript
44+
* import { DynamoDBClient, DeleteResourcePolicyCommand } from "@aws-sdk/client-dynamodb"; // ES Modules import
45+
* // const { DynamoDBClient, DeleteResourcePolicyCommand } = require("@aws-sdk/client-dynamodb"); // CommonJS import
46+
* const client = new DynamoDBClient(config);
47+
* const input = { // DeleteResourcePolicyInput
48+
* ResourceArn: "STRING_VALUE", // required
49+
* ExpectedRevisionId: "STRING_VALUE",
50+
* };
51+
* const command = new DeleteResourcePolicyCommand(input);
52+
* const response = await client.send(command);
53+
* // { // DeleteResourcePolicyOutput
54+
* // RevisionId: "STRING_VALUE",
55+
* // };
56+
*
57+
* ```
58+
*
59+
* @param DeleteResourcePolicyCommandInput - {@link DeleteResourcePolicyCommandInput}
60+
* @returns {@link DeleteResourcePolicyCommandOutput}
61+
* @see {@link DeleteResourcePolicyCommandInput} for command's `input` shape.
62+
* @see {@link DeleteResourcePolicyCommandOutput} for command's `response` shape.
63+
* @see {@link DynamoDBClientResolvedConfig | config} for DynamoDBClient's `config` shape.
64+
*
65+
* @throws {@link InternalServerError} (server fault)
66+
* <p>An error occurred on the server side.</p>
67+
*
68+
* @throws {@link InvalidEndpointException} (client fault)
69+
*
70+
* @throws {@link LimitExceededException} (client fault)
71+
* <p>There is no limit to the number of daily on-demand backups that can be taken. </p>
72+
* <p>For most purposes, up to 500 simultaneous table operations are allowed per account. These operations
73+
* include <code>CreateTable</code>, <code>UpdateTable</code>,
74+
* <code>DeleteTable</code>,<code>UpdateTimeToLive</code>,
75+
* <code>RestoreTableFromBackup</code>, and <code>RestoreTableToPointInTime</code>. </p>
76+
* <p>When you are creating a table with one or more secondary
77+
* indexes, you can have up to 250 such requests running at a time. However, if the table or
78+
* index specifications are complex, then DynamoDB might temporarily reduce the number
79+
* of concurrent operations.</p>
80+
* <p>When importing into DynamoDB, up to 50 simultaneous import table operations are allowed per account.</p>
81+
* <p>There is a soft account quota of 2,500 tables.</p>
82+
* <p>GetRecords was called with a value of more than 1000 for the limit request parameter.</p>
83+
* <p>More than 2 processes are reading from the same streams shard at the same time. Exceeding
84+
* this limit may result in request throttling.</p>
85+
*
86+
* @throws {@link PolicyNotFoundException} (client fault)
87+
* <p>The operation tried to access a nonexistent resource-based policy.</p>
88+
* <p>If you specified an <code>ExpectedRevisionId</code>, it's possible that a policy is present for the resource but its revision ID didn't match the expected value.</p>
89+
*
90+
* @throws {@link ResourceInUseException} (client fault)
91+
* <p>The operation conflicts with the resource's availability. For example, you
92+
* attempted to recreate an existing table, or tried to delete a table currently in the
93+
* <code>CREATING</code> state.</p>
94+
*
95+
* @throws {@link ResourceNotFoundException} (client fault)
96+
* <p>The operation tried to access a nonexistent table or index. The resource might not
97+
* be specified correctly, or its status might not be <code>ACTIVE</code>.</p>
98+
*
99+
* @throws {@link DynamoDBServiceException}
100+
* <p>Base exception class for all service exceptions from DynamoDB service.</p>
101+
*
102+
* @public
103+
*/
104+
export class DeleteResourcePolicyCommand extends $Command
105+
.classBuilder<
106+
DeleteResourcePolicyCommandInput,
107+
DeleteResourcePolicyCommandOutput,
108+
DynamoDBClientResolvedConfig,
109+
ServiceInputTypes,
110+
ServiceOutputTypes
111+
>()
112+
.ep({
113+
...commonParams,
114+
})
115+
.m(function (this: any, Command: any, cs: any, config: DynamoDBClientResolvedConfig, o: any) {
116+
return [
117+
getSerdePlugin(config, this.serialize, this.deserialize),
118+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
119+
];
120+
})
121+
.s("DynamoDB_20120810", "DeleteResourcePolicy", {})
122+
.n("DynamoDBClient", "DeleteResourcePolicyCommand")
123+
.f(void 0, void 0)
124+
.ser(se_DeleteResourcePolicyCommand)
125+
.de(de_DeleteResourcePolicyCommand)
126+
.build() {}

0 commit comments

Comments
 (0)