def old(region, profile='default'):
project_details = json.load(open('project.json'))
boto3.setup_default_session(
profile_name=profile,
region_name=region
)
client = boto3.client('apigateway', region_name=region)
raml = ramlfications.parse('api_schema.raml')
api_name = raml.title
api_gateway = get_api_by_name(client, api_name)
if api_gateway is None:
api_gateway = client.create_rest_api(name=api_name)
aws_resources = client.get_resources(restApiId=api_gateway['id'])['items']
root = grab_root_resource(aws_resources)
resources = api.transform_resources(raml, raml.resources)
resources = associate_resources(aws_resources, resources)
aws_authorizers = client.get_authorizers(restApiId=api_gateway['id'])['items'] # NOQA
authorizers = associate_authorizers(aws_authorizers, raml.security_schemes or []) # NOQA
create_authorizer = functools.partial(
create_security_scheme,
client,
api_gateway['id'],
project_details['name']
)
authorizers = map(create_authorizer, authorizers)
for resource in resources:
print 'Creating Resource'
create_resource(
client,
api_gateway['id'],
root['id'],
resource,
project_details['name'],
authorizers
)
deployment = client.create_deployment(
restApiId=api_gateway['id'],
stageName=raml.base_uri
)
data = {
'deployment': deployment['id'],
'api': api_gateway['id'],
'uri': 'https://{}.execute-api.{}.amazonaws.com/{}/'.format(
api_gateway['id'],
region,
raml.base_uri
)
}
print data
评论列表
文章目录