-2

I did some set of activities on json script. Need to add precondition on it. how to use precondition on json script.

In precondition, i need to check the mysql db field. once flag as 'Y', start execution else should be stop the execution.

pragowin
  • 1
  • 2
  • { "id" : "InputData", "type" : "S3DataNode", "schedule" : { "ref" : "CopyPeriod" }, "filePath" : "s3://example-bucket/InputData/#{@scheduledStartTime.format('YYYYMM-dd-hh:mm')}.csv", "precondition" : { "ref" : "Ready" } }, { "id" : "Ready", "type" : "Exists" } – pragowin Sep 09 '15 at 10:28
  • am using code for precondition on datapipeline, but it is not working good. – pragowin Sep 09 '15 at 10:29

1 Answers1

0

You can use a ShellCommandPrecondition for this which will let you write a custom precondition.

{
  "objects": [
    {
      "schedule": {
        "ref": "DefaultSchedule"
      },
      "resourceRole": "DataPipelineDefaultResourceRole",
      "role": "DataPipelineDefaultRole",
      "name": "DefaultResource1",
      "id": "ResourceId_dWoZ0",
      "type": "Ec2Resource",
      "terminateAfter": "1 Hour"
    },
    {
      "name": "DefaultPrecondition1",
      "id": "PreconditionId_yA2rV",
      "type": "ShellCommandPrecondition",
      "command": "<Script to check mysql field>"
    },
    {
      "occurrences": "1",
      "period": "1 Day",
      "name": "RunOnce",
      "id": "DefaultSchedule",
      "type": "Schedule",
      "startAt": "FIRST_ACTIVATION_DATE_TIME"
    },
    {
      "failureAndRerunMode": "CASCADE",
      "schedule": {
        "ref": "DefaultSchedule"
      },
      "resourceRole": "DataPipelineDefaultResourceRole",
      "role": "DataPipelineDefaultRole",
      "pipelineLogUri": "s3://<mybucket>",
      "scheduleType": "cron",
      "name": "Default",
      "id": "Default"
    },
    {
      "schedule": {
        "ref": "DefaultSchedule"
      },
      "name": "DefaultActivity1",
      "runsOn": {
        "ref": "ResourceId_dWoZ0"
      },
      "precondition": {
        "ref": "PreconditionId_yA2rV"
      },
      "id": "ActivityId_gmQ0W",
      "type": "ShellCommandActivity",
      "command": "echo 'Hello world'"
    }
  ],
  "parameters": []
}