本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Provision AWS IoT FleetWise 車輛
車輛中執行的 Edge Agent for AWS IoT FleetWise 軟體會收集資料並將其傳輸至雲端。 AWS IoT FleetWise 與 整合 AWS IoT Core ,支援 Edge Agent 軟體與雲端之間透過 MQTT 進行安全通訊。每部車輛對應至 實 AWS IoT 物。您可以使用現有 AWS IoT 物件來建立車輛,或設定 AWS IoT FleetWise 來自動為您的車輛建立 AWS IoT 物件。如需詳細資訊,請參閱建立 AWS IoT FleetWise 車輛。
AWS IoT Core 支援身分驗證和授權,可協助安全地控制對 AWS IoT FleetWise 資源的存取。車輛可以使用 X.509 憑證進行身分驗證 (登入),以使用 AWS IoT FleetWise 和 AWS IoT Core 政策來取得授權 (具有許可) 來執行指定的動作。
驗證 車輛
您可以建立 AWS IoT Core 政策來驗證您的 車輛。
驗證您的 車輛
-
若要建立 AWS IoT Core 政策,請執行下列命令。
-
將
policy-name
取代為您要建立的政策名稱。 -
將
file-name
取代為包含 AWS IoT Core 政策的 JSON 檔案的名稱。
aws iot create-policy --policy-name
policy-name
--policy-document file://file-name
.json使用範例政策之前,請執行下列動作:
-
將
區域
取代為您建立 AWS IoT FleetWise 資源 AWS 的區域。 -
將
awsAccount
取代為 AWS 您的帳戶 ID。
此範例包含 AWS IoT FleetWise 預留的主題。您必須將主題新增至政策。如需詳細資訊,請參閱AWS IoT FleetWise 中的預留主題。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:
region
:awsAccount
:client/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:region
:awsAccount
:topic/$aws/iotfleetwise/vehicles/${iot:Connection.Thing.ThingName}/checkins", "arn:aws:iot:region
:awsAccount
:topic/$aws/iotfleetwise/vehicles/${iot:Connection.Thing.ThingName}/signals" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:region
:awsAccount
:topicfilter/$aws/iotfleetwise/vehicles/${iot:Connection.Thing.ThingName}/collection_schemes", "arn:aws:iot:region
:awsAccount
:topicfilter/$aws/iotfleetwise/vehicles/${iot:Connection.Thing.ThingName}/decoder_manifests" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:region
:awsAccount
:topic/$aws/iotfleetwise/vehicles/${iot:Connection.Thing.ThingName}/collection_schemes", "arn:aws:iot:region
:awsAccount
:topic/$aws/iotfleetwise/vehicles/${iot:Connection.Thing.ThingName}/decoder_manifests" ] } ] } -
授權 車輛
您可以建立 X.509 憑證來授權您的 車輛。
授權您的 車輛
重要
建議您為每個車輛建立新的憑證。
-
若要建立 RSA 金鑰對並發行 X.509 憑證,請執行下列命令。
-
將
憑證
取代為儲存 certificatePem 命令輸出內容的檔案名稱。 -
以儲存 keyPair.PublicKey 命令輸出內容的檔案名稱取代
public-
key。 keyPair.PublicKey. -
將
private-key
取代為儲存 keyPair.PrivateKey.
aws iot create-keys-and-certificate \ --set-as-active \ --certificate-pem-outfile
cert
.pem \ --public-key-outfilepublic-key
.key" \ --private-key-outfileprivate-key
.key" -
-
從輸出複製憑證的 Amazon Resource Name (ARN)。
-
若要將政策連接至憑證,請執行下列命令。
-
將
policy-name
取代為您 AWS IoT Core 建立的政策名稱。 -
將
certificate-arn
取代為您複製之憑證的 ARN。
aws iot attach-policy \ --policy-name
policy-name
\ --target "certificate-arn
" -
-
若要將憑證連接至物件,請執行下列命令。
-
將
thing-name
取代為 AWS IoT 物件名稱或車輛 ID。 -
將
certificate-arn
取代為您複製之憑證的 ARN。
aws iot attach-thing-principal \ --thing-name
thing-name
\ --principal "certificate-arn
" -