<jupyter_start><jupyter_text>Buckets<jupyter_code>## Let's use Amazon S3
s3_client = boto3.resource('s3')
## that's just one of the services
## for all services, please see
## https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html#available-services
# Print out bucket names
#for bucket in s3.buckets.all():
#    print(bucket.name)
bucket_name = "my-test-bucket"
b = s3_client.Bucket(bucket_name)
for obj in b.objects.all():
    print(obj)
iot_client = boto3.client('iot')
## as described here: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iot.html#id293
## let's see what IoT devices we have
iot_client.list_things()
# iot_data_client = boto3.client('iot-data')
# iot_data_client.list_retained_messages() # needs some extra access rights shit..
# "Lambda function" is something that you can call from wherever (backend, API gateway, IoT device) and it get's executed in the cloud
# define lambda function in
# https://us-west-2.console.aws.amazon.com/lambda/home?region=us-west-2#/functions
# give it the name "myFirstLambda"
dynamodb = boto3.resource('dynamodb')
print(list(dynamodb.tables.all()))
table = dynamodb.Table('my-test-db')
# this table has the primary key 'prim' : str and sort key 'sortie' : str
response = table.put_item(
Item = { 
     'prim': 'eka',
     'sortie': 'A',
     'Name': '<NAME>',
     'Email': 'My Email'
       }
)
print(response)<jupyter_output>{'ResponseMetadata': {'RequestId': '47BQSFGT5U0B3FUT8PGIM138EFVV4KQNSO5AEMVJF66Q9ASUAAJG', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'Server', 'date': 'Fri, 18 Feb 2022 07:29:14 GMT', 'content-type': 'application/x-amz-json-1.0', 'content-length': '2', 'connection': 'keep-alive', 'x-amzn-requestid': '47BQSFGT5U0B3FUT8PGIM138EFVV4KQNSO5AEMVJF66Q9ASUAAJG', 'x-amz-crc32': '2745614147'}, 'RetryAttempts': 0}}<jupyter_text>Lambda<jupyter_code># https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html
lambda_client = boto3.client('lambda')
response = lambda_client.invoke(
    FunctionName='myFirstLambda',
    InvocationType='RequestResponse'
)
print(response["Payload"].read())
response = iot_client.describe_endpoint(
    endpointType='iot:Data-ATS'
)
print(response["endpointAddress"])
end_point_adr = response["endpointAddress"]
# create a file into the bucket
b.put_object(
    Body="kokkelis".encode("utf-8"),
    # Bucket=bucket_name,
    Key="somefile.txt"
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15169902912621358, 'fraction_numerical': 0.032766990291262135, 'mean_word_length': 5.793956043956044, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '532415', 'license': 'WTFPL', 'n_tokens_mistral': 932, 'n_tokens_neox': 879, 'n_words': 174, 'path': 'notebook/sdk_test1.ipynb', 'repo_name': 'elsampsa/aws-iot-testbed', 'size': '2473'}