├── website-creator ├── web-site-manifest.json ├── package.json ├── index.js ├── website-helper.js ├── css │ └── style.css ├── contactflowapi.html └── js │ └── connectflows.js ├── CODE_OF_CONDUCT.md ├── README.md ├── LICENSE ├── CONTRIBUTING.md └── template.yaml /website-creator/web-site-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "./contactflowapi.html", 4 | "./css/style.css", 5 | "./js/aws-sdk.min-cf.js", 6 | "./js/connectflows.js" 7 | ] 8 | } -------------------------------------------------------------------------------- /website-creator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webSiteCreator", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC" 11 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Amazon Connect contact flow API's demo 3 | 4 | This demo shows how you can leverage [Amazon Connect](https://aws.amazon.com/connect/) api's to manage contact flows. 5 | 6 | ## Usage 7 | Use `sam` to build, invoke and deploy the function. 8 | 9 | ##### SAM Build: 10 | Ensure you are in the root folder 11 | 12 | `sam build --use-container` 13 | 14 | ##### SAM Deploy: 15 | 16 | `sam deploy template.yaml --s3-bucket REPLACE-ME --stack-name sam-cf1 --capabilities CAPABILITY_IAM --parameter-overrides ParameterKey=CFS3BucketForWebSite,ParameterValue=REPLACE-ME ParameterKey=backupDDBTable,ParameterValue=REPLACE-ME ParameterKey=arnMappingDDBTable,ParameterValue=REPLACE-ME` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /website-creator/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const https = require('https'); 3 | const url = require('url'); 4 | const WebsiteHelper = require('./website-helper.js'); 5 | 6 | exports.handler = (event, context, callback) => { 7 | console.log('Received event:', JSON.stringify(event, null, 2)); 8 | 9 | let responseStatus = 'FAILED'; 10 | let responseData = {}; 11 | 12 | if (event.RequestType === 'Delete') { 13 | sendResponse(event, callback, context.logStreamName, 'SUCCESS'); 14 | } 15 | 16 | if (event.RequestType === 'Create') { 17 | if (event.ResourceProperties.customAction === 'configureWebsite') { 18 | console.log('Starting to copy the files'); 19 | let _websiteHelper = new WebsiteHelper(); 20 | 21 | _websiteHelper.copyWebSiteAssets(event.ResourceProperties, 22 | function(err, data) { 23 | if (err) { 24 | responseData = { 25 | Error: 'Copy of website assets failed' 26 | }; 27 | console.log([responseData.Error, ':\n', err].join('')); 28 | } else { 29 | responseStatus = 'SUCCESS'; 30 | responseData = {}; 31 | } 32 | 33 | sendResponse(event, callback, context.logStreamName, responseStatus, responseData); 34 | }); 35 | 36 | } 37 | //sendResponse(event, callback, context.logStreamName, 'SUCCESS'); 38 | } 39 | 40 | 41 | }; 42 | 43 | /** 44 | * Sends a response to the pre-signed S3 URL 45 | */ 46 | 47 | let sendResponse = function(event, callback, logStreamName, responseStatus, responseData) { 48 | const responseBody = JSON.stringify({ 49 | Status: responseStatus, 50 | Reason: `See the details in CloudWatch Log Stream: ${logStreamName}`, 51 | PhysicalResourceId: logStreamName, 52 | StackId: event.StackId, 53 | RequestId: event.RequestId, 54 | LogicalResourceId: event.LogicalResourceId, 55 | Data: responseData, 56 | }); 57 | 58 | console.log('RESPONSE BODY:\n', responseBody); 59 | const parsedUrl = url.parse(event.ResponseURL); 60 | const options = { 61 | hostname: parsedUrl.hostname, 62 | port: 443, 63 | path: parsedUrl.path, 64 | method: 'PUT', 65 | headers: { 66 | 'Content-Type': '', 67 | 'Content-Length': responseBody.length, 68 | } 69 | }; 70 | 71 | const req = https.request(options, (res) => { 72 | console.log('STATUS:', res.statusCode); 73 | console.log('HEADERS:', JSON.stringify(res.headers)); 74 | callback(null, 'Successfully sent stack response!'); 75 | }); 76 | 77 | req.on('error', (err) => { 78 | console.log('sendResponse Error:\n', err); 79 | callback(err); 80 | }); 81 | 82 | req.write(responseBody); 83 | req.end(); 84 | }; -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /website-creator/website-helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let AWS = require('aws-sdk'); 4 | let s3 = new AWS.S3(); 5 | const fs = require('fs'); 6 | const _downloadLocation = './web-site-manifest.json'; 7 | 8 | /** 9 | * Helper function to interact with s3 hosted website for cfn custom resource. 10 | * 11 | * @class websiteHelper 12 | */ 13 | let websiteHelper = (function() { 14 | 15 | /** 16 | * @class websiteHelper 17 | * @constructor 18 | */ 19 | let websiteHelper = function() {}; 20 | 21 | websiteHelper.prototype.copyWebSiteAssets = function(resourceProperties, cb) { 22 | var destS3Bucket = resourceProperties.destS3Bucket; 23 | var destS3KeyPrefix = resourceProperties.destS3KeyPrefix; 24 | var region = resourceProperties.Region; 25 | 26 | console.log("Copying UI web site"); 27 | console.log(['destination bucket:', destS3Bucket].join(' ')); 28 | console.log(['destination s3 key prefix:', destS3KeyPrefix].join(' ')); 29 | console.log(['region:', region].join(' ')); 30 | 31 | fs.readFile(_downloadLocation, 'utf8', function(err, data) { 32 | if (err) { 33 | console.log(err); 34 | return cb(err, null); 35 | } 36 | 37 | console.log(data); 38 | let _manifest = validateJSON(data); 39 | 40 | if (!_manifest) { 41 | return cb('Unable to validate downloaded manifest file JSON', null); 42 | } else { 43 | uploadToS3(_manifest.files, 0, destS3Bucket, destS3KeyPrefix, 44 | function(err, result) { 45 | if (err) { 46 | return cb(err, null); 47 | } 48 | console.log(result); 49 | return cb(null, result); 50 | }); 51 | } 52 | 53 | }); 54 | }; 55 | 56 | 57 | /** 58 | * Helper function to validate the JSON structure of contents of an import manifest file. 59 | * @param {string} body - JSON object stringify-ed. 60 | * @returns {JSON} - The JSON parsed string or null if string parsing failed 61 | */ 62 | let validateJSON = function(body) { 63 | try { 64 | let data = JSON.parse(body); 65 | console.log(data); 66 | return data; 67 | } catch (e) { 68 | // failed to parse 69 | console.log('Manifest file contains invalid JSON.'); 70 | return null; 71 | } 72 | }; 73 | 74 | async function uploadToS3(filelist, index, destS3Bucket, destS3KeyPrefix, cb) { 75 | if (filelist.length > index) { 76 | 77 | const response = fs.readFileSync(filelist[index], 'utf8'); 78 | var fileDetails = filelist[index] 79 | fileDetails = fileDetails.substring(2, fileDetails.length); 80 | 81 | let params2 = { 82 | Bucket: destS3Bucket, 83 | Key: destS3KeyPrefix + '/' + fileDetails, 84 | Body: response 85 | }; 86 | if (filelist[index].endsWith('.htm') || filelist[index].endsWith('.html')) { 87 | params2.ContentType = "text/html"; 88 | } else if (filelist[index].endsWith('.css')) { 89 | params2.ContentType = "text/css"; 90 | } else if (filelist[index].endsWith('.js')) { 91 | params2.ContentType = "application/javascript"; 92 | } else if (filelist[index].endsWith('.png')) { 93 | params2.ContentType = "image/png"; 94 | } else if (filelist[index].endsWith('.jpg') || filelist[index].endsWith('.jpeg')) { 95 | params2.ContentType = "image/jpeg"; 96 | } else if (filelist[index].endsWith('.pdf')) { 97 | params2.ContentType = "application/pdf"; 98 | } else if (filelist[index].endsWith('.gif')) { 99 | params2.ContentType = "image/gif"; 100 | } else if (filelist[index].endsWith('.svg')) { 101 | params2.ContentType = "image/svg+xml"; 102 | }; 103 | 104 | s3.putObject(params2, function(err, data) { 105 | if (err) { 106 | console.log(err); 107 | return cb(['error copying ', [filelist[index]].join('/'), '\n', err] 108 | .join( 109 | ''), 110 | null); 111 | } 112 | 113 | console.log([ 114 | [filelist[index]].join('/'), 'uploaded successfully' 115 | ].join(' ')); 116 | let _next = index + 1; 117 | uploadToS3(filelist, _next, destS3Bucket, destS3KeyPrefix, function(err, resp) { 118 | if (err) { 119 | return cb(err, null); 120 | } 121 | 122 | cb(null, resp); 123 | }); 124 | }); 125 | } else { 126 | cb(null, [index, 'files copied'].join(' ')); 127 | } 128 | } 129 | return websiteHelper; 130 | 131 | })(); 132 | 133 | module.exports = websiteHelper; -------------------------------------------------------------------------------- /website-creator/css/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | border: 0; 4 | margin: 0; 5 | padding: 0; 6 | } 7 | 8 | body { 9 | font: 100% "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 10 | min-width: 100%; 11 | min-height: 101%; 12 | color: #666; 13 | background: #eee; 14 | } 15 | 16 | p, 17 | label, 18 | legend { 19 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 20 | } 21 | 22 | h1 { 23 | margin: 10px 0 10px; 24 | font-size: 20px; 25 | color: #333333; 26 | } 27 | 28 | hr { 29 | color: inherit; 30 | height: 0; 31 | margin: 6px 0 6px 0; 32 | padding: 0; 33 | border: 1px solid #d9d9d9; 34 | border-style: none none solid; 35 | } 36 | 37 | section { 38 | display: block; 39 | width: 800px; 40 | margin: 10px auto; 41 | padding: 35px; 42 | border: 1px solid #cbcbcb; 43 | background-color: #FFF; 44 | -webkit-border-radius: 5px; 45 | -moz-border-radius: 5px; 46 | border-radius: 5px; 47 | box-shadow: 0 2px 5px rgba(50, 50, 50, 0.1); 48 | -webkit-box-shadow: 0 2px 5px rgba(50, 50, 50, 0.1); 49 | -moz-box-shadow: 0 2px 5px rgba(50, 50, 50, 0.1); 50 | } 51 | 52 | 53 | /* Special CSS for Call Controls Section */ 54 | 55 | fieldset.salesOrder { 56 | padding: 7px; 57 | } 58 | 59 | fieldset.callControls { 60 | padding: 3px; 61 | margin: 4px; 62 | -webkit-transition: margin-left 1s ease-in-out; 63 | z-index: 1; 64 | } 65 | 66 | .callControls { 67 | margin: 2px 2px; 68 | display: inline-block; 69 | border: 1px solid #bfbfbf; 70 | border-radius: 5px 5px 5px 5px; 71 | -webkit-border-radius: 5px 5px 5px 5px; 72 | -moz-border-radius: 5px 5px 5px 5px; 73 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 74 | width: auto; 75 | height: auto; 76 | font-size: 16px; 77 | box-shadow: inset 0 1px 0 0 #fff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2, 0 2px 4px 0 #f2f2f2; 78 | -moz-box-shadow: inset 0 1px 0 0 #fff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2, 0 2px 4px 0 #f2f2f2; 79 | -webkit-box-shadow: inset 0 1px 0 0 #fff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2, 0 2px 4px 0 #f2f2f2; 80 | text-shadow: 0 1px 0 #fff; 81 | background-image: linear-gradient(to top, #f2f2f2, #f2f2f2); 82 | background-color: #f2f2f2; 83 | } 84 | 85 | .callControls:hover, 86 | .callControls:active { 87 | border: 1px solid #8c8c8c; 88 | color: #8c8c8c; 89 | box-shadow: inset 0 1px 0 0 #ffffff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2; 90 | -moz-box-shadow: inset 0 1px 0 0 #ffffff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2; 91 | -webkit-box-shadow: inset 0 1px 0 0 #ffffff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2; 92 | background-color: #f2f2f2; 93 | } 94 | 95 | 96 | /* Form style */ 97 | 98 | mark.validate { 99 | display: inline-block; 100 | margin: 12px 0 0 10px; 101 | width: 16px; 102 | height: 16px; 103 | background: transparent none; 104 | } 105 | 106 | mark.valid { 107 | background: url(images/success.gif) no-repeat top left; 108 | } 109 | 110 | mark.error { 111 | background: url(images/error.gif) no-repeat top left; 112 | } 113 | 114 | form label, 115 | section label { 116 | display: inline-block; 117 | float: left; 118 | height: 1em; 119 | line-height: 1em; 120 | padding: 6px 0 0; 121 | width: 135px; 122 | font-size: 1em; 123 | margin: 5px 0; 124 | clear: both; 125 | } 126 | 127 | form label small, 128 | section label small { 129 | font-size: 0.75em; 130 | color: #ccc; 131 | } 132 | 133 | form label.verify { 134 | padding: 0; 135 | margin: 2px 10px 2px 0; 136 | width: 145px; 137 | text-align: right; 138 | } 139 | 140 | form label.verify img { 141 | padding: 1px; 142 | border: 1px solid #cccccc; 143 | -webkit-border-radius: 3px; 144 | -moz-border-radius: 3px; 145 | border-radius: 3px; 146 | } 147 | 148 | form button { 149 | width: 120px; 150 | padding: 4px; 151 | color: #666; 152 | background: #f5f5f5; 153 | border: 1px solid #ccc; 154 | margin: 5px 0; 155 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 156 | -webkit-border-radius: 5px; 157 | -moz-border-radius: 5px; 158 | border-radius: 5px; 159 | vertical-align: top; 160 | transition: all 0.25s ease-in-out; 161 | -webkit-transition: all 0.25s ease-in-out; 162 | -moz-transition: all 0.25s ease-in-out; 163 | box-shadow: 0 0 5px rgba(81, 203, 238, 0); 164 | -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 165 | -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 166 | } 167 | 168 | form input, 169 | form textarea, 170 | form select, 171 | section select, 172 | section input, 173 | section textarea { 174 | width: 220px; 175 | padding: 5px; 176 | color: #666; 177 | background: #f5f5f5; 178 | border: 1px solid #ccc; 179 | margin: 5px 0; 180 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 181 | -webkit-border-radius: 5px; 182 | -moz-border-radius: 5px; 183 | border-radius: 5px; 184 | vertical-align: top; 185 | transition: all 0.25s ease-in-out; 186 | -webkit-transition: all 0.25s ease-in-out; 187 | -moz-transition: all 0.25s ease-in-out; 188 | box-shadow: 0 0 5px rgba(81, 203, 238, 0); 189 | -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 190 | -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 191 | } 192 | 193 | form select { 194 | width: 232px; 195 | margin: 8px 0; 196 | } 197 | 198 | form input#verify { 199 | width: 55px; 200 | } 201 | 202 | form textarea, 203 | section textarea { 204 | width: 414px; 205 | } 206 | 207 | form input:focus, 208 | form textarea:focus, 209 | form select:focus, 210 | form button:focus, 211 | section input:focus, 212 | section textarea:focus, 213 | section select:focus { 214 | border: 1px solid #ddd; 215 | background-color: #fff; 216 | color: #333; 217 | outline: none; 218 | position: relative; 219 | z-index: 5; 220 | box-shadow: 0 0 5px rgba(81, 203, 238, 1); 221 | -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 1); 222 | -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 1); 223 | -webkit-transform: scale(1.05); 224 | -moz-transform: scale(1.05); 225 | transition: all 0.25s ease-in-out; 226 | -webkit-transition: all 0.25s ease-in-out; 227 | -moz-transition: all 0.25s ease-in-out; 228 | } 229 | 230 | form input.error, 231 | form textarea.error, 232 | form select.error { 233 | box-shadow: 0 0 5px rgba(204, 0, 0, 0.5); 234 | -webkit-box-shadow: 0 0 5px rgba(204, 0, 0, 0.5); 235 | -moz-box-shadow: 0 0 5px rgba(204, 0, 0, 0.5); 236 | border: 1px solid #faabab; 237 | background: #fef3f3 238 | } 239 | 240 | form input.submit { 241 | width: auto; 242 | cursor: pointer; 243 | position: relative; 244 | border: 1px solid #282828; 245 | color: #fff; 246 | padding: 6px 16px; 247 | text-decoration: none; 248 | font-size: 1.1em; 249 | background: #555; 250 | background: -webkit-gradient( linear, left bottom, left top, color-stop(0.12, rgb(60, 60, 60)), color-stop(1, rgb(85, 85, 85))); 251 | background: -moz-linear-gradient( center bottom, rgb(60, 60, 60) 12%, rgb(85, 85, 85) 100%); 252 | box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25); 253 | -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 254 | -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 255 | text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25); 256 | } 257 | 258 | form input.submit:hover { 259 | background: #282828 !important; 260 | transition: none; 261 | -webkit-transition: none; 262 | -moz-transition: none; 263 | } 264 | 265 | form input.submit:active, 266 | form input.submit:focus { 267 | top: 1px; 268 | } 269 | 270 | form button.delete-comment { 271 | width: auto; 272 | cursor: pointer; 273 | position: relative; 274 | border: 1px solid #282828; 275 | color: #fff; 276 | border-radius: 5px; 277 | padding: 6px 16px; 278 | text-decoration: none; 279 | font-size: 1.1em; 280 | background: #555; 281 | background: -webkit-gradient( linear, left bottom, left top, color-stop(0.12, rgb(60, 60, 60)), color-stop(1, rgb(85, 85, 85))); 282 | background: -moz-linear-gradient( center bottom, rgb(60, 60, 60) 12%, rgb(85, 85, 85) 100%); 283 | box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25); 284 | -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 285 | -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 286 | text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25); 287 | } 288 | 289 | .copy { 290 | width: 30px; 291 | height: 29px; 292 | padding: 5px; 293 | color: #666; 294 | background: #f5f5f5; 295 | border: 1px solid #ccc; 296 | margin: 5px 0; 297 | } 298 | 299 | form button.delete-comment:hover { 300 | background: #282828 !important; 301 | transition: none; 302 | -webkit-transition: none; 303 | -moz-transition: none; 304 | } 305 | 306 | form button.delete-comment:active, 307 | form button.delet-comment:focus { 308 | top: 1px; 309 | } 310 | 311 | form button:hover { 312 | background: #eeeeee; 313 | transition: none; 314 | -webkit-transition: none; 315 | -moz-transition: none; 316 | } 317 | 318 | form input[type="submit"][disabled] { 319 | background: #888; 320 | } 321 | 322 | form fieldset { 323 | padding: 7px; 324 | border: 1px solid #eee; 325 | -webkit-border-radius: 5px; 326 | -moz-border-radius: 5px; 327 | margin: 0 0 20px; 328 | } 329 | 330 | form legend { 331 | padding: 7px 10px; 332 | font-weight: bold; 333 | color: #000; 334 | border: 1px solid #eee; 335 | -webkit-border-radius: 5px; 336 | -moz-border-radius: 5px; 337 | margin-bottom: 0 !important; 338 | margin-bottom: 20px; 339 | } 340 | 341 | form span.required { 342 | font-size: 13px; 343 | color: #ff0000; 344 | } 345 | 346 | section span.required { 347 | font-size: 13px; 348 | color: #ff0000; 349 | } 350 | 351 | fieldset { 352 | padding: 20px; 353 | border: 1px solid #eee; 354 | -webkit-border-radius: 5px; 355 | -moz-border-radius: 5px; 356 | margin: 0 0 20px; 357 | } 358 | 359 | legend { 360 | padding: 7px 10px; 361 | font-weight: bold; 362 | color: #000; 363 | border: 1px solid #eee; 364 | -webkit-border-radius: 5px; 365 | -moz-border-radius: 5px; 366 | margin-bottom: 0 !important; 367 | margin-bottom: 20px; 368 | } 369 | 370 | #message { 371 | margin: 1em 0; 372 | padding: 0; 373 | display: block; 374 | background: transparent none; 375 | } 376 | 377 | acronym { 378 | border-bottom: 1px dotted #ccc; 379 | } -------------------------------------------------------------------------------- /template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: > 3 | Amazon Connect contact flow APIs demo 4 | 5 | Mappings: 6 | FunctionMap: 7 | Configuration: 8 | S3Bucket: "amazon-connect-blogs2" 9 | S3Key: "2020/contactflows/" 10 | 11 | Parameters: 12 | CFS3BucketForWebSite: 13 | Type: String 14 | Default: "contactflowapi-website" 15 | AllowedPattern: '(?=^.{3,63}$)(?!^(\d+\.)+\d+$)(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)' 16 | ConstraintDescription: 'Invalid S3 Bucket name' 17 | Description: Enter the (globally unique) name you would like to use for the Amazon S3 bucket where we will store the website assets and the sample contact flow. This template will fail to deploy if the bucket name you chose is currently in use. 18 | 19 | backupDDBTable: 20 | Type: String 21 | Default: "contactflows" 22 | Description: > 23 | The name of the DynamoDB Table contact flows will be backed up (Ensure you do not have a table with this name already). 24 | 25 | arnMappingDDBTable: 26 | Type: String 27 | Default: "contactflowmapping" 28 | Description: > 29 | The name of the DynamoDB Table which maintains ARN mappings to target environment (Ensure you do not have a table with this name already). 30 | 31 | Metadata: 32 | 'AWS::CloudFormation::Interface': 33 | ParameterGroups: 34 | - Label: 35 | default: Amazon S3 Configuration 36 | Parameters: 37 | - CFS3BucketForWebSite 38 | - Label: 39 | default: Amazon DynamoDB Configuration 40 | Parameters: 41 | - backupDDBTable 42 | - arnMappingDDBTable 43 | 44 | ParameterLabels: 45 | CFS3BucketForWebSite: 46 | default: Website Bucket Name 47 | backupDDBTable: 48 | default: Backup table 49 | arnMappingDDBTable: 50 | default: ARN Mappings 51 | 52 | Outputs: 53 | CloudfrontEndpoint: 54 | Description: Endpoint for Cloudfront distribution 55 | Value: !Join 56 | - '' 57 | - - 'https://' 58 | - !GetAtt [CFCloudFrontDistribution, DomainName] 59 | - '/contactflowapi.html' 60 | 61 | DDBForBackup: 62 | Description: Endpoint for Cloudfront distribution 63 | Value: !Ref backupDDBTable 64 | 65 | DDBForARNMapping: 66 | Description: Endpoint for Cloudfront distribution 67 | Value: !Ref arnMappingDDBTable 68 | 69 | Resources: 70 | CFABackupDDBTable: 71 | Type: AWS::DynamoDB::Table 72 | Properties: 73 | TableName: !Ref backupDDBTable 74 | AttributeDefinitions: 75 | - 76 | AttributeName: "flowId" 77 | AttributeType: "S" 78 | KeySchema: 79 | - 80 | AttributeName: "flowId" 81 | KeyType: "HASH" 82 | ProvisionedThroughput: 83 | ReadCapacityUnits: 84 | 1 85 | WriteCapacityUnits: 86 | 1 87 | 88 | CFAARNMappingDDBTable: 89 | Type: AWS::DynamoDB::Table 90 | Properties: 91 | TableName: !Ref arnMappingDDBTable 92 | AttributeDefinitions: 93 | - 94 | AttributeName: "sourceARN" 95 | AttributeType: "S" 96 | KeySchema: 97 | - 98 | AttributeName: "sourceARN" 99 | KeyType: "HASH" 100 | ProvisionedThroughput: 101 | ReadCapacityUnits: 102 | 1 103 | WriteCapacityUnits: 104 | 1 105 | 106 | createWebSiteS3Bucket: 107 | Type: 'AWS::S3::Bucket' 108 | Properties: 109 | VersioningConfiguration: 110 | Status: Enabled 111 | BucketName: !Ref CFS3BucketForWebSite 112 | VersioningConfiguration: 113 | Status : Enabled 114 | BucketEncryption: 115 | ServerSideEncryptionConfiguration: 116 | - ServerSideEncryptionByDefault: 117 | SSEAlgorithm: AES256 118 | PublicAccessBlockConfiguration: 119 | BlockPublicAcls: True 120 | BlockPublicPolicy: True 121 | IgnorePublicAcls: True 122 | RestrictPublicBuckets: True 123 | WebsiteConfiguration: 124 | IndexDocument: contactflowapi.html 125 | ErrorDocument: error.html 126 | 127 | 128 | CFS3BucketPolicy: 129 | Type: AWS::S3::BucketPolicy 130 | DependsOn: 131 | - CFCloudFrontDistributionAccessIdentity 132 | Properties: 133 | Bucket: !Ref createWebSiteS3Bucket 134 | PolicyDocument: 135 | Statement: 136 | - 137 | Action: 138 | - "s3:GetObject" 139 | Effect: "Allow" 140 | Principal: 141 | CanonicalUser: 142 | Fn::GetAtt: [ CFCloudFrontDistributionAccessIdentity , S3CanonicalUserId ] 143 | Resource: 144 | !Sub ${createWebSiteS3Bucket.Arn}/contactflowsite/* 145 | 146 | CFCloudFrontDistributionAccessIdentity: 147 | Type: AWS::CloudFront::CloudFrontOriginAccessIdentity 148 | Properties: 149 | CloudFrontOriginAccessIdentityConfig: 150 | Comment: 'CloudFront endpoint for contact flows s3' 151 | 152 | CFCloudFrontDistribution: 153 | Type: AWS::CloudFront::Distribution 154 | Properties: 155 | DistributionConfig: 156 | Origins: 157 | - DomainName: 158 | !Join 159 | - '' 160 | - - !Ref CFS3BucketForWebSite 161 | - .s3.amazonaws.com 162 | Id: !Ref CFS3BucketForWebSite 163 | OriginPath: '/contactflowsite' 164 | S3OriginConfig: 165 | OriginAccessIdentity: 166 | !Join 167 | - '' 168 | - - 'origin-access-identity/cloudfront/' 169 | - !Ref CFCloudFrontDistributionAccessIdentity 170 | Enabled: 'true' 171 | Logging: 172 | Bucket: !GetAtt createWebSiteS3Bucket.DomainName 173 | Prefix: 'logs/' 174 | IncludeCookies: 'true' 175 | Comment: CloudFront for contact flow apis 176 | DefaultRootObject: contactflowapi.html 177 | DefaultCacheBehavior: 178 | AllowedMethods: 179 | - DELETE 180 | - GET 181 | - HEAD 182 | - OPTIONS 183 | - PATCH 184 | - POST 185 | - PUT 186 | TargetOriginId: !Ref CFS3BucketForWebSite 187 | ForwardedValues: 188 | QueryString: true 189 | Cookies: 190 | Forward: all 191 | ViewerProtocolPolicy: redirect-to-https 192 | Restrictions: 193 | GeoRestriction: 194 | RestrictionType: whitelist 195 | Locations: 196 | - US 197 | 198 | CFWebsiteCreatorRole: 199 | Type: "AWS::IAM::Role" 200 | Properties: 201 | AssumeRolePolicyDocument: 202 | Version: "2012-10-17" 203 | Statement: 204 | - 205 | Effect: "Allow" 206 | Principal: 207 | Service: 208 | - "lambda.amazonaws.com" 209 | Action: 210 | - "sts:AssumeRole" 211 | Path: "/" 212 | Policies: 213 | - 214 | PolicyName: !Sub ${AWS::StackName}-contact-flow-creator-policy 215 | PolicyDocument: 216 | Version: "2012-10-17" 217 | Statement: 218 | - 219 | Effect: "Allow" 220 | Action: 221 | - 'logs:CreateLogGroup' 222 | - 'logs:CreateLogStream' 223 | - 'logs:PutLogEvents' 224 | Resource: 225 | - !Sub "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*" 226 | - 227 | Effect: "Allow" 228 | Action: 229 | - "s3:PutObject" 230 | - "s3:GetObject" 231 | - "s3:PutObjectAcl" 232 | Resource: 233 | - !Join 234 | - '' 235 | - - 'arn:' 236 | - !Ref 'AWS::Partition' 237 | - ':s3:::' 238 | - !Ref CFS3BucketForWebSite 239 | - '/*' 240 | - 241 | Effect: "Allow" 242 | Action: 243 | - "s3:PutBucketPublicAccessBlock" 244 | Resource: 245 | - !Join 246 | - '' 247 | - - 'arn:' 248 | - !Ref 'AWS::Partition' 249 | - ':s3:::' 250 | - !Ref CFS3BucketForWebSite 251 | - 252 | Effect: "Allow" 253 | Action: 254 | - "s3:GetObject" 255 | Resource: 256 | - !Join 257 | - '' 258 | - - 'arn:' 259 | - !Ref 'AWS::Partition' 260 | - ':s3:::' 261 | - 'amazon-connect-blogs2' 262 | - '/*' 263 | 264 | webSiteCreator: 265 | Type: "AWS::Lambda::Function" 266 | Properties: 267 | Description: > 268 | AWS Lambda Function that will create the website and upload it to the S3 bucket 269 | Handler: "index.handler" 270 | Role: !GetAtt CFWebsiteCreatorRole.Arn 271 | Runtime: "nodejs12.x" 272 | MemorySize: 256 273 | Timeout: 120 274 | Code: ./website-creator/ 275 | 276 | invokeWebSiteCreator: 277 | Type: Custom::CreateWebSite 278 | DependsOn: createWebSiteS3Bucket 279 | Properties: 280 | ServiceToken: !GetAtt webSiteCreator.Arn 281 | customAction: configureWebsite 282 | Region: !Ref AWS::Region 283 | destS3Bucket: !Ref CFS3BucketForWebSite 284 | destS3KeyPrefix: contactflowsite 285 | -------------------------------------------------------------------------------- /website-creator/contactflowapi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 |Cannot find flow with same name in the target instance, do you want to create new flow?
237 |Waiting for server to respond
240 || Source ARN | 260 |Target ARN | 261 |Type | 262 |
|---|---|---|
| - | - | - | 265 |