Amazon cloudformation CloudFormation-以Ubuntu用户身份运行的用户数据

Amazon cloudformation CloudFormation-以Ubuntu用户身份运行的用户数据,amazon-cloudformation,Amazon Cloudformation,我的CFN模板中有以下用户数据: UserData: 'Fn::Base64': !Sub | #!/bin/bash sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get -y install python-pip; sudo apt-get -y install gcc; sudo apt-get -y in

我的CFN模板中有以下用户数据:

  UserData:
    'Fn::Base64': 
      !Sub |
        #!/bin/bash
        sudo apt-get update;
        sudo apt-get upgrade -y;
        sudo apt-get -y install python-pip;
        sudo apt-get -y install gcc;
        sudo apt-get -y install gcc-c++;
        sudo apt-get install awscli -y;
        sudo apt-get install python-mysqldb;
        echo "$(pwd)" >> /home/ubuntu/current1.txt

        cd /home/ubuntu/;
        echo "$(pwd)" >> /home/ubuntu/current2.txt
        pip install apache-airflow;
        pip install celery==4.4.0;
        pip install kombu==4.5.0;
        echo "$(pwd)" >> /home/ubuntu/current3.txt
        cd /home/ubuntu/airflow/;
        echo "$(pwd)" >> /home/ubuntu/current4.txt
        mv airflow.cfg airflow.cfg.original_1;
        cd /home/ubuntu/;
        nohup airflow initdb;
        nohup airflow webserver -p 8080 >> webserver.log &;   
        nohup airflow scheduler >> scheduler.log &;
        nohup airflow worker >> worker.log &;
如果我安装了
cd/home/ubuntu
,然后又安装了apache,那么它仍然是在root下安装的

我想在
/home/ubuntu
下安装apache airflow


如何在
/home/ubuntu
用户下安装软件包

在Ubuntu实例上自动安装Ghost时,我遇到了类似的情况。您可以尝试切换用户。当我试图专门使用pip安装软件包时,我必须对此进行测试。但以下是我作为非root用户运行某些特定设置命令的示例:

su ghost-user << 'EOF'
cd /ghost-app/ghost
ghost install --no-setup --no-stack --dbhost 10.16.11.80 --dbuser ghost --dbpass myterribledbasepassword --dbname ghost_prod
EOF

su ghost user我想知道您是否可以设置
导出气流\u HOME=/HOME/ubuntu/aiffort/
?见: