For this guide -- https://linuxacademy.com/cp/socialize/index/type/community_post/id/14209 Can someone clarify are we supposed to append the code below to the list_instances.py script?  Or are they supposed to be two separate scripts?

import boto3

ec2 = boto3.resource('ec2')

instance = ec2.create_instances(

ImageId='ami-1e299d7e',

MinCount=1,

MaxCount=1,

InstanceType='t2.micro')

print instance[0].id

When I append it, I get syntax errors but when I leave the list_instances.py script like this (screenshot)user_331868_5bbe639e2d0cc.png, nothing happens (it doesn't list my instances).

  • post-author-pic
    cblanche
    10-10-2018

    Is the guide supposed to be compatible with the cloud servers? Are there any settings/configs on the servers that would interfere with being able to follow along? I terminated the cloud server and created a new one and now I can't even install the aws cli I get this error. user_331868_5bbe6fcadab1f.png_800.jpg

  • post-author-pic
    Keith T
    10-11-2018

    As far as I can tell, it looks like the code in your initial post should go in a separate script that I would call create_instance.py. It doesn't say that, but since the rest of the scripts all do one thing I think you're safe to call it that and put it in its own script.


    For the error you're seeing, it's really hard to read but it looks like a permissions issue. It looks like the example command is slightly off for cloud servers. You can either use `sudo` with the command to install globally or pass the `--user` flag to the command to install it just for you cloud server user.

  • post-author-pic
    cblanche
    10-11-2018

    If you right click the thumbnail and hit view image it will maximize the screenshot..Anyway I copied and pasted both scripts, created two separate scripts (list_instances.py and createinstances.py) yet I'm still getting this error when i run createinstances.pyuser_331868_5bbf6cf2e686e.png_800.jpg

  • post-author-pic
    cblanche
    10-12-2018

    Can somebody take a look at this?

Looking For Team Training?

Learn More