The code looks fine to me.
Can you try to use the
aws command line directly? If the command line does not work, then there may be a network problem.
The aws command line may look like below. This will try to read all the parameters in the SSM.
aws ssm get-parameters-by-path --path / --recursive --with-decryption