Hello everyone I try to use pulumi to deploy and p...
# typescript
s
Hello everyone I try to use pulumi to deploy and provision a aws lightsail app. At the moment I have a issue with the ssh commands. When I run:
Copy code
const getBitnamiPassword = new remote.Command(
    "get-bitnami-password",
    {
      create: "cat $HOME/bitnami_application_password",
      connection: {
        host: staticIp.ipAddress,
        user: "bitnami",
        privateKey: privateKey,
      },
    },
    { dependsOn: [wordpressInstance, staticIp] }
  );
I have a issue
Copy code
Failed    
   get-bitnami-password command:remote:Command
   Process exited with status 1: running "cat $HOME/bitnami_application_password":
cat: /home/bitnami/bitnami_application_password: No such file or directory
But when I run ssh command in CLI everything is working properly. What I doing wrong? 😄
q
What user are you logging in as? Is it the same
"bitnami"
user or a different one?
s
Yep, is the same
q
How's that file getting created? Is it possible that something is creating it async and it's just not there yet when the remote command runs?
s
I try to connect to aws lightsail instance, that at the moment of the cli command all files will be there.
And it seems like I have issues with paths when I connect via ssh to the lightsail
q
What do you mean? What issues with paths exactly?
s
For example I tried this code:
Copy code
const scriptContent = `
        #!/bin/bash
        cd /tmp
        curl -Ls <https://api.github.com/repos/xenolf/lego/releases/tags/v4.20.4> | grep browser_download_url | grep linux_amd64 | cut -d '"' -f 4 | wget -i -
        tar xf lego_v4.20.4_linux_amd64.tar.gz 
        sudo mkdir -p /opt/bitnami/letsencrypt 
        sudo mv lego /opt/bitnami/letsencrypt/lego 
        sudo /opt/bitnami/ctlscript.sh stop 
        sudo /opt/bitnami/letsencrypt/lego --tls --email="admin@${domainName}" --domains="${domainName}" --path="/opt/bitnami/letsencrypt" --accept-tos="1" run 
        rm -rf /opt/bitnami/apache/conf/bitnami/certs/server* 
        sudo ln -sf /opt/bitnami/letsencrypt/certificates/${domainName}.key /opt/bitnami/apache/conf/bitnami/certs/server.key 
        sudo ln -sf /opt/bitnami/letsencrypt/certificates/${domainName}.crt /opt/bitnami/apache/conf/bitnami/certs/server.crt 
        sudo chown root:root /opt/bitnami/apache/conf/bitnami/certs/server* 
        sudo chmod 600 /opt/bitnami/apache/conf/bitnami/certs/server* 
        sudo /opt/bitnami/ctlscript.sh start
    `;

  const createScriptFile = new local.Command(
    "create-script-file",
    {
      create: `echo "${scriptContent.replace(/"/g, '\\"')}" > ${path.join(rootPath, "configure-ssl.sh")}`,
    },
    { dependsOn: [wordpressInstance, staticIp, sshKeyGeneration] }
  );

  const copySSLConfig = new remote.CopyToRemote(
    "copy-ssl-script",
    {
      source: new $util.asset.FileAsset(`${rootPath}/configure-ssl.sh`),
      remotePath: "/tmp/configure-ssl.sh",
      connection: {
        host: staticIp.ipAddress,
        user: "bitnami",
        privateKey: privateKey,
      },
    },
    { dependsOn: createScriptFile }
  );

  // Install lego
  new remote.Command(
    "configure-ssl",
    {
      create:
        "sudo chmod +x /tmp/configure-ssl.sh && sudo sh /tmp/configure-ssl.sh",
      connection: {
        host: staticIp.ipAddress,
        user: "bitnami",
        privateKey: privateKey,
      },
    },
    { dependsOn: copySSLConfig }
  );
};
Sometimes
ln -sF
not able to setup the links And always the last line:
Copy code
sudo /opt/bitnami/ctlscript.sh start
Always gives an error
Maybe I need rewrite something? 😄
q
This definitely sounds odd! I'd appreciate if you could open an issue here with a pulumi program that reproduces the problem: https://github.com/pulumi/pulumi-command/issues