In [15]:
import boto3
s3=boto3.client('s3')
list=s3.list_objects(Bucket='mert01')['Contents']
list[1:3]
Out[15]:
In [27]:
# https://stackoverflow.com/questions/3337912/quick-way-to-list-all-files-in-amazon-s3-bucket
import boto
s3 = boto.connect_s3()
bucket = s3.get_bucket('mert01')
#bl = bucket.list()
#for key in bucket.list():
# print(key.name)
In [30]:
import itertools
for el in itertools.islice(bl, 0, 3):
print(el.name)
In [32]:
# len(bl)
i = 0
for key in bucket.list():
i = i + 1
print(i)
In [37]:
bl2 = bucket.list(prefix="201")
for el in itertools.islice(bl2, 0, 3):
print(el.name)
In [38]:
# https://stackoverflow.com/questions/10054985/how-to-delete-files-recursively-from-an-s3-bucket#18698235
result = bucket.delete_keys([key.name for key in bl2])
result
Out[38]:
In [ ]:
!aws configure help
In [2]:
!aws configure list
In [3]:
!cat ~/.aws/config
In [5]:
!export AWS_DEFAULT_REGION=us-west-1
!aws ec2 describe-volumes
In [6]:
!aws iam list-groups
In [7]:
!aws iam list-attached-group-policies --group-name iterative
In [1]:
!aws iam list-users
In [3]:
!awespottr c4.xlarge
In [ ]:
!export AWS_DEFAULT_REGION=us-east-2
!aws ec2 describe-spot-price-history --availability-zone "${AWS_DEFAULT_REGION}b" --product-description "Linux/UNIX" --instance-types c4.xlarge --start-time `date -u --date="7 days ago" +'%Y-%m-%dT%H:%M:00'` | jq -r -c '.SpotPriceHistory[] | (.SpotPrice)' | head -n 20
In [1]:
!aws ec2 describe-regions
In [2]:
!aws ec2 describe-availability-zones --region us-east-2
In [3]:
!aws ec2 describe-images --owners self amazon --filters "Name=root-device-type,Values=ebs" > data/ex_aws01.json
In [4]:
!cat data/ex_aws01.json | head -n 30
In [2]:
!jq '{ami: .Images[].ImageId}' data/ex_aws01.json | head -n 8
In [1]:
!jq '{ami: [.Images[].ImageId]}' data/ex_aws01.json | head -n 5
In [ ]: