当前位置:网站首页>樹莓派 + AWS IoT Greengrass
樹莓派 + AWS IoT Greengrass
2022-06-26 02:05:00 【DexterLien】
參考文檔
過程記錄
准備自動化安裝過程中IAM需要的必要權限
https://docs.amazonaws.cn/en_us/greengrass/v2/developerguide/provision-minimal-iam-policy.html
本地用配置好的aws cli確認當前的IAM user
aws sts get-caller-identity
來到IAM控制臺中先創建一個policy. 注意替換account-id
為自己的賬號ID, GreengrassV2TokenExchangeRole
如果修改的話, 需要與後面安裝過程中在--tes-role-name
後面指定的名稱一致(其實不用改, 後面不加參數默認用的就是這個名字). 另外注意此處內容中的arn:aws-cn
與文檔中寫的arn:aws
不一樣, 注意修改
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CreateTokenExchangeRole",
"Effect": "Allow",
"Action": [
"iam:AttachRolePolicy",
"iam:CreatePolicy",
"iam:CreateRole",
"iam:GetPolicy",
"iam:GetRole",
"iam:PassRole"
],
"Resource": [
"arn:aws-cn:iam::account-id:role/GreengrassV2TokenExchangeRole",
"arn:aws-cn:iam::account-id:policy/GreengrassV2TokenExchangeRoleAccess"
]
},
{
"Sid": "CreateIoTResources",
"Effect": "Allow",
"Action": [
"iot:AddThingToThingGroup",
"iot:AttachPolicy",
"iot:AttachThingPrincipal",
"iot:CreateKeysAndCertificate",
"iot:CreatePolicy",
"iot:CreateRoleAlias",
"iot:CreateThing",
"iot:CreateThingGroup",
"iot:DescribeEndpoint",
"iot:DescribeRoleAlias",
"iot:DescribeThingGroup",
"iot:GetPolicy"
],
"Resource": "*"
},
{
"Sid": "DeployDevTools",
"Effect": "Allow",
"Action": [
"greengrass:CreateDeployment",
"iot:CancelJob",
"iot:CreateJob",
"iot:DeleteThingShadow",
"iot:DescribeJob",
"iot:DescribeThing",
"iot:DescribeThingGroup",
"iot:GetThingShadow",
"iot:UpdateJob",
"iot:UpdateThingShadow"
],
"Resource": "*"
}
]
}
將policy應用到aws cli關聯使用的用戶
SSH到樹莓派
# 安裝jre(11)
sudo apt install -y default-jre
# 創建用戶
sudo useradd --system --create-home ggc_user
sudo groupadd --system ggc_group
# 修改cgroups啟動參數
sudo vi /boot/cmdline.txt
# 在末尾追加下面內容
cgroup_enable=memory cgroup_memory=1 systemd.unified_cgroup_hierarchy=0
# 改完重啟
sudo reboot
# 重啟後使用上面配置好IAM policy的user的AK/SK信息配置系統環境變量
export AWS_ACCESS_KEY_ID=xxxx
export AWS_SECRET_ACCESS_KEY=xxxx
# 下載安裝包
cd ~
curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip && unzip greengrass-nucleus-latest.zip -d GreengrassCore
# 檢查安裝包內的GreenGrass版本信息
java -jar ./GreengrassCore/lib/Greengrass.jar --version
# AWS Greengrass v2.5.6
# 執行安裝
sudo -E java -Droot="/greengrass/v2" -Dlog.store=FILE -jar ./GreengrassCore/lib/Greengrass.jar --aws-region cn-north-1 --thing-name GreengrassRaspberryPi --component-default-user ggc_user:ggc_group --provision true --setup-system-service true --deploy-dev-tools true
安裝過程中輸出內容:
Provisioning AWS IoT resources for the device with IoT Thing Name: [GreengrassRaspberryPi]...
Found IoT policy "GreengrassV2IoTThingPolicy", reusing it
Creating keys and certificate...
Attaching policy to certificate...
Creating IoT Thing "GreengrassRaspberryPi"...
Attaching certificate to IoT thing...
Successfully provisioned AWS IoT resources for the device with IoT Thing Name: [GreengrassRaspberryPi]!
Setting up resources for aws.greengrass.TokenExchangeService ...
TES role alias "GreengrassV2TokenExchangeRoleAlias" does not exist, creating new alias...
TES role "GreengrassV2TokenExchangeRole" does not exist, creating role...
IoT role policy "GreengrassTESCertificatePolicyGreengrassV2TokenExchangeRoleAlias" for TES Role alias not exist, creating policy...
Attaching TES role policy to IoT thing...
No managed IAM policy found, looking for user defined policy...
No IAM policy found, will attempt creating one...
IAM role policy for TES "GreengrassV2TokenExchangeRoleAccess" created. This policy DOES NOT have S3 access, please modify it with your private components' artifact buckets/objects as needed when you create and deploy private components
Attaching IAM role policy for TES to IAM role for TES...
Configuring Nucleus with provisioned resource details...
Downloading Root CA from "https://www.amazontrust.com/repository/AmazonRootCA1.pem"
Created device configuration
Successfully configured Nucleus with provisioned resource details!
Creating a deployment for Greengrass first party components to the device
Configured Nucleus to deploy aws.greengrass.Cli component
Creating user ggc_user
ggc_user created
Creating group ggc_group
ggc_group created
Added ggc_user to ggc_group
Successfully set up Nucleus as a system service
安裝成功後即可在Amazon IoT控制臺中看到設備的狀態:
边栏推荐
- 前置++,后置++与前置--与后置--(++a,a++与--a,a--)
- CS144 环境配置
- Tengwenze, a hot-blooded boy, was invited to serve as the image ambassador of the global finals of the sixth season perfect children's model
- Detailed explanation of WiFi related knowledge
- Other codes,, VT,,, K
- 如何制定一个可实现的年度目标?
- About vs scanf, 'scanf' appears: this function or variable may be unsafe Solutions to the problem of consumer usi
- V4L2+QT视频优化策略
- keda 2.7.1 scaledJob 代码简要分析
- Data analysis - similarities and differences between C-end and b-end data analysis
猜你喜欢
cyclegan:unpaired image-to-image translation using cycle-consistent adversarial network
Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Hangzhou
Shell learning record (I)
shell学习记录(四)
关于VS scanf出现‘scanf‘: This function or variable may be unsafe. Consider usi问题的解决方法
Differences and functions of TOS cos DSCP
jenkins汉化及汉化无效解决方案
recvmsg & sendmsg
【无标题】vsbiji esp....32
shell学习记录(一)
随机推荐
Characteristics and related specificity of Papain
Use of redis
安装了Visual Studio 2013 Redistributable,mysql还是安装失败
How to use commands to write file names (including paths) in folders to txt files
連接投影儀
Output Lua print to the cocos2d console output window
Three factors affecting personal growth
PTA class a simulated ninth bullet: 1114-1117
Byte order problem
Gun make (7) execute make
It's better to finish one than start thousands of times (reprinted from Douban)
wifi 的理论速度计算方法
如何使用命令将文件夹中的文件名(包括路径)写入到txt文件中
反向输出一个整数
Differences and functions of TOS cos DSCP
V4L2+QT视频优化策略
NDK20b FFmpeg4.2.2 编译和集成
跨域问题的一种解决方案
Find the multiplication order of n
cv==biaoding---open----cv001