This repository is a sample that uses AWS CDK v2 to deploy an AWS Greengrass Core Device.
Move to the cdk
directory.
The following work is done in the terminal.
Please replace the AWS profile for each environment. This is defined in the AWS CLI configuration files (~/.aws/config
and ~/.aws/credentials
).
To initialize AWS CDK, perform cdk bootstrap
.
cdk bootstrap --profile={your-profile}
To deploy the stack using AWS CDK, perform cdk deploy
.
At this time, use the outputs-file
option to output the results of CfnOutput
to a JSON file.
cdk deploy --profile={your-profile} --outputs-file ./cdk-output.json
When the deployment is complete, cdk-output.json
is generated under the cdk
directory.
Run the following command. In this process, it obtains credentials that temporarily have the necessary permissions to install the Greengrass Core device and generates a new JSON file.
AWS_PROFILE={your-profile} npx ts-node script/generateConfigFile.ts cdk-output.json
When the above process is complete, greengrass-config.json
is created.
Set the SSH connection destination information as your-server
in .ssh/config
.
Run the following command.
Transfer the generated greengrass-config.json
and the shell script installGreengrassCore.sh
that installs Greengrass Core to the Ubuntu machine with scp.
scp script/installGreengrassCore.sh greengrass-config.json {your-server}:~
Connect to the Ubuntu machine via ssh and run the following command to install Greengrass Core.
. ./installGreengrassCore.sh greengrass-config.json
Go to the Greengrass section of the AWS console and check that MyThing
is registered in the device list.
That's all.