def bootstrap_api(stage_name):
"""
Upload a bootstrap Swagger document to a new API Gateway object and set it live
with environment-specific variables.
"""
client = boto3.client('apigateway', region_name=args.aws_region)
# bootstrap.json is relative to me; where am I?
my_dir = os.path.dirname(os.path.realpath(__file__))
bootstrap_swagger = open(my_dir + '/bootstrap.json', 'r')
response = client.import_rest_api(body=bootstrap_swagger.read())
logging.info('New bootstrap API ID "%s" created', response['id'])
client.create_deployment(
restApiId=response['id'],
stageName=stage_name)
logging.info('API ID "%s" deployed to stage "%s"', response['id'], stage_name)
return response['id']
评论列表
文章目录