How to extract part of the string from `$$.Execution.Name` in AWS step function?

From this page: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html

I'm using "TransformJobName": "$$.Execution.Name" to define a dynamic SageMaker job name since the name needs to be unique otherwise statemachine will fail, the definition of the statmachine is:


{
    "Comment": "Defines the statemachine.",
    "StartAt": "SageMaker CreateTransformJob",
    "States": {
      "SageMaker CreateTransformJob": {
        "Type": "Task",
        "Resource": "arn:aws:states:::sagemaker:createTransformJob.sync",
        "Parameters": {
          "BatchStrategy": "SingleRecord",
          "DataProcessing": {
              "InputFilter": "$",
              "JoinSource": "Input",
              "OutputFilter": "xxx"
          },
          "Environment": {
              "SAGEMAKER_MODEL_SERVER_TIMEOUT": "300"
          },
          "MaxConcurrentTransforms": 100,
          "MaxPayloadInMB": 1,
          "ModelName": "${model_name}",
          "TransformInput": {
              "DataSource": {
                  "S3DataSource": {
                      "S3DataType": "S3Prefix",
                      "S3Uri": "${s3_input_path}"
                  }
              },
              "ContentType": "application/jsonlines",
              "CompressionType": "Gzip",
              "SplitType": "Line"
          },
          "TransformJobName": "$$.Execution.Name",
          "TransformOutput": {
              "S3OutputPath": "${s3_output_path}",
              "Accept": "application/jsonlines",
              "AssembleWith": "Line"
          },
          "TransformResources": {
              "InstanceType": "xxx",
              "InstanceCount": 1
          }
      },
        "End": true
      }
    }
  }

When I executed the statemachine, I got the error below:

{
  "resourceType": "sagemaker",
  "resource": "createTransformJob.sync",
  "error": "SageMaker.AmazonSageMakerException",
  "cause": "2 validation errors detected: Value '808bxx-xxxx-xxxx-xxxx-c831xxxxxx1_xxxxx0-xxxx-xxxx-xxxx-12345b071e5e' at 'transformJobName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}; Value '808bxx-xxxx-xxxx-xxxx-c831xxxxxx1_xxxxx0-xxxx-xxxx-xxxx-xxxxxxxx71e5e' at 'transformJobName' failed to satisfy constraint: Member must have length less than or equal to 63 (Service: AmazonSageMaker; Status Code: 400; Error Code: ValidationException; Request ID: xxxxxxxxxxx; Proxy: null)"
}

How can I modify the definition file to make the job name to meet the requirement, something like myjobname-12345b071e5e, where 12345b071e5e is the final bit of the the Execution.Name?

I also tried "TransformJobName": "$$.Execution.StartTime", but it gave me error 1 validation error detected: Value '2021-01-14T16:15:14.437Z' at 'transformJobName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62} (Service: AmazonSageMaker; Status Code: 400; Error Code: ValidationException; Request ID: xxxxxxxxxxxx; Proxy: null)

I've been struggling with this issue for a whole day now, can someone help please? Thanks in advance.



Read more here: https://stackoverflow.com/questions/65722714/how-to-extract-part-of-the-string-from-execution-name-in-aws-step-function

Content Attribution

This content was originally published by Cecilia at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: