Commit d0b074a
authored
### What is changing?
This PR introduces two new classes, `TableGrants` and `StreamGrants`, that allow the assignment of permissions, in a uniform way, to both L1s and L2s:
```ts
const table = new Table(...); // or new CfnTable(...)
const role = new Role(...);
// Allow the role to read data from the table
const grant = TableGrants._fromTable(table).readData(role);
```
To make the interface more similar to the auto-generated grants (e.g., `TopicGrants`), `TableGrants._fromTable()` takes a new interface, `IIndexableRegionalTable` as a parameter.
```ts
export interface IIndexableRegionalTable extends ITableRef {
/**
* Additional regions other than the main one that this table is replicated to *
* @default no regions
*/
readonly regions?: string[];
/**
* Whether this table has indexes
*
* If so, permissions are granted on all table indexes as well.
*
* @default false
*/
readonly hasIndex?: boolean;
}
```
And now `TableBase` implements `IIndexableRegionalTable`. `TableBase` has also gained two additional public immutable properties: `grants` and `streamGrants`, that should be used to grant permissions on a table. The existing `grant*()` methods will be deprecated soon.
### Why did the integration test templates change?
The current implementation uses `Lazy.string()` to produce the regional ARNs. Since the `produce()` method has to return _something_, it returned `Aws.NO_VALUE` when there was no real value to produce. In `TableGrants`, by contrast, the ARNs are computed eagerly in the constructor, so there is no need for pseudo-values. This is what caused the integration test templates to change. There are additional changes that are purely in the order of JSON properties.
### Why does `StreamGrants` not have a `_fromStream()` static method?
Unlike table, a table stream is not a resource in CloudFormation. So, although we could try to mimic one, by creating interfaces like `ITableStream`, `ITableStreamRef`, `TableStreamReference`, there is nothing to gain from it. The consumer would still have to assemble an object from properties of a `Table` of `CfnTable` anyway.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 183ec35 commit d0b074a
File tree
39 files changed
+5310
-6548
lines changed- packages
- @aws-cdk-testing/framework-integ/test
- aws-apigatewayv2-integrations/test/websocket
- integ.lambda-connect-disconnect-trigger.js.snapshot
- aws-appsync/test
- integ.appsync-eventapi-dynamodb.js.snapshot
- integ.auth-apikey.js.snapshot
- integ.graphql-iam.js.snapshot
- integ.graphql.js.snapshot
- integ.js-resolver.js.snapshot
- aws-dynamodb/test
- integ.dynamodb.js.snapshot
- integ.dynamodb.sse.js.snapshot
- aws-cdk-lib/aws-dynamodb
- lib
- test
39 files changed
+5310
-6548
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
66 | 61 | | |
67 | 62 | | |
68 | 63 | | |
| |||
97 | 92 | | |
98 | 93 | | |
99 | 94 | | |
100 | | - | |
| 95 | + | |
101 | 96 | | |
102 | 97 | | |
103 | 98 | | |
| |||
157 | 152 | | |
158 | 153 | | |
159 | 154 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
171 | 161 | | |
172 | 162 | | |
173 | 163 | | |
| |||
202 | 192 | | |
203 | 193 | | |
204 | 194 | | |
205 | | - | |
| 195 | + | |
206 | 196 | | |
207 | 197 | | |
208 | 198 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
Lines changed: 6 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
91 | 86 | | |
92 | 87 | | |
93 | 88 | | |
| |||
Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
85 | 80 | | |
86 | 81 | | |
87 | 82 | | |
| |||
103 | 98 | | |
104 | 99 | | |
105 | 100 | | |
106 | | - | |
107 | | - | |
108 | 101 | | |
109 | 102 | | |
110 | 103 | | |
| |||
113 | 106 | | |
114 | 107 | | |
115 | 108 | | |
| 109 | + | |
116 | 110 | | |
117 | 111 | | |
118 | 112 | | |
119 | 113 | | |
120 | 114 | | |
121 | | - | |
| 115 | + | |
| 116 | + | |
122 | 117 | | |
123 | 118 | | |
124 | 119 | | |
| |||
130 | 125 | | |
131 | 126 | | |
132 | 127 | | |
133 | | - | |
134 | | - | |
135 | 128 | | |
| 129 | + | |
136 | 130 | | |
137 | 131 | | |
138 | | - | |
| 132 | + | |
| 133 | + | |
139 | 134 | | |
140 | 135 | | |
141 | 136 | | |
| |||
151 | 146 | | |
152 | 147 | | |
153 | 148 | | |
154 | | - | |
155 | | - | |
156 | 149 | | |
| 150 | + | |
157 | 151 | | |
158 | 152 | | |
159 | | - | |
| 153 | + | |
| 154 | + | |
160 | 155 | | |
161 | 156 | | |
162 | 157 | | |
| |||
166 | 161 | | |
167 | 162 | | |
168 | 163 | | |
169 | | - | |
| 164 | + | |
170 | 165 | | |
171 | 166 | | |
172 | | - | |
| 167 | + | |
173 | 168 | | |
174 | 169 | | |
175 | | - | |
| 170 | + | |
| 171 | + | |
176 | 172 | | |
177 | 173 | | |
178 | | - | |
| 174 | + | |
179 | 175 | | |
180 | | - | |
181 | | - | |
| 176 | + | |
182 | 177 | | |
183 | 178 | | |
184 | 179 | | |
| |||
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments