I am trying to install AWS Greengrass on a windows machine, but it fails with the following output (after correctly configuring aws credentials and downloading the official packages):
C:\...> java "-Droot=C:\greengrass\v2" "-Dlog.store=FILE" -jar .\GreengrassCore\lib\Greengrass.jar --aws-region eu-west-1 --thing-name Greengrass-balazs --thing-group-name GreengrassGroup --component-default-user ggc_user --provision true --setup-system-service true --deploy-dev-tools true
Provisioning AWS IoT resources for the device with IoT Thing Name: [Greengrass-balazs]...
Found IoT policy "GreengrassV2IoTThingPolicy", reusing it
Creating keys and certificate...
Attaching policy to certificate...
Creating IoT Thing "Greengrass-balazs"...
Attaching certificate to IoT thing...
Successfully provisioned AWS IoT resources for the device with IoT Thing Name: [Greengrass-balazs]!
Adding IoT Thing [Greengrass-balazs] into Thing Group: [GreengrassGroup]...
IoT Thing Group "GreengrassGroup" already existed, reusing it
Successfully added Thing into Thing Group: [GreengrassGroup]
Setting up resources for aws.greengrass.TokenExchangeService ...
Attaching TES role policy to IoT thing...
No managed IAM policy found, looking for user defined policy...
IAM policy named "GreengrassV2TokenExchangeRoleAccess" already exists. Please attach it to the IAM role if not already
Configuring Nucleus with provisioned resource details...
Root CA file found at "C:\greengrass\v2\rootCA.pem". Contents will be preserved.
Downloading Root CA from "https://www.amazontrust.com/repository/AmazonRootCA1.pem"
Created device configuration
Successfully configured Nucleus with provisioned resource details!
Thing group exists, it could have existing deployment and devices, hence NOT creating deployment for Greengrass first party dev tools, please manually create a deployment if you wish to
Default user creation is only supported on Linux platforms, Greengrass will not make a user for you. Ensure that the user exists and password is stored. Continuing...
Unable to set up Nucleus as a system service
I tried to follow the troubleshooting guide but it seems outdated? Couldn't really understand what this is supposed to do.
C:\Users\bk73027\Projects> Set-Service -Name "greengrass" -Status stopped -StartupType enabled
>>
Set-Service : Cannot bind parameter 'StartupType'. Cannot convert value "enabled" to type "System.ServiceProcess.ServiceStartMode". Error: "Unable to match the identifier name enabled to a valid enumerator
name. Specify one of the following enumerator names and try again:
Boot, System, Automatic, Manual, Disabled"
At line:1 char:61
+ Set-Service -Name "greengrass" -Status stopped -StartupType enabled
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Service], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.SetServiceCommand
In the logs, I can see the following in C:\greengrass\v2\logs~greengrass.log
:
2022-08-03T11:54:49.086Z [INFO] (main) com.aws.greengrass.util.platforms.Platform: Getting platform instance com.aws.greengrass.util.platforms.windows.WindowsPlatform.. {}
2022-08-03T11:54:49.187Z [WARN] (Serialized listener processor) com.aws.greengrass.lifecyclemanager.KernelAlternatives: C:\greengrass\v2\alts\current. {}
2022-08-03T11:54:49.188Z [WARN] (Serialized listener processor) com.aws.greengrass.lifecyclemanager.KernelAlternatives: C:\greengrass\v2\alts\current. {}
2022-08-03T11:54:49.192Z [INFO] (main) com.aws.greengrass.lifecyclemanager.Kernel: No ongoing deployment detected. Proceed as default. {}
2022-08-03T11:54:49.252Z [INFO] (main) com.aws.greengrass.config.Configuration: config-loading. Read configuration from a file path. {path=C:\greengrass\v2\config\config.tlog}
2022-08-03T11:54:49.297Z [INFO] (main) com.aws.greengrass.lifecyclemanager.Kernel: effective-config-dump-complete. {file=C:\greengrass\v2\config\effectiveConfig.yaml}
2022-08-03T11:54:49.385Z [INFO] (main) com.aws.greengrass.deployment.DeviceConfiguration: Copy Nucleus artifacts to component store. {destination=C:\greengrass\v2\packages\artifacts-unarchived\aws.greengrass.Nucleus\2.7.0\aws.greengrass.nucleus, source=C:\Users\bk73027\Projects\GreengrassCore}
2022-08-03T11:54:49.460Z [ERROR] (main) com.aws.greengrass.deployment.DeviceConfiguration: Unable to set up Nucleus from build recipe file. {}
java.io.IOException: Failed to setup initial launch directory. Expecting loader script at: C:\greengrass\v2\alts\current\distro\bin\loader.cmd
at com.aws.greengrass.lifecyclemanager.KernelAlternatives.relinkInitLaunchDir(KernelAlternatives.java:206)
at com.aws.greengrass.deployment.DeviceConfiguration.initializeComponentStore(DeviceConfiguration.java:357)
at com.aws.greengrass.deployment.DeviceConfiguration.initializeNucleusFromRecipe(DeviceConfiguration.java:388)
at com.aws.greengrass.lifecyclemanager.Kernel.parseArgs(Kernel.java:645)
at com.aws.greengrass.easysetup.GreengrassSetup.performSetup(GreengrassSetup.java:296)
at com.aws.greengrass.easysetup.GreengrassSetup.main(GreengrassSetup.java:269)
2022-08-03T11:55:06.421Z [INFO] (main) com.aws.greengrass.lifecyclemanager.Kernel: effective-config-dump-complete. {file=C:\greengrass\v2\config\effectiveConfig.yaml}
2022-08-03T11:55:06.425Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: Waiting for services to shutdown. {}
2022-08-03T11:55:06.431Z [WARN] (main) com.aws.greengrass.lifecyclemanager.KernelAlternatives: C:\greengrass\v2\alts\current. {}
2022-08-03T11:55:06.433Z [ERROR] (main) com.aws.greengrass.util.orchestration.WinswUtils: winsw-setup. Failed to set up Windows service. {}
java.nio.file.FileAlreadyExistsException: C:\greengrass\v2\alts\current
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:87)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at java.base/sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(WindowsFileSystemProvider.java:585)
at java.base/java.nio.file.Files.createSymbolicLink(Files.java:1059)
at com.aws.greengrass.lifecyclemanager.KernelAlternatives.setupLinkToDirectory(KernelAlternatives.java:345)
at com.aws.greengrass.lifecyclemanager.KernelAlternatives.setupInitLaunchDirIfAbsent(KernelAlternatives.java:178)
at com.aws.greengrass.util.orchestration.WinswUtils.setupSystemService(WinswUtils.java:38)
at com.aws.greengrass.easysetup.GreengrassSetup.performSetup(GreengrassSetup.java:328)
at com.aws.greengrass.easysetup.GreengrassSetup.main(GreengrassSetup.java:269)
2022-08-03T11:55:06.433Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: system-shutdown. {main=null}
2022-08-03T11:55:06.443Z [INFO] (main) com.aws.greengrass.lifecyclemanager.Kernel: effective-config-dump-complete. {file=C:\greengrass\v2\config\effectiveConfig.yaml}
2022-08-03T11:55:06.444Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: Waiting for services to shutdown. {}
2022-08-03T11:55:06.444Z [INFO] (Serialized listener processor) com.aws.greengrass.lifecyclemanager.KernelLifecycle: executor-service-shutdown-initiated. {}
2022-08-03T11:55:06.445Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: Waiting for executors to shutdown. {}
2022-08-03T11:55:06.445Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: executor-service-shutdown-complete. {executor-terminated=true, scheduled-executor-terminated=true}
2022-08-03T11:55:06.445Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: context-shutdown-initiated. {}
2022-08-03T11:55:06.446Z [INFO] (main) com.aws.greengrass.lifecyclemanager.KernelLifecycle: context-shutdown-complete. {}
According to this, I have placed the script there:
C:\Users\bk73027\Projects> cat C:\greengrass\v2\alts\current\distro\bin\loader.cmd
@REM -------------------------------
@REM Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@REM SPDX-License-Identifier: Apache-2.0
@REM -------------------------------
@echo off
SETLOCAL EnableDelayedExpansion
etc...
But it still writes the same error.
After deleting the c:\greengrass folder, and starting from stratch again, it worked.
I suspect that the problem was that I did not follow the guide precisely.
This step is crucial: In the "Install the Amazon IoT Greengrass Core software (CLI)" it says:
- On your Greengrass core device, run the following command to switch to the home directory.
cd ~
As I have created a different work folder to download & extract the files, it must have messed up how it creates the symlinks. The folder was empty, but after executing the commands from my home folder, the folders were filled with those and it successfully installed greengrass.