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

feat(stepfunctions-tasks): run batch job #6396

Merged
merged 17 commits into from
Mar 10, 2020
Merged

feat(stepfunctions-tasks): run batch job #6396

merged 17 commits into from
Mar 10, 2020

Conversation

ayush987goyal
Copy link
Contributor

@ayush987goyal ayush987goyal commented Feb 21, 2020

Commit Message

feat(stepfunctions-tasks): run batch job (#6396)

Adding implementation to run batch job from step functions based on docs

closes #6467

End Commit Message


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c7e8f56
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: e405aa0
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: bf9ddd4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0727eff
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 6fd567d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b24ad8f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 6e16a67
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@nija-at nija-at changed the title feat(sfn-tasks): add invoke-batch-job task feat(stepfunctions-tasks): invoke batch job Feb 26, 2020
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

Once batch has a more stable API, we can use the interfaces from batch instead of working with names and ARNs

Why wait? Why not start using them straight away?

packages/@aws-cdk/aws-stepfunctions/README.md Outdated Show resolved Hide resolved
@ayush987goyal
Copy link
Contributor Author

On the same note, I had a doubt on naming this task. I was confused between calling it InvokeBatchJob v/s RunBatchJob. What do you think should be the appropriate name?

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 74ab577
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@nija-at
Copy link
Contributor

nija-at commented Feb 27, 2020

On the same note, I had a doubt on naming this task. I was confused between calling it InvokeBatchJob v/s RunBatchJob. What do you think should be the appropriate name?

Let's switch to RunBatchJob.

@mergify mergify bot dismissed nija-at’s stale review February 27, 2020 14:24

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 508b3b9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@ayush987goyal ayush987goyal changed the title feat(stepfunctions-tasks): invoke batch job feat(stepfunctions-tasks): run batch job Feb 27, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 1b322e7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot dismissed nija-at’s stale review February 28, 2020 19:22

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 156f794
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 65bca62
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: bc15bd9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

nija-at
nija-at previously requested changes Mar 4, 2020
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

Thanks for the updated revision. I have a few more comments based on a second iteration on this. It's starting to come together and looks close. 😊

Comment on lines 229 to 251
// Resource-level access control is not supported by Batch
// https://docs.aws.amazon.com/step-functions/latest/dg/batch-iam.html
new iam.PolicyStatement({
resources: ['*'],
Copy link
Contributor

Choose a reason for hiding this comment

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

I found this - https://docs.aws.amazon.com/batch/latest/userguide/batch-supported-iam-actions-resources.html.

Is it possible that AWS batch has added supported for resource-level permissions and that the step functions page is stale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure how it would work out with the current batch implementation anyway. It does not expose the revision of a jobDefinition.
https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-batch.JobDefinition.html

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I'm fully following your last comment.

I was thinking we could do -

resources: [ `${this.props.jobdefinition.jobDefinitionArn}/*` ]

This would be better than just *.

@mergify mergify bot dismissed nija-at’s stale review March 4, 2020 19:08

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: a9f93aa
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

nija-at
nija-at previously requested changes Mar 9, 2020
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

Mostly good. I'm still a bit worried about the * permission, which I think we can do better, but not sure.

Some minor code clean up for readability.

This is very close to the line. Thanks for iterating on this!

Comment on lines 229 to 251
// Resource-level access control is not supported by Batch
// https://docs.aws.amazon.com/step-functions/latest/dg/batch-iam.html
new iam.PolicyStatement({
resources: ['*'],
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I'm fully following your last comment.

I was thinking we could do -

resources: [ `${this.props.jobdefinition.jobDefinitionArn}/*` ]

This would be better than just *.

@ayush987goyal
Copy link
Contributor Author

Based on the permission configuration mentioned in this doc, we have to either provide the job-definition with the revision or none at all.

Job Definition

arn:aws:batch:region:account:job-definition/*

arn:aws:batch:region:account:job-definition/definition-name:revision

So based on this, I am going ahead with these permission instead of '*'

	new iam.PolicyStatement({
          resources: [
            Stack.of(_task).formatArn({
              service: 'batch',
              resource: 'job-definition',
              resourceName: '*'
            }),
            this.props.jobQueue.jobQueueArn
          ],
          actions: ['batch:SubmitJob']
        }),

That way we are limiting the permission to a specific queue but all the job-definitions. Once we have revision provided by Batch, we can probably update the permission to that specific revision.

@mergify mergify bot dismissed nija-at’s stale review March 10, 2020 04:42

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 407757a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@nija-at
Copy link
Contributor

nija-at commented Mar 10, 2020

Based on the permission configuration mentioned in this doc, we have to either provide the job-definition with the revision or none at all.

Oops, yes you're correct. I mis-read the doc. This is fine to start off with.

@mergify
Copy link
Contributor

mergify bot commented Mar 10, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 22b3107
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Mar 10, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit de1a36b into aws:master Mar 10, 2020
@ayush987goyal ayush987goyal deleted the pr/invoke-batch branch March 10, 2020 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stepfunction tasks - support aws batch
3 participants