代码之家  ›  专栏  ›  技术社区  ›  Daniel Birowsky Popeski

如何在CDK中获取AWS物联网自定义端点?

  •  -1
  • Daniel Birowsky Popeski  · 技术社区  · 4 年前

    我想将IoT自定义端点作为环境变量传递给在中声明的lambda CDK

    我说的是住在这里的物联网定制端点: enter image description here

    我如何在CDK的上下文中获得它?

    0 回复  |  直到 4 年前
        1
  •  6
  •   mingzhe526    4 年前

    您可以参考AWS示例代码: https://github.com/aws-samples/aws-iot-cqrs-example/blob/master/lib/querycommandcontainers.ts

    const getIoTEndpoint = new customResource.AwsCustomResource(this, 'IoTEndpoint', {
                onCreate: {
                  service: 'Iot',
                  action: 'describeEndpoint',
                  physicalResourceId: customResource.PhysicalResourceId.fromResponse('endpointAddress'),
                  parameters: {
                    "endpointType": "iot:Data-ATS"
                  }
                },
                policy: customResource.AwsCustomResourcePolicy.fromSdkCalls({resources: customResource.AwsCustomResourcePolicy.ANY_RESOURCE})
              });
    
    const IOT_ENDPOINT = getIoTEndpoint.getResponseField('endpointAddress')
    
        2
  •  0
  •   Massimo    4 年前

    AFAIK恢复的唯一方法是使用自定义资源(Lambda),例如(IoTThing): https://aws.amazon.com/blogs/iot/automating-aws-iot-greengrass-setup-with-aws-cloudformation/