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:

    1. const { AwsCdkTypeScriptApp } = require('projen');
    2. const project = new AwsCdkTypeScriptApp({
    3. cdkVersion: "1.70.0",
    4. name: "apisix-aws",
    5. '@aws-cdk/aws-ec2',
    6. '@aws-cdk/aws-ecs',
    7. '@aws-cdk/aws-ecs-patterns',
    8. ]
    9. });

    update the project:

    1. $ npx projen

    Deploy the APISIX Stack with AWS CDK

    1. $ cdk diff
    2. $ cdk deploy

    On deployment complete, some outputs will be returned:

    1. Outputs:
    2. apiSix.PhpServiceLoadBalancerDNS5E5BAB1B = apiSi-PhpSe-FOL2MM4TW7G8-09029e095ab36fcc.elb.us-west-2.amazonaws.com
    3. apiSix.ApiSixDashboardURL = http://apiSi-ApiSi-1TM103DN35GRY-1477666967.us-west-2.elb.amazonaws.com/apisix/dashboard/
    4. 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.

    upstream with AWS NLB IP addresses

    define route with service and uri

    OK. Let’s test the /index.php on {apiSix.ApiSixServiceServiceURL}/index.php

    Clean up

    1. $ cdk destroy

    update src/main.ts

    1. .addContainer('etcd', {
    2. image: ContainerImage.fromRegistry('gcr.azk8s.cn/etcd-development/etcd:v3.3.12'),
    3. // image: ContainerImage.fromRegistry('gcr.io/etcd-development/etcd:v3.3.12'),
    4. })
    5. .addPortMappings({
    6. containerPort: 2379
    7. })

    (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):

    1. Outputs:
    2. apiSix.PhpServiceLoadBalancerDNS5E5BAB1B = apiSi-PhpSe-1760FFS3K7TXH-562fa1f7f642ec24.elb.cn-northwest-1.amazonaws.com.cn
    3. apiSix.ApiSixDashboardURL = http://apiSi-ApiSi-123HOROQKWZKA-1268325233.cn-northwest-1.elb.amazonaws.com.cn/apisix/dashboard/
    4. apiSix.ApiSixServiceLoadBalancerDNSD4E5B8CB = apiSi-ApiSi-123HOROQKWZKA-1268325233.cn-northwest-1.elb.amazonaws.com.cn
    5. 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