08/09/2022, 8:50 AM
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?
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 ./; ./`,
                    delete: "rm",
                    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 file and the environment variables have the place holder value test which I setup in the first remote command, I am not able to override it. I went with AcceptEnv as people recommended it in the issue I am stuck here and need some help