Web Content Lambda

We will now create a lambda function that generates the http content and dashboard embed url for our sample page.
This lambda function simulates both dynamic and static page flows.
In dynamic mode, it generates the dashboard embed url and includes it in the initial HTML content that is sent back to the browser.
In static mode, it initially returns HTML content with javascript function that makes an API Gateway call to get dashboard embed url.
This lambda is invoked in the follow up API Gateway call for static flow (getUrl mode) and then returns the dashboard embed url.

  1. Launch Lambda and click Create function button.
    Make the following selections.
    Choose Author from scratch
    Function Name: QSAnonymousEmbedSample
    Runtime: Python 3.8
    Execution role: Use an existing role
    Select QSAnonymousEmbedRole from drop down. Click Create function
HCL
  1. Download the following package to your machine.
    Download Lambda Package

  2. From Code source section, click Upload from dropdown button and click .zip file.
    Click Upload button, select the zip file downloaded in last step and click Open followed by Save.

HCL
  1. Click Configuration > Environment variables > Edit. Add the following environment variables (Refer notepad for values).
    DashboardIdList
    DashboardNameList
    DashboardRegion
    Click Save button.
HCL
  1. Click General configuration > Edit.
    Increase Timeout value to 30 secs and click Save button.
HCL

Lambda Code - For easy reference

Python code
Dynamic HTML template
Static HTML template