How do I access Greengrass Core environment variables in AWS System Manager Run Command

0

I have AWS systems manager managed node setup for a greengrass core device and want to run command to execute shell script. The shell script needs to access greengrass core environment variables $AWS_IOT_THING_NAME to process. However, I do not see any value returned by $AWS_IOT_THING_NAME.

  1. Is there a different mechanism to access the greengrass env variables by the AWS SSM run command?
  2. I can see that the SourceId of the node is same as the AWS_IOT_THING_NAME. Can I access it inside a shell script as environmental variable?

I need to execute a script to run on multiple devices which uploads images to the s3 bucket with folder name {AWS_IOT_THING_NAME}/images. I know this can be done using custom greengrass component, but I want to try it using the AWS SSM fleet manager.

raghak
gefragt vor einem Jahr290 Aufrufe
1 Antwort
0

Hi,

SSM Agent is not able to access Greengrass variables since it is not executed as a child process of Greengrass, but as an independent process executed by systemd, even when you deploy it via aws.greengrass.SystemManagerAgent component.

What you can do is to write a component that export that variable so that it is available to the script run by the SSM Agent. One example would be to write that ThingName in a file inside /var/ or /etc/ folders, and then read it from your script before executing it. Alternatively the custom component could add an export to the .bashrc file of the SSM Agent user and execute your script in bash.

Cheers,

Massimiliano

AWS
EXPERTE
beantwortet vor einem Jahr
  • Hi Massimiliano, Is there a way to get the Managed node "SourceId" using the SSM run command to run a shell script?

  • Could you please explain what you are trying to do?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen