Repository navigation
Expand file tree
/
Copy pathconfig.py
More file actions
86 lines (76 loc) · 3 KB
/
Copy pathconfig.py
File metadata and controls
86 lines (76 loc) · 3 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import os
import json
from six.moves.urllib.parse import urlparse
_service_endpoints_template = {
'dashboard': '{proto}://{host}:8080',
'apigateway': '{proto}://{host}:4567',
'apigatewayv2': '{proto}://{host}:4567',
'kinesis': '{proto}://{host}:4568',
'dynamodb': '{proto}://{host}:4569',
'dynamodbstreams': '{proto}://{host}:4570',
'elasticsearch': '{proto}://{host}:4571',
's3': '{proto}://{host}:4572',
'firehose': '{proto}://{host}:4573',
'lambda': '{proto}://{host}:4574',
'sns': '{proto}://{host}:4575',
'sqs': '{proto}://{host}:4576',
'redshift': '{proto}://{host}:4577',
'es': '{proto}://{host}:4578',
'ses': '{proto}://{host}:4579',
'route53': '{proto}://{host}:4580',
'cloudformation': '{proto}://{host}:4581',
'cloudwatch': '{proto}://{host}:4582',
'ssm': '{proto}://{host}:4583',
'secretsmanager': '{proto}://{host}:4584',
'stepfunctions': '{proto}://{host}:4585',
'logs': '{proto}://{host}:4586',
'events': '{proto}://{host}:4587',
'elb': '{proto}://{host}:4588',
'iot': '{proto}://{host}:4589',
'iotanalytics': '{proto}://{host}:4589',
'iotevents': '{proto}://{host}:4589',
'iotevents-data': '{proto}://{host}:4589',
'iot-data': '{proto}://{host}:4589',
'iot-jobs-data': '{proto}://{host}:4589',
'cognito-idp': '{proto}://{host}:4590',
'cognito-identity': '{proto}://{host}:4591',
'sts': '{proto}://{host}:4592',
'iam': '{proto}://{host}:4593',
'rds': '{proto}://{host}:4594',
'cloudsearch': '{proto}://{host}:4595',
'swf': '{proto}://{host}:4596',
'ec2': '{proto}://{host}:4597',
'elasticache': '{proto}://{host}:4598',
'kms': '{proto}://{host}:4599',
'emr': '{proto}://{host}:4600',
'ecs': '{proto}://{host}:4601',
'eks': '{proto}://{host}:4602',
'xray': '{proto}://{host}:4603',
'elasticbeanstalk': '{proto}://{host}:4604',
'appsync': '{proto}://{host}:4605',
'cloudfront': '{proto}://{host}:4606',
'athena': '{proto}://{host}:4607',
'glue': '{proto}://{host}:4608',
'sagemaker': '{proto}://{host}:4609',
'sagemaker-runtime': '{proto}://{host}:4609',
'ecr': '{proto}://{host}:4610',
'qldb': '{proto}://{host}:4611'
}
def get_service_endpoint(service, localstack_host=None):
endpoints = get_service_endpoints(localstack_host=localstack_host)
return endpoints.get(service)
def get_service_endpoints(localstack_host=None):
if localstack_host is None:
localstack_host = os.environ.get('LOCALSTACK_HOST', 'localhost')
protocol = 'https' if os.environ.get('USE_SSL') in ('1', 'true') else 'http'
return json.loads(json.dumps(_service_endpoints_template)
.replace('{proto}', protocol).replace('{host}', localstack_host))
def get_service_port(service):
ports = get_service_ports()
return ports.get(service)
def get_service_ports():
endpoints = get_service_endpoints()
result = {}
for service, url in endpoints.items():
result[service] = urlparse(url).port
return result