在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:awslabs/aws-api-gateway-developer-portal开源软件地址:https://github.com/awslabs/aws-api-gateway-developer-portal开源编程语言:JavaScript 98.8%开源软件介绍:IntroductionThe Amazon API Gateway Serverless Developer Portal is an application that you use for developer engagement by making your API Gateway APIs available to your customers through self-service discovery of those APIs. Your customers can use the developer portal to browse API documentation, register for – and immediately receive – their own API key that can be used to build applications, test published APIs, monitor their own API usage, generate SDKs, and submit feedback on your APIs design. For more information about Amazon API Gateway, visit the API Gateway product page. SetupThere are three main ways to deploy the Developer Portal today: 1. Deploy using SARIf all you want to do is deploy it as it is out of the box, you can do it by simply following the instructions in the Serverless Developer Portal documentation. 2. Deploy using SAMIf you plan to automate the deployment through your own infrastructure or if you just want to customize the template, you can just use the SAM CLI to do it. See the SAM Deployment Guide for how to do this. 3. Deploy using the development scriptsThis deployment model is better if you choose to modify the developer portal assets and/or design itself or if you need to do something else more advanced. See the development guide for how to do this. PrerequisitesFirst, ensure you have the latest version of the SAM CLI installed. Note that while the instructions specify Docker as a pre-requisite, Docker is only necessary for local development via SAM local. Feel free to skip installing Docker when you first set up the developer portal. Then, clone this repo into a local directory. Ensure that you have an S3 bucket to put zipped lambda functions into. It can be private, and will be referred to in this readme as If you have not used the AWS CLI or SAM CLI before, you may need to configure your AWS credentials file. If you have previously set up a v1 developer portal (non-SAM deployed), you will need to either remove all the v1 developer portal resources (dynamo tables, roles, etc.) or provide new names for the v2 developer portal by passing in parameter overrides for every resource. DeployRun the following, with
sam package --template-file ./cloudformation/template.yaml \
--output-template-file ./cloudformation/packaged.yaml \
--s3-bucket YOUR_LAMBDA_ARTIFACTS_BUCKET_NAME Then run the following, with
sam deploy --template-file ./cloudformation/packaged.yaml \
--stack-name "dev-portal" \
--s3-bucket YOUR_LAMBDA_ARTIFACTS_BUCKET_NAME \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides \
DevPortalSiteS3BucketName="CUSTOM_PREFIX-dev-portal-static-assets" \
ArtifactsS3BucketName="CUSTOM_PREFIX-dev-portal-artifacts" \
CognitoDomainNameOrPrefix="CUSTOM_PREFIX" The command will exit when the stack creation is successful. If you'd like to watch it create in real-time, you can log into the cloudformation console. To get the URL for the newly created developer portal instance, find the websiteURL field in the cloudformation console's outputs or run this command: aws cloudformation describe-stacks --query \
"Stacks[?StackName=='dev-portal'][Outputs[?OutputKey=='WebsiteURL']][][].OutputValue" You can override any of the parameters in the template using the Registering UsersUsers can self-register by clicking the 'Register' button in the developer portal. Cognito calls the Promoting a User to an AdminAdmin users can manage what APIs are visible to normal users and whether or not SDK generation is enabled (per api) for normal users. To promote a user to an admin, go to the Cognito console in the account the developer portal is in, select User Pools, then select the correct User Pool for the dev portal. From there, choose Users and groups, click on the users' name, choose Add to group, and select the group named Populate the API catalogBy default the Developer Portal won't list any APIs. You will have to pick and choose which APIs to show. There are 2 types of APIs: Subscribable APIsFor an API to be subscribable, they must be managed by Amazon API Gateway. The Developer Portal can let a user associate their API Key with these APIs (via the Subscribe button) so they can start calling and developing on these APIs. To list a subscribable API:
Non-subscribable APIsThe Developer can also list APIs that are managed outside of Amazon API Gateway (e.g., APIs hosted on-premise). The Developer Portal won't be able to associate an API Key with the API automatically; however, customers can still test the APIs. To list a non-subscribable API:
Testing your APIsWhen logged into the developer portal with an account that has a provisioned api key, you should be able to test your APIs by selecting a resource/method in them and clicking "Try it out!". Note that this requires CORS to be set up on your API to allow the developer portal to call it. Note that the default PetStore has CORS enabled on all resources but Before going to productionSetup a custom domain for your Developer PortalYou should request and verify an ACM managed certificate for your custom domain name. Then, redeploy the CFN stack with the domain name and ACM cert ARN as parameter overrides. Additionally, you can control if Route 53 nameservers are created using the
sam deploy --template-file ./cloudformation/packaged.yaml \
--stack-name "dev-portal" \
--s3-bucket YOUR_LAMBDA_ARTIFACTS_BUCKET_NAME \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides \
DevPortalSiteS3BucketName="CUSTOM_PREFIX-dev-portal-static-assets" \
ArtifactsS3BucketName="CUSTOM_PREFIX-dev-portal-artifacts" \
CustomDomainName="my.acm.managed.domain.name.com" \
CustomDomainNameAcmCertArn="arn:aws:acm:us-east-1:111111111111:certificate/12345678-1234-1234-1234-1234567890ab" \
UseRoute53Nameservers="false" This creates a cloudfront distribution in front of the S3 bucket serving the site, optionally sets up a Route53 hosted zone with records aliased to that distribution, and require HTTPS to communicate with the cloudfront distribution. If you chose If you chose Add custom content and brand the Developer PortalSee this page on customization Updating to a new versionThe Developer Portal follows the semantic versioning scheme (major.minor.patch). Changes to the minor or patch version are backwards compatible so you should feel safe to get the latest version. For changes to major versions, please see this page on updating. To update a SAM deployment:
To update a SAR deployment
ComponentsFor an overview of the components of the developer portal, please see this page. DebuggingYou can trace and troubleshoot the Lambda functions using CloudWatch Logs. See this blog post for more information. Tear-downDeleting the developer portal should be as easy as deleting the cloudformation stack. This will empty the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论