Running APISIX in AWS with AWS CDK
This reference architecture walks you through building APISIX as a serverless container API Gateway on top of AWS Fargate with AWS CDK.
Generate an AWS CDK project with projen
update the .projenrc.js
with the following content:
const { AwsCdkTypeScriptApp } = require('projen');
const project = new AwsCdkTypeScriptApp({
cdkVersion: "1.70.0",
name: "apisix-aws",
'@aws-cdk/aws-ec2',
'@aws-cdk/aws-ecs',
'@aws-cdk/aws-ecs-patterns',
]
});
update the project:
$ npx projen
Deploy the APISIX Stack with AWS CDK
$ cdk diff
$ cdk deploy
On deployment complete, some outputs will be returned:
Outputs:
apiSix.PhpServiceLoadBalancerDNS5E5BAB1B = apiSi-PhpSe-FOL2MM4TW7G8-09029e095ab36fcc.elb.us-west-2.amazonaws.com
apiSix.ApiSixDashboardURL = http://apiSi-ApiSi-1TM103DN35GRY-1477666967.us-west-2.elb.amazonaws.com/apisix/dashboard/
apiSix.ApiSixServiceLoadBalancerDNSD4E5B8CB = apiSi-ApiSi-1TM103DN35GRY-1477666967.us-west-2.elb.amazonaws.com
Open the apiSix.ApiSixDashboardURL
from your browser and you will see the login prompt.
Configure the IP addresses returned as your upstream nodes in your APISIX dashboard followed by the Services and Routes configuration. Let’s say we have a /index.php
as the URI for the first route for our first Service from the Upstream IP addresses.
OK. Let’s test the /index.php
on {apiSix.ApiSixServiceServiceURL}/index.php
Clean up
$ cdk destroy
update src/main.ts
.addContainer('etcd', {
image: ContainerImage.fromRegistry('gcr.azk8s.cn/etcd-development/etcd:v3.3.12'),
// image: ContainerImage.fromRegistry('gcr.io/etcd-development/etcd:v3.3.12'),
})
.addPortMappings({
containerPort: 2379
})
(read here for more reference)
Run cdk deploy
and specify your preferred AWS region in China.
In the following case, we got the Outputs
returned for AWS Ningxia region(cn-northwest-1):
Outputs:
apiSix.PhpServiceLoadBalancerDNS5E5BAB1B = apiSi-PhpSe-1760FFS3K7TXH-562fa1f7f642ec24.elb.cn-northwest-1.amazonaws.com.cn
apiSix.ApiSixDashboardURL = http://apiSi-ApiSi-123HOROQKWZKA-1268325233.cn-northwest-1.elb.amazonaws.com.cn/apisix/dashboard/
apiSix.ApiSixServiceLoadBalancerDNSD4E5B8CB = apiSi-ApiSi-123HOROQKWZKA-1268325233.cn-northwest-1.elb.amazonaws.com.cn
apiSix.ApiSixServiceServiceURLF6EC7872 = http://apiSi-ApiSi-123HOROQKWZKA-1268325233.cn-northwest-1.elb.amazonaws.com.cn
Open the apiSix.ApiSixDashboardURL
URL and log in to configure your APISIX in AWS China region.
TBD
Decouple APISIX and etcd3 on AWS
TBD