Hey I am having issues with running pulumi remote ...
# aws
s
Hey I am having issues with running pulumi remote command with environment variables, I tried a couple of things such as adding placeholder values in bashrc and setting AcceptEnv in another remote command that runs before the main one, still no joy What am I missing here?
Copy code
const setEnvVarsCommand = new remote.Command("set-env-vars", {connection,
                    create: pulumi.interpolate`echo "export MASTER_USER='"test"'\nexport MASTER_PASSWORD='test'\nexport DB_USERNAME='test'\nexport DB_PASSWORD='test'\nexport DB_NAME='test'\nexport DB_HOST='test'" >> ~/.bashrc && source ~/.bashrc && echo "AcceptEnv MASTER_USER MASTER_PASSWORD DB_USERNAME DB_PASSWORD DB_NAME DB_HOST" | sudo tee -a /etc/ssh/sshd_config && sudo service sshd restart`,
                    delete: `head -n -6 ~/.bashrc > tmp_file && mv tmp_file ~/.bashrc && head -n -1 ~/.bashrc > tmp_sshd && sudo mv tmp_sshd /etc/ssh/sshd_config`
                }, { dependsOn: remoteFile });

 new remote.Command("mysql-setup-execute", {connection,
                    create: pulumi.interpolate`chmod 777 ./mysql-setup.sh; ./mysql-setup.sh`,
                    delete: "rm mysql-setup.sh",
                    environment: {
                        MASTER_USER: masterUsername,
                        MASTER_PASSWORD: masterPassword!,
                        DB_USERNAME: dbUsername,
                        DB_PASSWORD: dbUserPassword,
                        DB_NAME: dbName,
                        DB_HOST: dbHost
                    }
                }, { dependsOn: setEnvVarsCommand });
I am dumping all the env variables available in the mysql-setup.sh file and the environment variables have the place holder value test. I went with AcceptEnv as people recommended it in the issue https://github.com/pulumi/pulumi-command/issues/48 I am stuck here and need some help
l
It looks like the environment variables you're expecting to see are set up in .bashrc. Non-interactive bash shells don't run .bashrc. Plus, you don't seem to be running bash (though you might be, I can't see the shebang in mysql-setup.sh). You can familiarize yourself with how remote execs and non-interactive shells work by reading `man bash`; the section titled "Invocation" has all the details.
There are many places to read up on how shebangs work and how to use them effectively over ssh. This page looks like a good place to start: https://linuxhandbook.com/shebang/