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-stepfunctions-tasks): Cannot provide JSONPath as entrypoint arguments to EmrContainersStartJobRun task #22061

Closed
gnovack opened this issue Sep 15, 2022 · 1 comment · Fixed by #22242
Labels
@aws-cdk/aws-stepfunctions-tasks bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@gnovack
Copy link

gnovack commented Sep 15, 2022

Describe the bug

When using the EmrContainersStartJobRun Step Functions Task, I cannot provide the entryPointArguments to the EMR job as an encoded JSON path parameter.

e.g.

const emrContainersStartJobRun = new EmrContainersStartJobRun(this, "EmrEksJob", {
  virtualCluster: VirtualClusterInput.fromVirtualClusterId("1234"),
  releaseLabel: ReleaseLabel.EMR_6_3_0,
  jobDriver: {
    sparkSubmitJobDriver: {
      entryPoint: TaskInput.fromText("local:///usr/lib/spark/examples/src/main/python/pi.py"),
      entryPointArguments: TaskInput.fromJsonPathAt("$.entrypointArguments")
    }
  }
})

Expected Behavior

I expected that the above code would synthesize without error, and that the resulting state JSON from the above task would look like this:

{
    "VirtualClusterId": "1234",
    "ReleaseLabel": "emr-6.3.0-latest",
    "JobDriver": {
        "SparkSubmitJobDriver": {
            "EntryPoint": "local:///usr/lib/spark/examples/src/main/python/pi.py",
            "EntryPointArguments.$": "$.entrypointArguments"
        }
    }
}

Current Behavior

The following error occurs when running cdk synth and the CloudFormation template is not synthesized:

Entry point arguments must be a string array or encoded JSON path but received string.

Reproduction Steps

Attempt to synthesize the CDK stack below by running cdk synth

import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { EmrContainersStartJobRun, ReleaseLabel, VirtualClusterInput } from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { TaskInput } from 'aws-cdk-lib/aws-stepfunctions';

export class EmrEksCdkStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);
    
    new EmrContainersStartJobRun(this, "EmrEksJob", {
      virtualCluster: VirtualClusterInput.fromVirtualClusterId("1234"),
      releaseLabel: ReleaseLabel.EMR_6_3_0,
      jobDriver: {
        sparkSubmitJobDriver: {
          entryPoint: TaskInput.fromText("local:///usr/lib/spark/examples/src/main/python/pi.py"),
          entryPointArguments: TaskInput.fromJsonPathAt("$.entrypointArguments")
        }
      }
    });
  }
}

Possible Solution

It appears that the following validation function needs to be modified to correctly detected when the input is an encoded JSON Path:

private validateEntryPointArguments (entryPointArguments:sfn.TaskInput) {
if (typeof entryPointArguments.value === 'string' && !sfn.JsonPath.isEncodedJsonPath(entryPointArguments.value)) {
throw new Error(`Entry point arguments must be a string array or encoded JSON path, but received a non JSON path string');
.`);
}
if (!this.isArrayOfStrings(entryPointArguments.value)) {
throw new Error(`Entry point arguments must be a string array or encoded JSON path but received ${typeof entryPointArguments.value}.`);
}
}

Additional Information/Context

No response

CDK CLI Version

2.28.1 (build d035432)

Framework Version

2.28.1

Node.js Version

v14.17.0

OS

MacOS Big Sur

Language

Typescript

Language Version

No response

Other information

No response

@gnovack gnovack added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 15, 2022
@kaizencc kaizencc added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Sep 26, 2022
@kaizencc kaizencc removed their assignment Sep 26, 2022
@mergify mergify bot closed this as completed in #22242 Oct 2, 2022
mergify bot pushed a commit that referenced this issue Oct 2, 2022
…ntry point arguments (#22242)

Fixes #22061. Validation is too strict and fails for situations where entry point arguments is a `jsonPath.fromJsonPathAt()`. 


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Oct 2, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

arewa pushed a commit to arewa/aws-cdk that referenced this issue Oct 8, 2022
…ntry point arguments (aws#22242)

Fixes aws#22061. Validation is too strict and fails for situations where entry point arguments is a `jsonPath.fromJsonPathAt()`. 


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
homakk pushed a commit to homakk/aws-cdk that referenced this issue Dec 1, 2022
…ntry point arguments (aws#22242)

Fixes aws#22061. Validation is too strict and fails for situations where entry point arguments is a `jsonPath.fromJsonPathAt()`. 


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions-tasks bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
2 participants