-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
35 lines (26 loc) · 884 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import argparse
import boto3
import constants
from clients import TimestreamClient
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--city", help="City")
args = parser.parse_args()
city = args.city
if not city:
raise ValueError("Invalid argument.")
try:
coordinates = constants.CITIES_MAPPING[city]
except KeyError:
raise ValueError("Invalid selection.")
client = boto3.client(
'timestream-write',
aws_access_key_id=constants.AWS_ACCESS_KEY_ID,
aws_secret_access_key=constants.AWS_SECRET_ACCESS_KEY,
region_name=constants.AWS_DEFAULT_REGION
)
timestream_client = TimestreamClient(client, coordinates['lat'], coordinates['lon'], args.city)
# Write sample data to Amazon Timestream
timestream_client.write_records()
if __name__ == '__main__':
main()