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): mediapackagevod service generates wrong action in role policy #28775

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -0,0 +1,37 @@
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import * as cdk from 'aws-cdk-lib';
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
import { CallAwsService } from 'aws-cdk-lib/aws-stepfunctions-tasks';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-call-aws-service-mediapackagevod-integ');

const task = new CallAwsService(stack, 'DeleteMediaPackageVoDAsset', {
service: 'mediapackagevod',
action: 'deleteAsset',
resultPath: sfn.JsonPath.DISCARD,
iamResources: ['*'],
});

const stateMachine = new sfn.StateMachine(stack, 'StateMachine', {
definition: task,
});

// THEN
const integ = new IntegTest(app, 'IntegTest', {
testCases: [stack],
});
const res = integ.assertions.awsApiCall('StepFunctions', 'startExecution', {
stateMachineArn: stateMachine.stateMachineArn,
});
const executionArn = res.getAttString('executionArn');
integ.assertions.awsApiCall('StepFunctions', 'describeExecution', {
executionArn,
}).expect(ExpectedResult.objectLike({
status: 'SUCCEEDED',
})).waitForAssertions({
totalTimeout: cdk.Duration.seconds(10),
interval: cdk.Duration.seconds(3),
});

app.synth();
aaythapa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class CallAwsService extends sfn.TaskStateBase {
const iamServiceMap: Record<string, string> = {
sfn: 'states',
cloudwatchlogs: 'logs',
mediapackagevod: 'mediapackage-vod',
mwaa: 'airflow',
};
aaythapa marked this conversation as resolved.
Show resolved Hide resolved
const iamService = iamServiceMap[props.service] ?? props.service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,34 @@ test('IAM policy for cloudwatchlogs', () => {
});
});

test('IAM policy for mediapackagevod', () => {
// WHEN
const task = new tasks.CallAwsService(stack, 'DeleteMediaPackageVoDAsset', {
service: 'mediapackagevod',
action: 'deleteAsset',
resultPath: sfn.JsonPath.DISCARD,
iamResources: ['*'],
});

new sfn.StateMachine(stack, 'StateMachine', {
definitionBody: sfn.DefinitionBody.fromChainable(task),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
PolicyDocument: {
Statement: [
{
Action: 'mediapackage-vod:deleteAsset',
Effect: 'Allow',
Resource: '*',
},
],
Version: '2012-10-17',
},
});
});

test('IAM policy for mwaa', () => {
// WHEN
const task = new tasks.CallAwsService(stack, 'ListMWAAEnvironments', {
Expand Down
Loading