Skip to content

Commit

Permalink
fix(stepfunctions-tasks): Athena* APIs have incorrect supported integ…
Browse files Browse the repository at this point in the history
…ration patterns (#11188)

The changes made by #11045 seem to support `WAIT_FOR_TASK_TOKEN (.waitForTaskToken)` but according to the documentation, only `Request Response` and `Run a job (.sync)` are supported: https://docs.aws.amazon.com/step-functions/latest/dg/connect-athena.html

closes #11246

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
akiym committed Nov 2, 2020
1 parent 122c68c commit 0f66833
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class AthenaGetQueryExecution extends sfn.TaskStateBase {

private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [
sfn.IntegrationPattern.REQUEST_RESPONSE,
sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
];

protected readonly taskMetrics?: sfn.TaskMetricsConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class AthenaGetQueryResults extends sfn.TaskStateBase {

private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [
sfn.IntegrationPattern.REQUEST_RESPONSE,
sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
];

protected readonly taskMetrics?: sfn.TaskMetricsConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class AthenaStartQueryExecution extends sfn.TaskStateBase {

private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [
sfn.IntegrationPattern.REQUEST_RESPONSE,
sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
sfn.IntegrationPattern.RUN_JOB,
];

protected readonly taskMetrics?: sfn.TaskMetricsConfig;
Expand Down Expand Up @@ -87,7 +87,7 @@ export class AthenaStartQueryExecution extends sfn.TaskStateBase {
}),

],
actions: ['athena:getDataCatalog', 'athena:startQueryExecution'],
actions: ['athena:getDataCatalog', 'athena:startQueryExecution', 'athena:getQueryExecution'],
}),
];

Expand Down Expand Up @@ -286,4 +286,4 @@ export interface QueryExecutionContext {
* @default - No database
*/
readonly databaseName?: string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class AthenaStopQueryExecution extends sfn.TaskStateBase {

private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [
sfn.IntegrationPattern.REQUEST_RESPONSE,
sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
];

protected readonly taskMetrics?: sfn.TaskMetricsConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
{
"Action": [
"athena:getDataCatalog",
"athena:startQueryExecution"
"athena:startQueryExecution",
"athena:getQueryExecution"
],
"Effect": "Allow",
"Resource": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
{
"Action": [
"athena:getDataCatalog",
"athena:startQueryExecution"
"athena:startQueryExecution",
"athena:getQueryExecution"
],
"Effect": "Allow",
"Resource": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
{
"Action": [
"athena:getDataCatalog",
"athena:startQueryExecution"
"athena:startQueryExecution",
"athena:getQueryExecution"
],
"Effect": "Allow",
"Resource": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
{
"Action": [
"athena:getDataCatalog",
"athena:startQueryExecution"
"athena:startQueryExecution",
"athena:getQueryExecution"
],
"Effect": "Allow",
"Resource": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as cdk from '@aws-cdk/core';
import { AthenaStartQueryExecution, EncryptionOption } from '../../lib/athena/start-query-execution';

Expand Down Expand Up @@ -53,4 +54,48 @@ describe('Start Query Execution', () => {
},
});
});
});

test('sync integrationPattern', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const task = new AthenaStartQueryExecution(stack, 'Query', {
integrationPattern: sfn.IntegrationPattern.RUN_JOB,
queryString: 'CREATE DATABASE database',
queryExecutionContext: {
databaseName: 'mydatabase',
},
resultConfiguration: {
encryptionConfiguration: { encryptionOption: EncryptionOption.S3_MANAGED },
},
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::athena:startQueryExecution.sync',
],
],
},
End: true,
Parameters: {
QueryString: 'CREATE DATABASE database',
QueryExecutionContext: {
Database: 'mydatabase',
},
ResultConfiguration: {
EncryptionConfiguration: { EncryptionOption: EncryptionOption.S3_MANAGED },
},
},
});
});
});

0 comments on commit 0f66833

Please sign in to comment.