forked from localstack/localstack-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
141 lines (129 loc) · 5.46 KB
/
Copy pathconfig.py
File metadata and controls
141 lines (129 loc) · 5.46 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
import json
from six.moves.urllib.parse import urlparse
# central entrypoint port for all LocalStack API endpoints
EDGE_PORT = int(os.environ.get('EDGE_PORT') or 4566)
# NOTE: The endpoints below will soon become deprecated/removed, as the default in the
# latest version is to access all services via a single "edge service" (port 4566 by default)
_service_endpoints_template = {
'edge': '{proto}://{host}:4566',
'apigateway': '{proto}://{host}:4567',
'apigatewayv2': '{proto}://{host}:4567',
'kinesis': '{proto}://{host}:4568',
'dynamodb': '{proto}://{host}:4569',
'dynamodbstreams': '{proto}://{host}:4570',
'elasticsearch': '{proto}://{host}:4571',
'opensearch': '{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',
'redshift-data': '{proto}://{host}:4577',
'es': '{proto}://{host}:4578',
'ses': '{proto}://{host}:4579',
'sesv2': '{proto}://{host}:4579',
'route53': '{proto}://{host}:4580',
'route53resolver': '{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',
'iotwireless': '{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',
'rds-data': '{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',
'qldb-session': '{proto}://{host}:4611',
'cloudtrail': '{proto}://{host}:4612',
'glacier': '{proto}://{host}:4613',
'batch': '{proto}://{host}:4614',
'organizations': '{proto}://{host}:4615',
'autoscaling': '{proto}://{host}:4616',
'mediastore': '{proto}://{host}:4617',
'mediastore-data': '{proto}://{host}:4617',
'transfer': '{proto}://{host}:4618',
'acm': '{proto}://{host}:4619',
'codecommit': '{proto}://{host}:4620',
'kinesisanalytics': '{proto}://{host}:4621',
'amplify': '{proto}://{host}:4622',
'application-autoscaling': '{proto}://{host}:4623',
'kafka': '{proto}://{host}:4624',
'apigatewaymanagementapi': '{proto}://{host}:4625',
'timestream': '{proto}://{host}:4626',
'timestream-query': '{proto}://{host}:4626',
'timestream-write': '{proto}://{host}:4626',
's3control': '{proto}://{host}:4627',
'elbv2': '{proto}://{host}:4628',
'support': '{proto}://{host}:4629',
'neptune': '{proto}://{host}:4594',
'docdb': '{proto}://{host}:4594',
'servicediscovery': '{proto}://{host}:4630',
'serverlessrepo': '{proto}://{host}:4631',
'appconfig': '{proto}://{host}:4632',
'ce': '{proto}://{host}:4633',
'mediaconvert': '{proto}://{host}:4634',
'resourcegroupstaggingapi': '{proto}://{host}:4635',
'resource-groups': '{proto}://{host}:4636',
'efs': '{proto}://{host}:4637',
'backup': '{proto}://{host}:4638',
'lakeformation': '{proto}://{host}:4639',
'waf': '{proto}://{host}:4640',
'wafv2': '{proto}://{host}:4640',
'config': '{proto}://{host}:4641',
'configservice': '{proto}://{host}:4641',
}
# TODO remove service port mapping above entirely
if os.environ.get('USE_LEGACY_PORTS') not in ['1', 'true']:
for key, value in _service_endpoints_template.items():
if key not in ['dashboard', 'elasticsearch']:
_service_endpoints_template[key] = '%s:%s' % (value.rpartition(':')[0], EDGE_PORT)
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