Use EC2 AMI:Deep Learning AMI (Ubuntu 18.04)
Download node.js
wget https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz
Copy node.js to /usr/local/lib/node.js
sudo mkdir -p /usr/local/lib/nodejs
tar xvf node-v16.13.1-linux-x64.tar.xz
sudo mv node-v16.13.1-linux-x64/ /usr/local/lib/nodejs/node-v16.13.1-linux-x64/
Edit /etc/profile
to add following line at the end of txt
export PATH=/usr/local/lib/nodejs/node-v16.13.1-linux-x64/bin:$PATH
Edit /etc/sudoers
to add following content to the secure_path
variable
/usr/local/lib/nodejs/node-v16.13.1-linux-x64/bin:
Logout and then login again, and then install CDK
Append following code in ~/.bashrc
source /etc/profile
Run
source /etc/profile
sudo npm install -g aws-cdk
cdk --version
Download this artifact
git clone https://github.com/mlzoo/CDK-API-Gateway-Lambda-Python.git
cd CDK-API-Gateway-Lambda-Python
In the root path of this artifact, install needed python modules:
conda activate python3
pip3 install -r requirements.txt
And bootstrap the CDK
cdk bootstrap
And then run:
cdk deploy
The output will be
Outputs: ApigatewayLambdaStack.WidgetsmlapiEndpoint79472A20 = https://xxx.execute-api.us-east-1.amazonaws.com/prod/
The EDGE mode is not supported in China region, so if you are using this CDK template in China region, please change file apigateway_lambda/ml_service.py
from
api = apigateway.RestApi(self, "ml-api",
rest_api_name="Machine Learning API",
description="This service serves ML endpoint")
to
api = apigateway.RestApi(self, "ml-api",
rest_api_name="Machine Learning API-v1",
description="This service serves ML endpoint",
endpoint_types=[apigateway.EndpointType.REGIONAL],)