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" }
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠