Getting error of PipelineActivity must have one and only one member when using Boto3 and Create_Pipeline

120 views Asked by At

I have a python program that is using boto3 to create an IoT Analytics path. My program was able to successfully create the channel and the datastore but fails when I try to connect the two through the create pipeline function. My code is as follows:

dactivity =  [{ 
          "channel": { 
          "channelName": channel["channelName"],
          "name": IoTAConfig["channelName"],
          "next" : IoTAConfig["datastoreName"]
           },
          "datastore": { 
          "datastoreName": ds["datastoreName"],
          "name": IoTAConfig["datastoreName"]
          }
          }]
pipeline = iota.create_pipeline(
        pipelineActivities = dactivity,           
        pipelineName = IoTAConfig["pipelineName"]
    )

The error code is as follows:

Traceback (most recent call last):
  File "createFullGG.py", line 478, in <module>
    createIoTA()
  File "createFullGG.py", line 268, in createIoTA
    pipelineName = IoTAConfig["pipelineName"]
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 320, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 623, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the UpdatePipeline operation: PipelineActivity must have one and only one member

According to the documentation pipeline activities can contain from 1 to 25 entries as long as they are in an array of 1 object. I have no idea why this continues to fail. Any help is appreciated.

1

There are 1 answers

1
Roger On BEST ANSWER

The public documentation looks a little confusing because of the way that optional elements are represented, the good news is that this is an easy fix.

A corrected version of what you are trying would be written as;

dactivity=[
    {
          "channel": {
                "channelName": channel["channelName"],
                "name": IoTAConfig["channelName"],
                "next" : IoTAConfig["datastoreName"]
           }
    },
    {
          "datastore": {
                "datastoreName": ds["datastoreName"],
                "name": IoTAConfig["datastoreName"]
          }
    }
]

response = client.create_pipeline(
        pipelineActivities = dactivity,
        pipelineName = IoTAConfig["pipelineName"] 
    )

So it's an array of activities that you are providing, like [ {A1},{A2} ] if that makes sense?

Does that help?