1

Consider example (source)

  # State machine for testing Athena Runner
  AthenaRunnerTestETLOrchestrator:
    Type: "AWS::StepFunctions::StateMachine"
    Properties:
      StateMachineName: AthenaRunnerTestETLOrchestrator
      DefinitionString:
        Fn::Sub:
          - |-
            {
              "StartAt": "Configure Athena Query",
              "States": {
                "Configure Athena Query":{
                  "Type": "Pass",
                  "Result": "{ \"AthenaQueryString\" : \"SELECT * FROM ${GlueTableName} limit 10;\", \"AthenaDatabase\": \"${GlueDatabaseName}\", \"AthenaResultOutputLocation\": \"${AthenaResultOutputLocation}\", \"AthenaResultEncryptionOption\": \"${AthenaResultEncryptionOption}\"}",
                  "Next": "Execute Athena Query"
                },
                "Execute Athena Query":{
                  "Type": "Task",
                  "Resource": "${AthenaRunnerActivityArn}",
                  "End": true
                }
              }
            }
          - {
            GlueDatabaseName: !Ref MarketingAndSalesDatabaseName,
            GlueTableName: !Ref MarketingTableName,
            AthenaRunnerActivityArn: !Ref AthenaRunnerActivity,
            AthenaResultOutputLocation: !Sub "s3://${SourceDataBucketName}/athena-runner-output/",
            AthenaResultEncryptionOption: "SSE_S3"
        }
      RoleArn: !GetAtt StateExecutionRole.Arn

Function Sub should received array of params: source and replacements, ut why |- is passed here? Is it yaml or aws Sub function feature?

404
  • 8,022
  • 2
  • 27
  • 47
Cherry
  • 31,309
  • 66
  • 224
  • 364

2 Answers2

4

|- is a yaml feature than means a multi-line string with linebreaks preserved and without a linebreak at the end:

How do I break a string over multiple lines?

Erez
  • 1,690
  • 8
  • 9
3

I think it's yaml feature. I refer to the YAML-Wikipedia, as it said:

Strings do not require quotation marks. There are two ways to write multi-line strings, one preserving newlines (using the | character) and one that folds the newlines (using the > character), both followed by a newline character.

And refer to How do I break a string over multiple lines?, we can get

Use >- or |- instead if you don't want a linebreak appended at the end.

So, |- just converts this part to string.

            {
              "StartAt": "Configure Athena Query",
              "States": {
                "Configure Athena Query":{
                  "Type": "Pass",
                  "Result": "{ \"AthenaQueryString\" : \"SELECT * FROM ${GlueTableName} limit 10;\", \"AthenaDatabase\": \"${GlueDatabaseName}\", \"AthenaResultOutputLocation\": \"${AthenaResultOutputLocation}\", \"AthenaResultEncryptionOption\": \"${AthenaResultEncryptionOption}\"}",
                  "Next": "Execute Athena Query"
                },
                "Execute Athena Query":{
                  "Type": "Task",
                  "Resource": "${AthenaRunnerActivityArn}",
                  "End": true
                }
              }
            }
LiuChang
  • 739
  • 6
  • 13