Getting error while terminating the Instance using Python boto3

+1 vote

This is the error I am getting when I am trying to terminate the instance.

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter InstanceIds, value: i-0bec2a0bf000bb71c, type: <class 'str'>, valid types: <class 'list'>, <class 'tuple'>

This is the code I am using

import boto3
ec2 = boto3.resource('ec2')
ec2.instances.filter(InstanceIds = 'i-27h087h66ikw').terminate()
Dec 3, 2018 in AWS by Nitesh
• 2,810 points
112 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can visit the link here and see the answer:-

https://www.edureka.co/community/32011/how-to-delete-an-ec2-instance-using-python-boto3

The mistake that you are doing is that you have to pass the list containing the instance-id not the instance-id as string.

import boto3
ids = ['i-1','i-2','i-3','i-4','i-5']
ec2 = boto3.resource('ec2')
ec2.instances.filter(InstanceIds = ids).terminate()
answered Dec 3, 2018 by Nabarupa

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

How to Pass the VPC ID while creating the Ec2 instance in AWS using Python Boto3

import boto3 ec2 = boto3.resource('ec2') instance = ec2.create_instances( ...READ MORE

answered Jan 29 in AWS by Priyaj
• 56,120 points
129 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 56,120 points
85 views
0 votes
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 56,120 points
182 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,520 points
100 views
0 votes
2 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.