amazon-api-gateway-url-shortener

所属分类:代理服务器
开发工具:Vue
文件大小:0KB
下载次数:0
上传日期:2022-01-04 18:00:46
上 传 者sh-1993
说明:  在AWS上创建无服务器URL缩短器,而不使用AWS Lambda或任何其他计算。,
(Creates a serverless URL shortener on AWS without using AWS Lambda or any other compute.,)

文件列表:
CODE_OF_CONDUCT.md (309, 2021-06-11)
CONTRIBUTING.md (3306, 2021-06-11)
LICENSE (930, 2021-06-11)
api.yaml (16166, 2021-06-11)
assets/ (0, 2021-06-11)
assets/client.png (346275, 2021-06-11)
assets/pat.png (166082, 2021-06-11)
client/ (0, 2021-06-11)
client/.env (71, 2021-06-11)
client/babel.config.js (73, 2021-06-11)
client/package.json (1093, 2021-06-11)
client/postcss.config.js (59, 2021-06-11)
client/public/ (0, 2021-06-11)
client/public/favicon.ico (1150, 2021-06-11)
client/public/index.html (1570, 2021-06-11)
client/src/ (0, 2021-06-11)
client/src/App.vue (6566, 2021-06-11)
client/src/assets/ (0, 2021-06-11)
client/src/assets/main.scss (113, 2021-06-11)
client/src/main.js (1416, 2021-06-11)
client/src/postcss.config.js (1065, 2021-06-11)
client/src/router/ (0, 2021-06-11)
client/src/router/index.js (1337, 2021-06-11)
client/src/store/ (0, 2021-06-11)
client/src/store/index.js (1683, 2021-06-11)
client/src/views/ (0, 2021-06-11)
client/src/views/Dashboard.vue (8117, 2021-06-11)
template.yaml (16391, 2021-06-11)
templates/ (0, 2021-06-11)
templates/app/ (0, 2021-06-11)
templates/app/get-request.json (301, 2021-06-11)
templates/app/get-response.json (234, 2021-06-11)
templates/app/linkId/ (0, 2021-06-11)
templates/app/linkId/delete-400-response.json (118, 2021-06-11)
templates/app/linkId/delete-request.json (336, 2021-06-11)
templates/app/linkId/put-request.json (579, 2021-06-11)
templates/app/linkId/put-response-200.json (212, 2021-06-11)
... ...

# Functionless URL Shortener This app creates a URL shortener without using any compute. All business logic is handled at the Amazon API Gateway level. The basic app will create an API Gateway instance utilizing Cognito for authentication and authorization. It will also create an Amazon DynamoDB table for data storage. It will also create a simple Vuejs application as a demo client. Read the blog series about this application: 1. [Building a serverless URL shortener app without AWS Lambda – part 1](https://aws.amazon.com/blogs/compute/building-a-serverless-url-shortener-app-without-lambda-part-1) 1. [Building a serverless URL shortener app without AWS Lambda – part 2](https://aws.amazon.com/blogs/compute/building-a-serverless-url-shortener-app-without-lambda-part-2) 1. [Building a serverless URL shortener app without AWS Lambda – part 3](https://aws.amazon.com/blogs/compute/building-a-serverless-url-shortener-app-without-lambda-part-3) ## The Backend ### Services Used * Amazon API Gateway * Amazon Cognito * Amazon DynamoDB * AWS Amplify Console * Amazon CloudFront *Will cause a lengthy deployment time. See note under **Deploying** * Amazon S3 ### Requirements for deployment * AWS CLI * AWS SAM CLI v0.37.0+ * Forked copy of this repository. Instructions for forking a GitHib repository can be found here * A GitHub personal access token with the *repo* scope as shown below. Instructions for creating a personal access token can be found here ![Personal access token scopes](./assets/pat.png) **Be sure and store you new token in a place that you can find it.** ### Deploying ***Note: This stack includes an Amazon CloudFront distribution which can take around 30 minutes to create. Don't be alarmed if the deploy seems to hang for a long time.*** In the terminal, use the SAM CLI guided deployment the first time you deploy ```bash sam deploy -g ``` #### Choose options You can choose the default for all options except *GithubRepository* and ** ```bash ## The name of the CloudFormation stack Stack Name [URLShortener]: ## The region you want to deploy in AWS Region [us-west-2]: ## The name of the application (lowercase no spaces). This must be globally unique Parameter AppName [shortener]: ## Enables public client and local client for testing. (Less secure) Parameter UseLocalClient [false]: ## GitHub forked repository URL Parameter GithubRepository []: ## Github Personal access token Parameter PersonalAccessToken: ## Shows you resources changes to be deployed and requires a 'Y' to initiate deploy Confirm changes before deploy [y/N]: ## SAM needs permission to be able to create roles to connect to the resources in your template Allow SAM CLI IAM role creation [Y/n]: ## Save your choice for later deployments Save arguments to samconfig.toml [Y/n]: ``` SAM will then deploy the AWS CloudFormation stack to your AWS account and provide required outputs for the included client. After the first deploy you may re-deploy using `sam deploy` or redeploy with different options using `sam deploy -g`. ## The Client *The client can also be run locally for debugging. Instructions can be found [here](./client/README.md).* The client is a Vue.js application that interfaces with the backend and allows you to authenticate and manage URL links. The client is hosted using Amplify Console. To avoid circular dependencies, we need to provide some information for the client after stack is built. The information needed is provided at the end of the deploy process. If you do not have the information you can run the following: ```bash aws cloudformation describe-stacks --stack-name URLShortener ``` We need to add this information to the environment variables for the Amplify Console app. There are two options for adding the variables. #### Option 1: using the AWS CLI (Update the *\* to reflect the information returned from the deployment.) ```bash aws amplify update-app --app-id --environment-variables \ VUE_APP_NAME=\ ,VUE_APP_CLIENT_ID=\ ,VUE_APP_API_ROOT=\ ,VUE_APP_AUTH_DOMAIN= ``` *Also available in the stack output as **AmplifyEnvironmentUpdateCommand*** #### Option 2: Amplify Console page 1. Open the [Amplify Console page](https://us-west-2.console.aws.amazon.com/amplify/home) 1. On the left side, under **All apps**, choose *Url-Shortner-Client* 1. Under **App settings** choose *Environment variables* 1. Choose the *manage variables* button 1. Choose *add variable* 1. Fill in the *variable* and it's corresponding *Value* 1. Leave defaults for *Branches* and *Actions* 1. Repeat for all four variables 1. Choose save ### Starting the first deployment After deploying the CloudFormation template, you need to go into the Amplify Console and trigger a build. The CloudFormation template can provision the resources, but can’t trigger a build since it creates resources but cannot trigger actions. This can be done via the AWS CLI. #### Option 1: Using the AWS CLI (Update the *\* to reflect the information returned from the deployment.) ```bash aws amplify start-job --app-id --branch-name master --job-type RELEASE ``` *Also available in the stack output as **AmplifyDeployCommand*** To check on the status, you can view it on the AWS Amplify Console or run: ```bash aws amplify get-job --app-id --branch-name master --job-id ``` #### Option 2: Amplify Console page 1. Open the Amplify Console page 1. On the left side, under **All apps**, choose *Url-Shortner-Client* 1. Click *Run build* *Note: this is only required for the first build subsequent client builds will be triggered when updates are committed to your forked repository. ## Cleanup 1. Open the CloudFormation console 1. Locate a stack named *URLShortener* 1. Select the radio option next to it 1. Select **Delete** 1. Select **Delete stack** to confirm *Note: If you opted to have access logs (on by default), you may have to delete the S3 bucket manually.

近期下载者

相关文件


收藏者