๐Ÿ“/cloudIOT

AWS ๊ธฐ๋ฐ˜ ์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ (1) AWS IoT Core

sssbin 2022. 6. 16. 12:15

 

 

mqtt๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐ„๋‹จํ•œ AWS ๊ธฐ๋ฐ˜ ์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์„ ๋งŒ๋“ค์–ด๋ณด๊ณ ์ž ํ•œ๋‹ค.

camera.js -> ๋ฒˆํ˜ธํŒ ์ด๋ฏธ์ง€๋ฅผ S3์— ์—…๋กœ๋“œํ•˜๊ณ  request ํ† ํ”ฝ์— publish ํ•˜๊ณ 

์ด๋•Œ ๋žŒ๋‹คํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜์–ด rekognition ์ง„ํ–‰ ํ›„ detect ํ† ํ”ฝ์— publish ํ•˜๋ฉด

manage.js -> detect ํ† ํ”ฝ์— subscribe ํ•˜๊ณ  ๋ฐ›์€ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

 

 

์‹œ์Šคํ…œ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด AWS IoT Core์„ ์ด์šฉํ–ˆ๋‹ค.

 

 

 

1. AWS IoT > ๊ด€๋ฆฌ > ์‚ฌ๋ฌผ > ์‚ฌ๋ฌผ ์ƒ์„ฑ

 

์ •์ฑ… ์„ค์ •์€ ์ผ๋‹จ ๊ฑด๋„ˆ๋›ฐ๊ณ  ์‚ฌ๋ฌผ ์ƒ์„ฑํ•˜๋ฉด ์ธ์ฆ์„œ ํ‚ค ๋‹ค์šด๋กœ๋“œ ์ฐฝ ๋‚˜์˜ค๋Š”๋ฐ ๋ชจ๋‘ ๋‹ค์šด ๋ฐ›๊ธฐ

์ด๋•Œ ๋ฌด์กฐ๊ฑด ๋‹ค์šด๋ฐ›์•„์•ผ ํ•จ!!!!!!!! โญ๏ธโญ๏ธโญ๏ธ

 

 

๋งŒ๋“  ์‚ฌ๋ฌผ ARN ๋ณต์‚ฌ

 

 

2. AWS IoT > ๋ณด์•ˆ > ์ •์ฑ… > ์ •์ฑ… ์ƒ์„ฑ

 

์ •์ฑ… ํšจ๊ณผ์— 

iot:Connect

iot:Publish

iot:Receive

iot:Subscribe

์ถ”๊ฐ€

 

Connect ์ •์ฑ… ๋ฆฌ์†Œ์Šค์— ์œ„์—์„œ ๋งŒ๋“ค์—ˆ๋˜ ์‚ฌ๋ฌผ ARN ๋„ฃ์–ด์ฃผ๊ธฐ

๋‚˜๋จธ์ง€๋Š” ์ผ๋‹จ * ๋กœ ์„ค์ •

 

 

- ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ manage ์‚ฌ๋ฌผ๊ณผ ManagePolicy ์ •์ฑ… ์ƒ์„ฑ

 

3. AWS IoT Device SDK ์„ค์น˜

https://docs.aws.amazon.com/ko_kr/iot/latest/developerguide/connecting-to-existing-device.html

์šด์˜์ฒด์ œ ์—…๋ฐ์ดํŠธ ๋ฐ ํ•„์ˆ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install cmake
$ sudo apt-get install libssl-dev
git ์„ค์น˜

$ sudo apt-get install git
์ตœ์‹  ๋ฒ„์ „์˜ Node.js ์„ค์น˜

$ cd ~
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ sudo apt-get install -y nodejs


๋…ธ๋“œ, npm ์„ค์น˜ ํ™•์ธ

$ node -v
$ npm -v
AWS IoT Device SDK ์„ค์น˜

$ cd ~
$ git clone https://github.com/aws/aws-iot-device-sdk-js-v2.git
$ cd ~/aws-iot-device-sdk-js-v2
$ npm install

 

 

4. ์ธ์ฆ์„œ ํด๋” ๋งŒ๋“ค๊ธฐ

certs ํด๋” ์ƒ์„ฑ -> ๊ทธ ์•ˆ์— camera, manage ํด๋” ์ƒ์„ฑ -> ๊ทธ ์•ˆ์— ๊ฐ๊ฐ ํ•ด๋‹นํ•˜๋Š” ์ธ์ฆ์„œ ํŒŒ์ผ๋“ค ๋„ฃ์–ด์ฃผ๊ธฐ

์“ฐ๊ธฐ ์‰ฝ๋„๋ก ์ด๋ฆ„ ๋ฐ”๊ฟ”์คฌ๋‹ค

~์ƒ˜ํ”Œ ์•ฑ ์‹คํ–‰์€ ์ƒ๋žต ์œ„ ๋งํฌ ํƒ€๊ณ  ๋“ค์–ด๊ฐ€์„œ ๋”ฐ๋ผํ•˜๋ฉด ๋จ~

 

// access-keys.js

exports.access_key = "์•ก์„ธ์Šค ํ‚ค"
exports.secret_key = "์‹œํฌ๋ฆฟ ํ‚ค"

ํด๋” ์•ˆ์— access-keys.js ๋„ ๋งŒ๋“ค์–ด์ฃผ๊ธฐ

์•ก์„ธ์Šคํ‚ค / ์‹œํฌ๋ฆฟํ‚ค ๋Š” IAM ๊ณ„์ • ์ƒ์„ฑํ•  ๋•Œ ๋‹ค์šด ๋ฐ›์€ ์ธ์ฆ์„œ csv ํŒŒ์ผ ์•ˆ์— ๋“ค์–ด์žˆ์Œ

 

 

https://sssbin.tistory.com/188

 

AWS ๊ธฐ๋ฐ˜ ์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ (2) Lambda ์„ค์ •

https://sssbin.tistory.com/187 ๋ฒˆํ˜ธํŒ ์ด๋ฏธ์ง€๋ฅผ S3์— ์—…๋กœ๋“œํ•˜๊ณ  request ํ† ํ”ฝ์— publish ํ•˜๊ณ  ์ด๋•Œ ๋žŒ๋‹คํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜์–ด rekognition ์ง„ํ–‰ ํ›„ detect ํ† " data-og-host="sssbin.tistory.com" data-og-source-ur..

sssbin.tistory.com