/
stop-query-execution.ts
61 lines (51 loc) · 1.98 KB
/
stop-query-execution.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Construct } from 'constructs';
import * as iam from '../../../aws-iam';
import * as sfn from '../../../aws-stepfunctions';
import { integrationResourceArn, validatePatternSupported } from '../private/task-utils';
/**
* Properties for stoping a Query Execution
*/
export interface AthenaStopQueryExecutionProps extends sfn.TaskStateBaseProps {
/**
* Query that will be stopped
*/
readonly queryExecutionId: string;
}
/**
* Stop an Athena Query Execution as a Task
*
* @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.html
*/
export class AthenaStopQueryExecution extends sfn.TaskStateBase {
private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [
sfn.IntegrationPattern.REQUEST_RESPONSE,
];
protected readonly taskMetrics?: sfn.TaskMetricsConfig;
protected readonly taskPolicies?: iam.PolicyStatement[];
private readonly integrationPattern: sfn.IntegrationPattern;
constructor(scope: Construct, id: string, private readonly props: AthenaStopQueryExecutionProps) {
super(scope, id, props);
this.integrationPattern = props.integrationPattern ?? sfn.IntegrationPattern.REQUEST_RESPONSE;
validatePatternSupported(this.integrationPattern, AthenaStopQueryExecution.SUPPORTED_INTEGRATION_PATTERNS);
this.taskPolicies = [
new iam.PolicyStatement({
resources: ['*'], // Grant access to allow user to stop queries on all workgroups as no workgroup defined in request https://docs.aws.amazon.com/athena/latest/ug/workgroups-iam-policy.html
actions: ['athena:stopQueryExecution'],
}),
];
}
/**
* Provides the Athena stop query execution service integration task configuration
*/
/**
* @internal
*/
protected _renderTask(): any {
return {
Resource: integrationResourceArn('athena', 'stopQueryExecution', this.integrationPattern),
Parameters: sfn.FieldUtils.renderObject({
QueryExecutionId: this.props.queryExecutionId,
}),
};
}
}