-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(integ-tests): add waiterProvider to IApiCall #27844
Changes from 8 commits
e25b30b
f4458c7
eaf0074
2e9c866
b7db4a8
b9bb4dd
0e1cec3
00ae81a
f6491fc
cf0ae6f
e8fb9a2
a66b911
73df509
8a1f519
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -522,3 +522,32 @@ const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecut | |||||
}); | ||||||
``` | ||||||
|
||||||
In cases where the `waitForAssertions()` is used for the `awsApiCall`, the actual API call is executed | ||||||
by the `waiterProvider`. | ||||||
|
||||||
Same as `provider`, by default, the `AwsApiCall` construct will automatically add the correct IAM policies | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
to allow the Lambda function to make the API call. It does this based on the `service` | ||||||
and `api` that is provided. In the above example the service is `SQS` and the api is | ||||||
`receiveMessage` so it will create a policy with `Action: 'sqs:ReceiveMessage`. | ||||||
|
||||||
There are some cases where the permissions do not exactly match the service/api call, for | ||||||
example the S3 `listObjectsV2` api. In these cases it is possible to add the correct policy | ||||||
by accessing the `waiterProvider` object. | ||||||
|
||||||
```ts | ||||||
declare const integ: IntegTest; | ||||||
|
||||||
const apiCall = integ.assertions.awsApiCall('S3', 'listObjectsV2', { | ||||||
Bucket: 'mybucket', | ||||||
}).waitForAssertions({ | ||||||
totalTimeout: Duration.minutes(5), | ||||||
interval: Duration.seconds(15), | ||||||
backoffRate: 3, | ||||||
}); | ||||||
|
||||||
apiCall?.waiterProvider.addToRolePolicy({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Effect: 'Allow', | ||||||
Action: ['s3:GetObject', 's3:ListBucket'], | ||||||
Resource: ['*'], | ||||||
}); | ||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,19 +50,6 @@ export interface AwsApiCallProps extends AwsApiCallOptions { } | |
export class AwsApiCall extends ApiCallBase { | ||
public readonly provider: AssertionsProvider; | ||
|
||
/** | ||
* access the AssertionsProvider for the waiter state machine. | ||
* This can be used to add additional IAM policies | ||
* the the provider role policy | ||
* | ||
* @example | ||
* declare const apiCall: AwsApiCall; | ||
* apiCall.waiterProvider?.addToRolePolicy({ | ||
* Effect: 'Allow', | ||
* Action: ['s3:GetObject'], | ||
* Resource: ['*'], | ||
* }); | ||
*/ | ||
public waiterProvider?: AssertionsProvider; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the build is failing here. Can't remove this docstring entirely since its a public API. Why was it removed in the first place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I added it anyway. I've moved the same explanation to export class AwsApiCall extends ApiCallBase {
public readonly provider: AssertionsProvider; I looked aws.json(packages/@aws-cdk/integ-tests-alpha/awslint.json), but could not find the property. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understood, that's because it's readonly. |
||
|
||
protected readonly apiCallResource: CustomResource; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"Resources": { | ||
"Bucket83908E77": { | ||
"Type": "AWS::S3::Bucket", | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
} | ||
}, | ||
"Outputs": { | ||
"ExportsOutputRefBucket83908E7781C90AC0": { | ||
"Value": { | ||
"Ref": "Bucket83908E77" | ||
}, | ||
"Export": { | ||
"Name": "WaiterProviderStack:ExportsOutputRefBucket83908E7781C90AC0" | ||
} | ||
}, | ||
"ExportsOutputFnGetAttBucket83908E77Arn063C8555": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Bucket83908E77", | ||
"Arn" | ||
] | ||
}, | ||
"Export": { | ||
"Name": "WaiterProviderStack:ExportsOutputFnGetAttBucket83908E77Arn063C8555" | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.