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 Answer
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
EXPERT
Raphael
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions