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
질문됨 일 년 전290회 조회
1개 답변
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
전문가
답변함 일 년 전
  • 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?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인