"parameterOverrides" in pre-provisioning hook response not working

0

Hello,

I'm trying to follow the instructions in https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html

In there it mentions the "parameterOverrides" option that sends values back to the device during provisioning.

However, using the code in https://github.com/aws-samples/aws-iot-fleet-provisioning, the response from RegisterThing always comes back as {'deviceConfiguration': {}, 'thingName': 'MyNewThingName'} , i.e with an empty deviceConfiguration.

Example of lambda handler in simplest form that fails:

def lambda_handler(event, context):
    return {
        "allowProvisioning": True,
        "parameterOverrides" : {
           "customKeysAndValues": "sentToDevice"
        }
    }

Is there anything I'm missing here?

질문됨 4년 전491회 조회
3개 답변
0

Thanks for reaching out. If you are using the sample template from Github README, it says DeviceConfiguration is empty. (very end of README. file)

"DeviceConfiguration": {}

If you are planning on sending data back to the device, you need to define DeviceConfiguration parameters. The values can be provided by the Lambda function. For example, I would like to send ServerUrl to device, then I define something like,

    "DeviceConfiguration": {
        "ServerUrl": {"Ref": "ServerUrl"}
    }

My Lambda function will return the value for ServerUrl through parameterOverrides.

def lambda_handler(event, context):
    return {
        "allowProvisioning": True,
        "parameterOverrides" : {
           "ServerUrl": "https://amazon.com/devices" // dummy URL
        }
    }

Lambda function does supply the values for the parameters you defined in DeviceConfiguration. This way, customer knows what parameters are going to device by looking at the provisioning template.

Hope this helps,
Ranga

AWS
답변함 4년 전
0

Great! It now works :)
One thing that could be improved in the docs as a follow-up is having in the examples something like a you described to reference "Parameter" values, i.e. having

"DeviceConfiguration": {
    "SomeConfig": {"Ref": "SomeParameter"}
}

Because from my side I interpreted (wrongly) that simply adding something to "parameterOverrides" would already add to "deviceConfiguration" configuration. At least from this quote in the doc:
"parameterOverrides" will be added to "deviceConfiguration" parameter in RegisterThing response payload.

Nevertheless, your answer solved my issue, thank you very much!

답변함 4년 전
0

Glad it worked. Yes, we are working on fixing the documentation. Thanks for pointing it out.

Thanks,
Ranga

AWS
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠