Skip to content

Commit c7f68a7

Browse files
docs(integ-tests): how to use AwsApiCall.waiterProvider.addToRolePolicy() (#31167)
### Issue # (if applicable) None ### Reason for this change By using `AwsApiCall.provider.addToRolePolicy()`, we can add the necessary IAM policy to execute `AwsApiCall`. However, when using `waitForAssertions()`, the test will fail unless we use `AwsApiCall.waiterProvider.addToRolePolicy()`. Since this information was not mentioned in the official documentation, I struggled to resolve the issue, so I submitted a pull request to add it to the documentation." ### Description of changes Add description. ### Description of how you validated changes None ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 98b801c commit c7f68a7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/@aws-cdk/integ-tests-alpha/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ apiCall.provider.addToRolePolicy({
345345
});
346346
```
347347

348+
When executing `waitForAssertion()`, it is necessary to add an IAM policy using `waiterProvider.addToRolePolicy()`.
349+
Because `IApiCall` does not have a `waiterProvider` property, you need to cast it to `AwsApiCall`.
350+
351+
```ts
352+
declare const integ: IntegTest;
353+
354+
const apiCall = integ.assertions.awsApiCall('S3', 'listObjectsV2', {
355+
Bucket: 'mybucket',
356+
}).waitForAssertions() as AwsApiCall;
357+
358+
apiCall.waiterProvider?.addToRolePolicy({
359+
Effect: 'Allow',
360+
Action: ['s3:GetObject', 's3:ListBucket'],
361+
Resource: ['*'],
362+
});
363+
```
364+
348365
Note that addToRolePolicy() uses direct IAM JSON policy blobs, not a iam.PolicyStatement
349366
object like you will see in the rest of the CDK.
350367

0 commit comments

Comments
 (0)