Skip to content
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

fix(stepfunctions-tasks): Athena* APIs have incorrect supported integration patterns #11188

Merged
merged 4 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the rationale for this addition into the commit body. I didn't see it in there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}),
];

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 },
},
},
});
});
});