-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(apigatewayv2): add aws service integration -- step functions #14498
Conversation
Thanks so much for submitting this pull request. I am marking this pull request as We use +1s to help prioritize our work, and are happy to revaluate this pull request based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization. |
This is a good feature. I was testing it out with a EXPRESS Synchronous State Machine and the following bug was found: Environment Steps to reproduce the bug
Code to reproduce the bug
` Expected Output Actual Result Severity Fix
This should fix the bug. I would suggest looking into StepFunctionsStartExecutionIntegration implementation too as I dd not see any attached policy and I'm not sure if it works correctly or not. |
Thanks for your deep dive the exception and proposed fix. Will keep an eye on it due to the CDK team does not have review bandwidth. |
924c117
to
ebfd5f2
Compare
…cutionIntegration fixed to attach Inline Policy for credentialsRole. Fixed README to change input for correct input passing. Fixed Unit and Integration tests. All tests passing. Permissions bug mentioned in the PR is now fixed. Fix Bug awsGH-14498."
The bug is now fixed!! |
711b6cb
to
16447ea
Compare
* The StepFunctions-StartExecution integration resource for HTTP API | ||
*/ | ||
export class StepFunctionsStartExecutionIntegration extends StepFunctionsIntegration { |
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.
this one says StartExecution but later on L79 you are giving permission to StartSyncExecution.
Also resources [*] should be avoided if you have the state machine.
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.
Good Note. I will fix this. Thank you
credentialsRole.attachInlinePolicy( | ||
new iam.Policy(this._scope, 'AllowSfnSyncExec', { | ||
statements: [ | ||
new iam.PolicyStatement({ | ||
actions: ['states:StartSyncExecution'], | ||
effect: iam.Effect.ALLOW, | ||
resources: ['*'], | ||
}), | ||
], | ||
}), | ||
); |
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.
I believe this should be removed.
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.
This attaches the policy and fixes the permission bug mentioned above.
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.
but this is for StartExecution, not StartSyncExecution right? They are different constructs and therefore requires different permissions.
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.
yes I have fixed that in the push
*/ | ||
protected _fulfillRole(credentialsRole: iam.IRole): void { | ||
|
||
this._props.stateMachine.grantExecution(credentialsRole.grantPrincipal, 'states:StartSyncExecution'); |
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.
could you please clarify what is this line of code doing?
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.
It grants the execution permission, but does not attach the policy. That needs to be done explicitly.
new iam.PolicyStatement({ | ||
actions: ['states:StartSyncExecution'], | ||
effect: iam.Effect.ALLOW, | ||
resources: ['*'], |
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.
I believe permission to * should be avoided as you have the state machine. It should give permission only to the state machine ARN as a best practice (least privilege).
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.
Yes that is correct. I will fix this. Thank you.
* | ||
* @default - undefined | ||
*/ | ||
readonly traceHeader?: string; |
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.
doesn't StartExecution also accepts a traceheader?
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.
Yes it does.
|
||
public bind(_options: HttpRouteIntegrationBindOptions): HttpRouteIntegrationConfig { | ||
|
||
const role = new Role(_options.scope, 'Role', { |
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.
should this be called ApiGatewayIntegrationRole?
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.
Yes. I will fix that
I believe the template files should be removed from your request. |
b73875a
to
6551bec
Compare
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.
there's a bunch of files that are not related to your change. Example: Lambda Hot swap
|
||
public bind(_options: HttpRouteIntegrationBindOptions): HttpRouteIntegrationConfig { | ||
|
||
const ApiGatewayIntegrationRole = new Role(_options.scope, 'ApiGatewayIntegrationRole', { |
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.
I believe this should be lowercase.
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.
I will fix that
PayloadFormatVersion: '1.0', | ||
RequestParameters: { | ||
StateMachineArn: { | ||
Ref: 'MyStateMachine6C968CA5', |
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.
I wonder if this should be the state machine arn instead of the resource. Did it work if you try to deploy?
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.
nope it does not work. it needs the resource.
expect(stack).toHaveResource('AWS::ApiGatewayV2::Integration', { | ||
IntegrationType: 'AWS_PROXY', | ||
IntegrationSubtype: 'StepFunctions-StartSyncExecution', | ||
PayloadFormatVersion: '1.0', | ||
RequestParameters: { | ||
StateMachineArn: { | ||
Ref: 'MyStateMachine6C968CA5', | ||
}, | ||
Input: { | ||
a: 'b', | ||
}, | ||
}, | ||
}); |
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.
should you validate if the other resources are also created? The IAM Role for example
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.
IAM Role did not show up in the properties when testing, but I will add more extended tests for both.
const endpoint = new HttpApi(stack, 'AwsIntegrationApi', { | ||
defaultIntegration: new StepFunctionsStartExecutionIntegration(stack, { | ||
stateMachine: state, | ||
input: '$request.body', | ||
}), | ||
}); | ||
|
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.
should this include some assertions? What is this test file doing?
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.
It is integration testing. While testing, it validates the test against expected json.
const endpoint = new HttpApi(stack, 'AwsIntegrationApi', { | ||
defaultIntegration: new StepFunctionsStartSyncExecutionIntegration(stack, { | ||
stateMachine: state, | ||
input: '$request.body', | ||
}), | ||
}); |
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.
same question as above.
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.
It is integration testing. While testing, it validates the test against expected json.
6551bec
to
009114d
Compare
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.
-
This PR is changing unrelated files and has merge conflicts. Please update the PR to the latest master and make sure only the necessary changes are here.
-
Please add a section to the README with a sample usage.
009114d
to
afc9ef9
Compare
afc9ef9
to
0a6a1b1
Compare
98e87a2
to
a50b049
Compare
a50b049
to
9c04142
Compare
…ncExecutionIntegration. Added unit and integration tests. Fixed issues mentioned in the Pull-request. Added example to README Fixed unit test closes aws#11947.
9c04142
to
1e2999c
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This PR has been deemed to be abandoned, and will be closed. Please create a new PR for these changes if you think this decision has been made in error. |
closes #11947
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license