AWS ec2 ubuntu 18.04 LTS python upgrade

0

I am creating aws ec2 Ubuntu 18.04 LTS using cloud formation template and have user data to run commands during launch of instance. In user data, command is written to install python3.8:

apt-get install python3.8 -y

This cloud formation / user data is not installing python 3.8 on ec2 instance (checked after running command: python3.8 --version on ssh client). If manually connect instance with ssh client (putty) and run apt-get install python3.8 -y , it install python 3.8 on instance. I analysed cfn-init.log & cfn-init-output.log at /var/log/ on ec2 instance, but didn't find any useful information for python3.8

Can anyone help me to find why cloud formation template / user data is not installing python3.8 but ssh client (putty) can install python3.8

The user data section is as below:

      UserData: "Fn::Base64": "Fn::Sub":
     - | #!/bin/bash
     # Install Python dependencies 


      apt-get update 
      apt-get update && apt -y upgrade 
      apt-get install dos2unix
      apt-get install -y python-pip
      
      apt-get install -y python3.6 python3-pip
      apt-get install python3.8 -y # installing python3.8

      pip3 install --no-cache-dir NumPy

      # Install AWS cli and init functions
      pip3 install --no-cache-dir awscli
      pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz 
      ln -s /usr/local/bin/cfn-hup /etc/init.d/cfn-hup
      cfn-init -v --stack ${STACK} --resource resources --configsets install --region ${REGION}
    - { STACK: !Ref "AWS::StackName" , REGION: !Ref "AWS::Region" }
已提问 2 年前432 查看次数
1 回答
0

I would ask:

  1. Does your instance have access to the internet (or apt repos to fetch from)?
  2. How long did you wait?

The following user data worked for me on the Ubuntu 18.04 LTS AMI:

      UserData:
        Fn::Base64: !Sub |
          #!/bin/bash -xe

          echo "Started" > /tmp/1234

          apt-get update -y
          apt-get upgrade -y
          apt-get install python3.8 -y
          apt-get install python3-pip -y

          pip3 install --no-cache-dir NumPy
          pip3 install --no-cache-dir awscli

          aws sts get-caller-identity > /tmp/2345
AWS
专家
Raphael
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则