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

aws-stepfunction: Failed to create correct IAM role for step function #33580

Open
1 task
jalencato opened this issue Feb 25, 2025 · 1 comment
Open
1 task
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@jalencato
Copy link

Describe the bug

When trying the code here:

submit_training_job = tasks.BatchSubmitJob(
    self, "Sample Training Job",
    job_definition_arn=sfn.JsonPath.string_at("$.trainingJob.jobDefinitionArn"),
    job_name=sfn.JsonPath.string_at("$.trainingJob.jobName"),
    job_queue_arn=sfn.JsonPath.string_at("$.trainingJob.jobQueueArn"),
    result_path="$.trainingJobResult"
)

chain = submit_training_job.next(submit_inference_job)

state_machine = sfn.StateMachine(
    self, "SamplePipeline",
    definition_body=sfn.DefinitionBody.from_chainable(chain)
)

I am just building a step function to submit a batch job with dynamic parameter values by using payload during submit time.

However, when deploying the resource, the code above is trying to create one IAM role with following resources:

Resource                                       Effect      Action                             Principal
$.inferenceJob.jobQueueArn      Allow       Batch:SubmitJob           xxxx

$.inferenceJob.jobQueueArn cannot be retrieved so it will lead to an error. How to handle this case?

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.1000.2

Expected Behavior

I assume the role will be deployed correctly. Even if it did not add correct rules, at least it deployed the rules successfully.

Current Behavior

It will throw an error saying:

Refine sentense:        # Do not use $.trainingJob.jobQueue for the job queue because it will 
        # lead to an error when creating associated error in the iam role.

Reproduction Steps

Copy the code above and deploy and it will see the error.

Possible Solution

Anyway we can ban the step function cdk to create the role itself? We can use our own rules this way.

Additional Information/Context

No response

CDK CLI Version

2.1000.2

Framework Version

No response

Node.js Version

21

OS

macos

Language

Python

Language Version

3.9

Other information

No response

@jalencato jalencato added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 25, 2025
@github-actions github-actions bot added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Feb 25, 2025
@pahud pahud self-assigned this Feb 25, 2025
@pahud
Copy link
Contributor

pahud commented Feb 25, 2025

The issue is in the configurePolicyStatements() method of the BatchSubmitJob class. Unlike other task implementations, it doesn't check if jobQueueArn is a JsonPath expression. The fix would be to modify this method to check if jobQueueArn is a JsonPath expression, and if so, use a wildcard (*) instead:

@pahud pahud removed their assignment Feb 25, 2025
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

No branches or pull requests

2 participants