Skip to content

Instantly share code, notes, and snippets.

@narutaro
Last active March 13, 2022 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narutaro/b843f5bc54790dc31819673897c6f1db to your computer and use it in GitHub Desktop.
Save narutaro/b843f5bc54790dc31819673897c6f1db to your computer and use it in GitHub Desktop.
Shell script for automating the procedure here
# Shell script for the procedure here.
# https://docs.aws.amazon.com/greengrass/v2/developerguide/create-components.html
if [ $# != 1 ]; then
echo "Usage: $0 <dirname>"
exit 1
else
mkdir -p $1/{recipes,artifacts}
cat <<EOS > $1/recipes/com.example.HelloWorld-1.0.0.json
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "com.example.HelloWorld",
"ComponentVersion": "1.0.0",
"ComponentDescription": "My first AWS IoT Greengrass component.",
"ComponentPublisher": "Amazon",
"ComponentConfiguration": {
"DefaultConfiguration": {
"Message": "world"
}
},
"Manifests": [
{
"Platform": {
"os": "linux"
},
"Lifecycle": {
"Run": "python3 -u {artifacts:path}/hello_world.py \"{configuration:/Message}\""
}
},
{
"Platform": {
"os": "windows"
},
"Lifecycle": {
"Run": "py -3 -u {artifacts:path}/hello_world.py \"{configuration:/Message}\""
}
}
]
}
EOS
mkdir -p $1/artifacts/com.example.HelloWorld/1.0.0
cat <<EOS > $1/artifacts/com.example.HelloWorld/1.0.0/hello_world.py
import sys
message = "Hello, %s!" % sys.argv[1]
# Print the message to stdout, which Greengrass saves in a log file.
print(message)
EOS
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment