-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding S3 example Co-authored-by: Josip Janzic <[email protected]>
- Loading branch information
1 parent
5ecd118
commit f556253
Showing
9 changed files
with
859 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
|
||
# Created by https://www.gitignore.io/api/osx,node,linux,windows | ||
|
||
### Linux ### | ||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
|
||
### OSX ### | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
|
||
# End of https://www.gitignore.io/api/osx,node,linux,windows | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
#AWS/SAM | ||
.aws-sam | ||
packaged.yaml | ||
samconfig.toml | ||
|
||
#jbesw-specific | ||
testData/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Miro Terms Modal Banner App (Web-SDK V2 & AWS S3) | ||
|
||
This app creates a custom modal banner on your Miro boards that you can show to your users/attendees with any desired content and/or call to actions. It is typically used to accept terms and agreements before using a Miro board. | ||
|
||
<b> To understand how to set up the app (including AWS resources needed to run the app) see the | ||
[developer tutorial](https://developers.miro.com/v2.0/docs/terms-modal-banner-aws-s3) on Miro's Developer documentation.</b> | ||
|
||
💸 **Important**: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example. 💸 | ||
|
||
# 👨🏻💻 App Demo | ||
|
||
https://github.com/miroapp/app-examples/assets/10428517/6fafc30b-e246-4677-8f5b-cb5396ccdc54 | ||
|
||
# 📒 Table of Contents | ||
|
||
- [Support](#support) | ||
- [Included Features](#features) | ||
- [Tools and Technologies](#tools) | ||
- [Prerequisites](#prerequisites) | ||
- [Associated Developer Tutorial](#tutorial) | ||
- [Run the app locally](#run) | ||
- [Folder Structure](#folder) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
# 🙋🏻 Support <a name="features"></a> | ||
|
||
If you have any questions or need assistance setting up this application, please reach out to your Miro Customer Success Manager or dedicated Miro Solutions Engineer. | ||
|
||
# ⚙️ Included Features <a name="features"></a> | ||
|
||
- [Miro Web SDK](https://developers.miro.com/docs/web-sdk-reference) | ||
- [miro.board.ui.canOpenModal()](https://developers.miro.com/docs/websdk-reference-ui#canopenmodal) | ||
- [miro.board.ui.openModal()](https://developers.miro.com/docs/websdk-reference-ui#openmodal) | ||
- [miro.board.ui.closeModal()](https://developers.miro.com/docs/websdk-reference-ui#closemodal) | ||
- [miro.board.getUserInfo()](https://developers.miro.com/docs/websdk-reference-board#getuserinfo) | ||
|
||
# 🛠️ Tools and Technologies <a name="tools"></a> | ||
|
||
- [AWS CLI](https://aws.amazon.com/cli/) | ||
- [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) | ||
- [AWS CloudFormation](https://aws.amazon.com/cloudformation/) | ||
- [AWS S3](https://aws.amazon.com/s3/) | ||
- [AWS Lambda](https://aws.amazon.com/lambda/) | ||
- [AWS API Gateway](https://aws.amazon.com/api-gateway/) | ||
|
||
# ✅ Prerequisites <a name="prerequisites"></a> | ||
|
||
- You have a [Miro account](https://miro.com/signup/). | ||
- You're [signed in to Miro](https://miro.com/login/). | ||
- Your Miro account has a [Developer team](https://developers.miro.com/docs/create-a-developer-team). | ||
- [NodeJS 16.x installed](https://nodejs.org/en/download/) | ||
- [AWS CLI](https://aws.amazon.com/cli/) already configured with Administrator permission | ||
- [AWS SAM CLI installed](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) - minimum version 0.48. | ||
|
||
# 📖 Associated Developer Tutorial <a name="tutorial"></a> | ||
|
||
Using AWS S3 you can host your html files and serve them as regular web pages so they can load within Miro. In addition, you can also use AWS S3 to add custom functionality to your Miro app to track which users have already accepted the modal, so that the modal does not re-appear again for those users. In this guide we will guide you on how to achieve this functionality using Miro and AWS S3. | ||
|
||
> See the [developer tutorial](https://developers.miro.com/v2.0/docs/terms-modal-banner-aws-s3) on Miro's Developer documentation. | ||
# 🏃🏽♂️ Run the app using AWS S3 <a name="run"></a> | ||
|
||
Once you have finished all of the steps related to AWS in the [developer tutorial](https://developers.miro.com/v2.0/docs/terms-modal-banner-aws-s3), you can then create the Miro app. | ||
|
||
1. In your new Miro app settings, add in the `App URL`. It should end with `webassets/app.html`. | ||
2. Open the [app manifest editor](https://developers.miro.com/docs/manually-create-an-app#step-2-configure-your-app-in-miro) by clicking **Edit in Manifest**. \ | ||
In the app manifest editor, configure the app as follows <b> ⚠️ Note: you will need to change your sdkUri to be your app.html which is hosted in the `webassets` folder of your S3 bucket. Mine is just shown as an example </b> and then click save: | ||
|
||
```yaml | ||
# See https://developers.miro.com/docs/app-manifest on how to use this | ||
appName: s3-modal-banner | ||
sdkVersion: SDK_V2 | ||
sdkUri: >- | ||
https://s3-miro-terms-banner-12345.s3.amazonaws.com/webassets/app.html | ||
scopes: | ||
- identity:read | ||
``` | ||
3. Go back to your app home page, and under the `Permissions` section, you will see a blue button that says `Install app and get OAuth token`. Click that button. Then click on `Add` as shown in the video below. <b>In the video we install a different app, but the process is the same regardless of the app.</b> | ||
|
||
> ⚠️ We recommend to install your app on a [developer team](https://developers.miro.com/docs/create-a-developer-team) while you are developing or testing apps.⚠️ | ||
|
||
https://github.com/miroapp/app-examples/assets/10428517/43922ea1-d619-4480-af23-029a1a4e67d8 | ||
|
||
4. Go to the team in which you installed the app, and open a board. | ||
5. Once you open the board, the modal should appear within a few seconds. | ||
6. If you click accept, you should see a checkmark and then you should not see the modal again when refreshing the page or opening a new board | ||
on that team. | ||
7. You can also check your AWS S3 bucket and see that a new folder `users` has been added. The userID of the user which clicked on `accept` will | ||
be added to the `users` folder in AWS S3. | ||
|
||
🎉 That's it. Great job! 🎉 | ||
|
||
# 🗂️ Folder structure <a name="folder"></a> | ||
|
||
``` | ||
. | ||
├── getSignedURL <-- Source code for the serverless backend. | ||
│ └── app.js // The code to add userID to S3 bucket once user accepts terms. | ||
├── webassets <-- HTML and JavaScript files for the Miro app. | ||
│ ├── app.html // The code which uses Miro WebSDK to open the modal for the user. | ||
│ └── modal.html // The code which serves as the UI for the terms which the user will accept. | ||
├── template.yaml <-- The yaml code used to generate AWS resources via AWS SAM. | ||
``` | ||
# 🫱🏻🫲🏽 Contributing <a name="contributing"></a> | ||
If you want to contribute to this example, or any other Miro Open Source project, please review [Miro's contributing guide](https://github.com/miroapp/app-examples/blob/main/CONTRIBUTING.md). | ||
# 🪪 License <a name="license"></a> | ||
[MIT License](https://github.com/miroapp/app-examples/blob/main/LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# See https://developers.miro.com/docs/app-manifest on how to use this | ||
# make sure to replace the sdkUri with the correct URL (it will be different for each deployment) | ||
appName: s3-modal-banner | ||
sdkVersion: SDK_V2 | ||
sdkUri: >- | ||
https://s3-miro-terms-banner-12345.s3.amazonaws.com/webassets/app.html | ||
scopes: | ||
- identity:read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
software and associated documentation files (the "Software"), to deal in the Software | ||
without restriction, including without limitation the rights to use, copy, modify, | ||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
const AWS = require("aws-sdk"); | ||
AWS.config.update({ region: process.env.AWS_REGION }); | ||
const s3 = new AWS.S3({ | ||
apiVersion: "2006-03-01", | ||
signatureVersion: "v4", | ||
}); | ||
|
||
// Change this value to adjust the signed URL's expiration | ||
const URL_EXPIRATION_SECONDS = 300; | ||
|
||
// Main Lambda entry point | ||
exports.handler = async (event) => { | ||
return await getUploadURL(event); | ||
}; | ||
|
||
const getUploadURL = async function (event) { | ||
const userID = event.queryStringParameters.id; | ||
const Key = userID; | ||
|
||
// Get signed URL from S3 | ||
const s3Params = { | ||
Bucket: process.env.MiroBannerAccepters + "/users", | ||
Key, | ||
Expires: URL_EXPIRATION_SECONDS, | ||
ContentType: "text/plain", | ||
}; | ||
|
||
console.log("Params: ", s3Params); | ||
const uploadURL = await s3.getSignedUrlPromise("putObject", s3Params); | ||
|
||
return JSON.stringify({ | ||
uploadURL: uploadURL, | ||
Key, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "miro-terms-banner-s3-uploader", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "James Beswick, AWS Serverless", | ||
"license": "MIT-0", | ||
"devDependencies": { | ||
"aws-sdk": "^2.749.0" | ||
} | ||
} |
Oops, something went wrong.