This README explains how to upload code to an AWS Lambda function, create an AWS Layer, and attach the layer to the lambda. Additionally, it provides steps for creating Cognito users and adding them to already present Cognito groups.
- Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
- Node and NPM installed
- Amplify CLI, only required to generate code as the backend deployment is done via AWS CDK
- AWS CLI installed and configured
- Log in to the AWS Management Console and navigate to the Lambda service console.
- Navigate to Function Code page of
crawlerLambda
andrequestHandlerLambda
. Copy and paste the code of respective lambda functions from thelambda
directory and Deploy the functions
- Navigate to the Lambda service.
- Select
Layers
in the left menu. - Click
Create Layer
. - Enter a name and description for your layer.
- Download this package layer ZIP file
- Click the
Upload
button to upload the ZIP file. - Choose the
python 3.7
runtime for your layer. - Click
Create
.
- Navigate to the Lambda service console and select the
requestHandlerLambda
function. - Scroll down to the
Layers
section. - Click
Add layer
. - Select Custom layers option and Choose the layer along with its version you created earlier
- Click
Add
.
- Navigate to the Cognito service console.
- Select the User Pools option from the left menu.
- Select the appropriate user pool.
- Select the
Users
tab. - Click the
Create user
button. - Enter the required user details, including their username, password and email(optional).
- Click the
Create user
button to complete the process. - Select the user you want to add to the group by clicking on their username.
- Click the
Add to group
button. - Select the appropriate group you want the user to be part of.
- Click the
Add to group
button to complete the process. - Repeat the steps above for any other user that needs to be added.
- Navigate to the LakeFormation service console.
- Select
Data lake permissions
underPermissions
section from the left menu. - Revoke all permissions for
IAMAllowedPrincipals
underPrincipal
column.
- Run following commands to upload the sample dataset Replace the the bucket_name placeholder with the S3 bucket provisioned using CloudFormation Template.
cd dataset aws s3 cp . s3://{bucket_name}/ --recursive
- Optionally, you can upload the dataset on S3 bucket using AWS console. Make sure to keep the same directory structure provided in the
dataset
folder
In order to view the data queried from datalake using AppSync GraphQl API, follow the instruction provided below to setup a react client application locally.
-
Navigate to react-app:
cd react-app
-
Install the project dependencies:
npm install
-
Open the file
.env
and update the configuration details by copying it from appropriate AWS service settings -
Generate the necessary code to interact with the API using the Amplify CodeGen with the
API ID
of AppSync Grpahql Endpoint from the console. Execute the following command accepting all defaults:amplify add codegen --apiId xxxxxxxxxxxxxxxxxxxxxx
-
Verify that graphql folder is created inside src folder, containing following files:
queries.js
-
Execute the application and access at http://localhost:3000:
npm start
-
Now you can login to the react application with appropriate user credentials to query data from datalake with restricted access