Adding automatic environment variable to EC2 instance

Is there any way to set environment variables on the EC2 instance automatically via terraform?
the EC2 instance lunching a bash script that includes passphrases, right now they are hardcoded, I would like to use $env_var in the bash script, that this var be automatically set by terraform.
The preferred way:
set env variable in local environment (maybe TF_VAR_*)
terraform takes this var and sets it when EC2 system boots (automation)
bash script is running using the env variable that was set automatically during boot.