From a615383e6c20d5142969680989f6968e5723abce Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Fri, 15 Jun 2018 16:07:23 -0700 Subject: [PATCH] Readmes (#84) --- aws-js-s3-folder-component/README.md | 21 ++-- aws-js-s3-folder/README.md | 22 ++--- aws-ts-airflow/README.md | 45 +++++++++ .../.gitignore | 0 .../Pulumi.yaml | 0 .../README.md | 15 +-- .../index.js | 6 +- .../package.json | 0 .../README.md | 22 ++--- cloud-js-thumbnailer/README.md | 26 ++--- cloud-ts-url-shortener-cache/README.md | 25 ++--- cloud-ts-url-shortener/README.md | 97 ++++++++++--------- cloud-ts-url-shortener/index.ts | 2 +- 13 files changed, 169 insertions(+), 112 deletions(-) rename {cloud-js-httpendpoint => cloud-js-api}/.gitignore (100%) rename {cloud-js-httpendpoint => cloud-js-api}/Pulumi.yaml (100%) rename {cloud-js-httpendpoint => cloud-js-api}/README.md (89%) rename {cloud-js-httpendpoint => cloud-js-api}/index.js (78%) rename {cloud-js-httpendpoint => cloud-js-api}/package.json (100%) diff --git a/aws-js-s3-folder-component/README.md b/aws-js-s3-folder-component/README.md index 5af4ffae0..1fb74e22d 100644 --- a/aws-js-s3-folder-component/README.md +++ b/aws-js-s3-folder-component/README.md @@ -4,6 +4,9 @@ The component version of [aws-js-s3-folder](../aws-js-s3-folder). For a detailed ## Deploying and running the program +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ```bash @@ -16,9 +19,10 @@ The component version of [aws-js-s3-folder](../aws-js-s3-folder). For a detailed $ pulumi config set aws:region us-west-2 ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. -1. Run `pulumi update` to preview and deploy changes. +1. Run `pulumi update` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. ```bash $ pulumi update @@ -38,14 +42,11 @@ The component version of [aws-js-s3-folder](../aws-js-s3-folder). For a detailed + └─ aws:s3:BucketObject index.html created ---outputs:--- - bucketName: "pulumi-static-site-517ff4e" - websiteUrl: undefined - info: 6 changes performed: + 6 resources created - Update duration: 8.997389052s + Update duration: *** - Permalink: https://pulumi.com/lindydonna/website-component-testing/updates/1 + Permalink: https://app.pulumi.com/*** ``` 1. To see the resources that were created, run `pulumi stack output`: @@ -54,8 +55,8 @@ The component version of [aws-js-s3-folder](../aws-js-s3-folder). For a detailed $ pulumi stack output Current stack outputs (2): OUTPUT VALUE - bucketName s3-website-bucket-e7c0411 - websiteUrl s3-website-bucket-e7c0411.s3-website-us-west-2.amazonaws.com + bucketName s3-website-bucket-*** + websiteUrl ***.s3-website-us-west-2.amazonaws.com ``` 1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI: @@ -70,7 +71,7 @@ The component version of [aws-js-s3-folder](../aws-js-s3-folder). For a detailed ```bash $ pulumi stack output websiteUrl - s3-website-bucket-8533d8b.s3-website-us-west-2.amazonaws.com + ***.s3-website-us-west-2.amazonaws.com ``` 1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt. diff --git a/aws-js-s3-folder/README.md b/aws-js-s3-folder/README.md index 9fa331bb8..00a0ac91b 100644 --- a/aws-js-s3-folder/README.md +++ b/aws-js-s3-folder/README.md @@ -5,6 +5,9 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on ## Deploying and running the program +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ```bash @@ -17,9 +20,10 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on $ pulumi config set aws:region us-west-2 ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. -1. Run `pulumi update` to preview and deploy changes. +1. Run `pulumi update` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. ```bash $ pulumi update @@ -37,15 +41,11 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on + ├─ aws:s3:BucketObject favicon.png created + └─ aws:s3:BucketObject index.html created - ---outputs:--- - bucketName: "s3-website-bucket-5afcc1d" - websiteUrl: "s3-website-bucket-5afcc1d.s3-website-us-west-2.amazonaws.com" - info: 5 changes performed: + 5 resources created - Update duration: 8.69080606s + Update duration: *** - Permalink: https://pulumi.com/lindydonna/website-testing/updates/4 + Permalink: https://app.pulumi.com/*** ``` 1. To see the resources that were created, run `pulumi stack output`: @@ -54,8 +54,8 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on $ pulumi stack output Current stack outputs (2): OUTPUT VALUE - bucketName s3-website-bucket-e7c0411 - websiteUrl s3-website-bucket-e7c0411.s3-website-us-west-2.amazonaws.com + bucketName s3-website-bucket-*** + websiteUrl ***.s3-website-us-west-2.amazonaws.com ``` 1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI: @@ -70,7 +70,7 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on ```bash $ pulumi stack output websiteUrl - s3-website-bucket-8533d8b.s3-website-us-west-2.amazonaws.com + ***.s3-website-us-west-2.amazonaws.com ``` ![Hello S3 example](images/part2-website.png) diff --git a/aws-ts-airflow/README.md b/aws-ts-airflow/README.md index 51a65a3ad..5914dbbff 100644 --- a/aws-ts-airflow/README.md +++ b/aws-ts-airflow/README.md @@ -1 +1,46 @@ +# AWS RDS and Airflow example + A Pulumi program to deploy an RDS Postgres instance and containerized Airflow. + +## Deploying and running the program + +For more information on how to run this example, see: https://pulumi.io/reference and https://pulumi.io/quickstart/ + +1. Create a new stack: + + ```bash + $ pulumi stack init airflow + ``` + +1. Set the AWS region: + + ``` + $ pulumi config set aws:region us-east-1 + ``` + +1. Enable ECS auto clustering: + + ``` + $ pulumi config set cloud-aws:ecsAutoCluster true + ``` + +1. Set the desired RDS password with: + + ``` + $ pulumi config set airflow:dbPassword DESIREDPASSWORD + ``` + +1. Restore NPM modules via `yarn install`. +1. Build the TypeScript code via `yarn run build`. +1. Run `pulumi update` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. + +``` +Previewing update of stack 'airflow' +Previewing changes: + + Type Name Plan Info + + pulumi:pulumi:Stack airflow create +... +``` + diff --git a/cloud-js-httpendpoint/.gitignore b/cloud-js-api/.gitignore similarity index 100% rename from cloud-js-httpendpoint/.gitignore rename to cloud-js-api/.gitignore diff --git a/cloud-js-httpendpoint/Pulumi.yaml b/cloud-js-api/Pulumi.yaml similarity index 100% rename from cloud-js-httpendpoint/Pulumi.yaml rename to cloud-js-api/Pulumi.yaml diff --git a/cloud-js-httpendpoint/README.md b/cloud-js-api/README.md similarity index 89% rename from cloud-js-httpendpoint/README.md rename to cloud-js-api/README.md index 29199e26e..e79da2cad 100644 --- a/cloud-js-httpendpoint/README.md +++ b/cloud-js-api/README.md @@ -6,6 +6,9 @@ A simple REST API that counts the number of times a route has been hit. For a de ## Deploying and running the program +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ```bash @@ -18,7 +21,7 @@ A simple REST API that counts the number of times a route has been hit. For a de $ pulumi config set aws:region us-west-2 ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. 1. Run `pulumi update` to preview and deploy changes: @@ -47,21 +50,21 @@ A simple REST API that counts the number of times a route has been hit. For a de + └─ aws:apigateway:Stage hello-world created ---outputs:--- - endpoint: "https://k6z25g5lw6.execute-api.us-west-2.amazonaws.com/stage/" + endpoint: "https://***.us-west-2.amazonaws.com/stage/" info: 14 changes performed: + 14 resources created - Update duration: 48.510747688s + Update duration: *** ``` 1. View the endpoint URL and curl a few routes: ```bash - $ pulumi stack output + $ pulumi stack output Current stack outputs (1): OUTPUT VALUE - endpoint https://5e8xrktey3.execute-api.us-west-2.amazonaws.com/stage/ - + endpoint https://***.us-west-2.amazonaws.com/stage/ + $ curl $(pulumi stack output endpoint)/hello {"route":"hello","count":1} $ curl $(pulumi stack output endpoint)/hello diff --git a/cloud-js-httpendpoint/index.js b/cloud-js-api/index.js similarity index 78% rename from cloud-js-httpendpoint/index.js rename to cloud-js-api/index.js index f6341150e..a5ac9e839 100644 --- a/cloud-js-httpendpoint/index.js +++ b/cloud-js-api/index.js @@ -4,7 +4,7 @@ const cloud = require("@pulumi/cloud-aws"); let counterTable = new cloud.Table("counterTable", "route"); // Create an API endpoint -let endpoint = new cloud.HttpEndpoint("hello-world"); +let endpoint = new cloud.API("hello-world"); endpoint.get("/{route+}", (req, res) => { let route = req.params["route"]; @@ -12,11 +12,11 @@ endpoint.get("/{route+}", (req, res) => { // get previous value and increment // reference outer `counterTable` object - counterTable.get({ route }).then(value => { + counterTable.get({ route }).then(value => { let count = (value && value.count) || 0; counterTable.insert({ route, count: ++count }).then(() => { res.status(200).json({ route, count }); - console.log(`Got count ${count} for '${route}'`); + console.log(`Got count ${count} for '${route}'`); }); }); }); diff --git a/cloud-js-httpendpoint/package.json b/cloud-js-api/package.json similarity index 100% rename from cloud-js-httpendpoint/package.json rename to cloud-js-api/package.json diff --git a/cloud-js-thumbnailer-machine-learning/README.md b/cloud-js-thumbnailer-machine-learning/README.md index 30df98417..f89e0e34d 100755 --- a/cloud-js-thumbnailer-machine-learning/README.md +++ b/cloud-js-thumbnailer-machine-learning/README.md @@ -10,6 +10,9 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat ## Running the App +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ``` @@ -29,13 +32,13 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat $ pulumi config set cloud-aws:computeIAMRolePolicyARNs arn:aws:iam::aws:policy/AWSLambdaFullAccess,arn:aws:iam::aws:policy/AmazonEC2ContainerServiceFullAccess,arn:aws:iam::aws:policy/AmazonRekognitionFullAccess ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. -1. Preview and deploy the app via `pulumi update`. The preview will take some time, as it builds a Docker container. A total of 44 resources are created. +1. Preview and deploy the app via `pulumi update`. The preview will take some time, as it builds a Docker container. A total of 48 resources are created. ``` $ pulumi update - Previewing update of stack 'donna-thumbnailer-rekognition' + Previewing update of stack 'thumbnailer-rekognition' ... Performing changes: @@ -88,21 +91,18 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat + └─ aws:sns:TopicSubscription AmazonRekognitionTopic_labelResults created ... - ---outputs:--- - bucketName: "bucket-d6c6339" - info: 44 changes performed: + 44 resources created - Update duration: 2m27.112988339s + Update duration: *** - Permalink: https://pulumi.com/pulumi/donna-thumbnailer-rekognition/updates/1 + Permalink: https://app.pulumi.com/*** ``` 1. Upload a video: ``` $ aws s3 cp ./sample/cat.mp4 s3://$(pulumi stack output bucketName) - upload: sample/cat.mp4 to s3://bucket-c647dfb/cat.mp4 + upload: sample/cat.mp4 to s3://***/cat.mp4 ``` 1. View the logs from both the Lambda function and the ECS task: @@ -113,7 +113,7 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat 2018-05-21T19:57:35.968-07:00[ onNewVideo] *** New video: file cat.mp4 was uploaded at 2018-05-22T02:57:35.431Z. 2018-05-21T19:57:36.376-07:00[ onNewVideo] *** Submitted Rekognition job for cat.mp4 2018-05-21T19:57:45.848-07:00[AmazonRekognitionTopic_labelRe] *** Rekognition job complete - 2018-05-21T19:57:50.690-07:00[AmazonRekognitionTopic_labelRe] Raw label results: + 2018-05-21T19:57:50.690-07:00[AmazonRekognitionTopic_labelRe] Raw label results: ... 2018-05-21T19:57:50.746-07:00[AmazonRekognitionTopic_labelRe] *** Found object Cat at position 1568. Confidence = 50.56669616699219 2018-05-21T19:57:50.746-07:00[AmazonRekognitionTopic_labelRe] *** Rekognition processing complete for bucket-d6c6339/cat.mp4 at timestamp 1.568 @@ -130,7 +130,7 @@ To use this example, make sure [Docker](https://docs.docker.com/engine/installat ``` $ aws s3 cp s3://$(pulumi stack output bucketName)/cat.jpg . - download: s3://bucket-0e25c2d/cat.jpg to ./cat.jpg + download: s3://***/cat.jpg to ./cat.jpg ``` ## Clean up diff --git a/cloud-js-thumbnailer/README.md b/cloud-js-thumbnailer/README.md index 6635889b8..60786d4ec 100755 --- a/cloud-js-thumbnailer/README.md +++ b/cloud-js-thumbnailer/README.md @@ -12,6 +12,9 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat ## Running the App +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ``` @@ -23,9 +26,9 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat ``` $ pulumi config set aws:region us-west-2 $ pulumi config set cloud-aws:useFargate true - ``` + ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. 1. Preview and deploy the app via `pulumi update`. The preview will take some time, as it builds a Docker container. A total of 32 resources are created. @@ -79,14 +82,11 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat + └─ aws:ec2:SecurityGroup pulumi-thumbnaile-global created ... - ---outputs:--- - bucketName: "bucket-c647dfb" - info: 32 changes performed: + 32 resources created - Update duration: 1m32.73050186s + Update duration: *** - Permalink: https://pulumi.com/lindydonna/thumbnailer-testing/updates/1 + Permalink: https://app.pulumi.com/*** ``` 1. View the stack outputs: @@ -95,29 +95,29 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat $ pulumi stack output Current stack outputs (1): OUTPUT VALUE - bucketName bucket-6120251 + bucketName *** ``` 1. Upload a video, embedding the timestamp in the filename: ``` $ aws s3 cp ./sample/cat.mp4 s3://$(pulumi stack output bucketName)/cat_00-01.mp4 - upload: sample/cat.mp4 to s3://bucket-c647dfb/cat_00-01.mp4 + upload: sample/cat.mp4 to s3://***/cat_00-01.mp4 ``` 1. View the logs from both the Lambda function and the ECS task: ``` $ pulumi logs -f - Collecting logs for stack thumbnailer-testing since 2018-05-25T11:56:53.000-07:00. + Collecting logs for stack thumbnailer-testing since *** 2018-05-25T12:57:26.326-07:00[ onNewVideo] *** New video: file cat_00-01.mp4 was uploaded at 2018-05-25T19:57:25.507Z. 2018-05-25T12:57:30.705-07:00[ onNewVideo] Running thumbnailer task. 2018-05-25T12:58:34.960-07:00[ ffmpegThumbTask] Starting ffmpeg task... 2018-05-25T12:58:34.960-07:00[ ffmpegThumbTask] Copying video from S3 bucket-5ea6b28/cat_00-01.mp4 to cat_00-01.mp4... - 2018-05-25T12:58:37.267-07:00[ ffmpegThumbTask] Completed 256.0 KiB/666.5 KiB (2.5 MiB/s) with 1 fildownload: s3://bucket-5ea6b28/cat_00-01.mp4 to ./cat_00-01.mp4 + 2018-05-25T12:58:37.267-07:00[ ffmpegThumbTask] Completed 256.0 KiB/666.5 KiB (2.5 MiB/s) with 1 fildownload: s3://bucket-5ea6b28/cat_00-01.mp4 to ./cat_00-01.mp4 2018-05-25T12:58:40.306-07:00[ ffmpegThumbTask] Copying cat.jpg to S3 at bucket-5ea6b28/cat.jpg ... - 2018-05-25T12:58:43.034-07:00[ ffmpegThumbTask] Completed 86.6 KiB/86.6 KiB (619.7 KiB/s) with 1 filupload: ./cat.jpg to s3://bucket-5ea6b28/cat.jpg + 2018-05-25T12:58:43.034-07:00[ ffmpegThumbTask] Completed 86.6 KiB/86.6 KiB (619.7 KiB/s) with 1 filupload: ./cat.jpg to s3://bucket-5ea6b28/cat.jpg 2018-05-25T12:58:43.758-07:00[ onNewThumbnail] *** New thumbnail: file cat.jpg was saved at 2018-05-25T19:58:43.028Z. ``` @@ -125,7 +125,7 @@ To run this example, make sure [Docker](https://docs.docker.com/engine/installat ``` $ aws s3 cp s3://$(pulumi stack output bucketName)/cat.jpg . - download: s3://bucket-0e25c2d/cat.jpg to ./cat.jpg + download: s3://***/cat.jpg to ./cat.jpg ``` ## Clean up diff --git a/cloud-ts-url-shortener-cache/README.md b/cloud-ts-url-shortener-cache/README.md index 5313d9eb3..b99af989c 100644 --- a/cloud-ts-url-shortener-cache/README.md +++ b/cloud-ts-url-shortener-cache/README.md @@ -1,9 +1,12 @@ # Serverless URL Shortener with Redis Cache -A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.HttpEndpoint` components. The example shows to combine serverless functions along with containers. +A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.API` components. The example shows to combine serverless functions along with containers. ## Deploying and running the program +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ``` @@ -21,7 +24,7 @@ A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.Htt ``` $ pulumi config set aws:region us-west-2 $ pulumi config set cloud-aws:useFargate true - ``` + ``` 1. Set a value for the Redis password. The value can be an encrypted secret, specified with the `--secret` flag. If this flag is not provided, the value will be saved as plaintext in `Pulumi.url-cache-testing.yaml` (since `url-cache-testing` is the current stack name). @@ -29,9 +32,9 @@ A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.Htt $ pulumi config set --secret redisPassword S3cr37Password ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. -1. Compile the program via `tsc` or `npm run build`. +1. Compile the program via `tsc` or `npm run build` or `yarn run build`. 1. Preview and run the deployment via `pulumi update`. The operation will take about 5 minutes to complete. @@ -43,21 +46,21 @@ A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.Htt Updating stack 'url-cache-testing' Performing changes: - #: Resource Type Name + #: Resource Type Name 1: pulumi:pulumi:Stack url-shortener-cache-url- ... - 63: aws:apigateway:Stage urlshortener - - info: 63 changes performed: - + 63 resources created - Update duration: 5m48.727390626s + 49: aws:apigateway:Stage urlshortener + + info: 49 changes performed: + + 49 resources created + Update duration: *** ``` 1. To view the API endpoint, use the `stack output` command: ``` $ pulumi stack output endpointUrl - https://gs8t66u634.execute-api.us-east-1.amazonaws.com/stage/ + https://***.us-east-1.amazonaws.com/stage/ ``` 1. Open this page in a browser and you'll see a single page app for creating and viewing short URLs. diff --git a/cloud-ts-url-shortener/README.md b/cloud-ts-url-shortener/README.md index bcc1b996b..bd501a7c3 100644 --- a/cloud-ts-url-shortener/README.md +++ b/cloud-ts-url-shortener/README.md @@ -1,9 +1,13 @@ # Serverless URL Shortener -A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.HttpEndpoint` components. The example shows to combine both deployment time and runtime code in one program. +A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.API` components. The +example shows to combine both deployment time and runtime code in one program. ## Deploying and running the program +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + 1. Create a new stack: ``` @@ -16,11 +20,12 @@ A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.Htt $ pulumi config set aws:region us-west-2 ``` -1. Restore NPM modules via `npm install`. +1. Restore NPM modules via `npm install` or `yarn install`. -1. Compile the program via `tsc` or `npm run build`. +1. Compile the program via `tsc` or `npm run build` or `yarn run build`. -1. Preview and run the deployment via `pulumi update`. The operation will take about 2 minutes to complete and will create 34 resources: +1. Preview and run the deployment via `pulumi update`. The operation will take about 2 minutes to + complete and will create 34 resources: ``` $ pulumi update @@ -32,56 +37,56 @@ A sample URL shortener SPA that uses the high-level `cloud.Table` and `cloud.Htt Performing changes: Type Name Status Info - + pulumi:pulumi:Stack url-shortener-url-shortener-dev created - + ├─ cloud:table:Table urls created - + │ └─ aws:dynamodb:Table urls created - + └─ cloud:http:HttpEndpoint urlshortener created - + ├─ aws:s3:Bucket urlshortener created - + ├─ aws:iam:Role urlshortener4c238266 created - + ├─ cloud:function:Function urlshortener0f7d8d8d created - + │ └─ aws:serverless:Function urlshortener0f7d8d8d created - + │ ├─ aws:iam:Role urlshortener0f7d8d8d created - + │ ├─ aws:iam:RolePolicyAttachment urlshortener0f7d8d8d-32be53a2 created - + │ ├─ aws:iam:RolePolicyAttachment urlshortener0f7d8d8d-fd1a00e5 created - + │ └─ aws:lambda:Function urlshortener0f7d8d8d created - + ├─ cloud:function:Function urlshortenerd9505e4a created - + │ └─ aws:serverless:Function urlshortenerd9505e4a created - + │ ├─ aws:iam:Role urlshortenerd9505e4a created - + │ ├─ aws:iam:RolePolicyAttachment urlshortenerd9505e4a-32be53a2 created - + │ ├─ aws:iam:RolePolicyAttachment urlshortenerd9505e4a-fd1a00e5 created - + │ └─ aws:lambda:Function urlshortenerd9505e4a created - + ├─ cloud:function:Function urlshortenereeb67ce9 created - + │ └─ aws:serverless:Function urlshortenereeb67ce9 created - + │ ├─ aws:iam:Role urlshortenereeb67ce9 created - + │ ├─ aws:iam:RolePolicyAttachment urlshortenereeb67ce9-32be53a2 created - + │ ├─ aws:iam:RolePolicyAttachment urlshortenereeb67ce9-fd1a00e5 created - + │ └─ aws:lambda:Function urlshortenereeb67ce9 created - + ├─ aws:s3:BucketObject urlshortener4c238266/bootstrap.min.css created - + ├─ aws:s3:BucketObject urlshortener4c238266/favicon.png created - + ├─ aws:s3:BucketObject urlshortener4c238266/index.html created - + ├─ aws:iam:RolePolicyAttachment urlshortener4c238266 created - + ├─ aws:apigateway:RestApi urlshortener created - + ├─ aws:apigateway:Deployment urlshortener created - + ├─ aws:lambda:Permission urlshortener-0f7d8d8d created - + ├─ aws:lambda:Permission urlshortener-eeb67ce9 created - + ├─ aws:lambda:Permission urlshortener-d9505e4a created - + └─ aws:apigateway:Stage urlshortener created - + + pulumi:pulumi:Stack url-shortener-url-shortener-dev created + + ├─ cloud:table:Table urls created + + │ └─ aws:dynamodb:Table urls created + + └─ cloud:http:HttpEndpoint urlshortener created + + ├─ aws:s3:Bucket urlshortener created + + ├─ aws:iam:Role urlshortener4c238266 created + + ├─ cloud:function:Function urlshortener0f7d8d8d created + + │ └─ aws:serverless:Function urlshortener0f7d8d8d created + + │ ├─ aws:iam:Role urlshortener0f7d8d8d created + + │ ├─ aws:iam:RolePolicyAttachment urlshortener0f7d8d8d-32be53a2 created + + │ ├─ aws:iam:RolePolicyAttachment urlshortener0f7d8d8d-fd1a00e5 created + + │ └─ aws:lambda:Function urlshortener0f7d8d8d created + + ├─ cloud:function:Function urlshortenerd9505e4a created + + │ └─ aws:serverless:Function urlshortenerd9505e4a created + + │ ├─ aws:iam:Role urlshortenerd9505e4a created + + │ ├─ aws:iam:RolePolicyAttachment urlshortenerd9505e4a-32be53a2 created + + │ ├─ aws:iam:RolePolicyAttachment urlshortenerd9505e4a-fd1a00e5 created + + │ └─ aws:lambda:Function urlshortenerd9505e4a created + + ├─ cloud:function:Function urlshortenereeb67ce9 created + + │ └─ aws:serverless:Function urlshortenereeb67ce9 created + + │ ├─ aws:iam:Role urlshortenereeb67ce9 created + + │ ├─ aws:iam:RolePolicyAttachment urlshortenereeb67ce9-32be53a2 created + + │ ├─ aws:iam:RolePolicyAttachment urlshortenereeb67ce9-fd1a00e5 created + + │ └─ aws:lambda:Function urlshortenereeb67ce9 created + + ├─ aws:s3:BucketObject urlshortener4c238266/bootstrap.min.css created + + ├─ aws:s3:BucketObject urlshortener4c238266/favicon.png created + + ├─ aws:s3:BucketObject urlshortener4c238266/index.html created + + ├─ aws:iam:RolePolicyAttachment urlshortener4c238266 created + + ├─ aws:apigateway:RestApi urlshortener created + + ├─ aws:apigateway:Deployment urlshortener created + + ├─ aws:lambda:Permission urlshortener-0f7d8d8d created + + ├─ aws:lambda:Permission urlshortener-eeb67ce9 created + + ├─ aws:lambda:Permission urlshortener-d9505e4a created + + └─ aws:apigateway:Stage urlshortener created + ---outputs:--- - endpointUrl: "https://hxgmq2ujml.execute-api.us-west-2.amazonaws.com/stage/" + endpointUrl: "https://***.us-west-2.amazonaws.com/stage/" info: 34 changes performed: + 34 resources created - Update duration: 1m47.983408851s + Update duration: *** - Permalink: https://pulumi.com/lindydonna/url-shortener-dev/updates/1 + Permalink: https://app.pulumi.com/*** ``` 1. To view the url for the API endpoint, run `pulumi stack output`: ``` $ pulumi stack output endpointUrl - https://gs8t66u634.execute-api.us-east-1.amazonaws.com/stage/ + https://***.us-east-1.amazonaws.com/stage/ ``` 1. Open the URL in a browser and you'll see a single page app for creating and viewing short URLs. @@ -110,13 +115,13 @@ This example combines deployment time and runtime code in the same application. ```typescript // Create a web server. -let endpoint = new cloud.HttpEndpoint("urlshortener"); +let endpoint = new cloud.API("urlshortener"); // Create a table `urls`, with `name` as primary key. let urlTable = new cloud.Table("urls", "name"); ``` -During `pulumi update`, the declaration `new cloud.HttpEndpoint` provisions an AWS API Gateway resource and `new cloud.Table` provisions a Dynamo DB instance. To learn more about how this works, see [How Pulumi Works](https://pulumi.io/reference/how.html) in the documentation. +During `pulumi update`, the declaration `new cloud.API` provisions an AWS API Gateway resource and `new cloud.Table` provisions a Dynamo DB instance. To learn more about how this works, see [How Pulumi Works](https://pulumi.io/reference/how.html) in the documentation. The `endpoint.get` and `endpoint.post` method calls cause Pulumi to register API routes on the API Gateway, pointing to an AWS Lambda function for each implementation: @@ -125,7 +130,7 @@ endpoint.get("/url", async (req, res) => { // this function is the body of the L try { let items = await urlTable.scan(); // reference outer urlTable definition res.status(200).json(items); - console.log(`GET /url retrieved ${items.length} items`); + console.log(`GET /url retrieved ${items.length} items`); } catch (err) { res.status(500).json(err.stack); console.log(`GET /url error: ${err.stack}`); diff --git a/cloud-ts-url-shortener/index.ts b/cloud-ts-url-shortener/index.ts index b722d931e..04a5b82ad 100644 --- a/cloud-ts-url-shortener/index.ts +++ b/cloud-ts-url-shortener/index.ts @@ -4,7 +4,7 @@ import * as cloud from "@pulumi/cloud-aws"; import { Output } from "@pulumi/pulumi"; // for output property // Create a web server. -let endpoint = new cloud.HttpEndpoint("urlshortener"); +let endpoint = new cloud.API("urlshortener"); // Create a table `urls`, with `name` as primary key. let urlTable = new cloud.Table("urls", "name");