Pull to refresh

How to create sound cloud platform — notes

Level of difficultyEasy
Reading time3 min
Views448
  1. Prerequisite: registered domain name

    1. Create Route 53 A record

    2. Configure ACM certificate in N. Virginia region .example.com

  2. Create s3 bucket with website feature to host static files

  3. Create Cloudfront distribution and attach ACM cert to it

  4. Create Cognito User Pool

  5. Attach own domain to Cognito User Pool

  6. Inside Cognito User Pool create web app client and Configure redirect URL

  7. Create Lambda Function for signup will fetch user image from google/fb

It may seem obvious but lambda has to have permission to s3/dynamodb

Create API Gateway REST API with Lambda as handler

don’t forget to enable CORS, attach custom domain

  1. Create API Gateway Authorizer

Create Usage plan

Create Stage

To enable logging you must create IAM role

After processing of the track is finished successfully we send message to dedicated fifo queue.

Outdated tracks(now — created_at < [reasonable time delta] AND status == ‘preparing’) deleted.

  1. Create ES domain. Attach policy to access Kibana(in our case from ext acc lambda and from local ip):

Using AWS to create Sound sharing platform

Prerequisite: registered domain name

Create Route 53 A record

Attachment
Attachment

Configure ACM certificate in N. Virginia region .example.com

Create s3 bucket with website feature to host static files

Create s3 bucket for avatars/artworks

Attachment
Attachment

Create Cloudfront distribution and attach ACM cert to it

Create Cognito User Pool

Attach own domain to Cognito User Pool

Screenshot 2021-01-22 at 12.53.03
Screenshot 2021-01-22 at 12.53.03

Inside Cognito User Pool create web app client and Configure redirect URL

Create Lambda  signup post confirmation trigger Function it will fetch user image from google/fb

It may seem obvious but lambda has to have permission to s3/dynamodb

Create API Gateway REST API with Lambda as handler

don’t forget to enable CORS, attach custom domain

Attachment
Attachment

Create dynamodb users table with sub as partition key

export type User = {  username: string  date_joined: Date  first_name: string  last_name: string  city: string  country: string  description: string  email: string  track_count: number  avatar_url: string  permalink: string}

Create API Gateway Authorizer

Attachment
Attachment

Create Usage plan

Create Stage

To enable logging you must create IAM role

why did I choose DynamoDB: for example facebook users tend to read but not to post. Keep data ready to read = writing could be more complex

API GW — Use id_token, assign api key, usage plan, custom domain path mapping

Attach authorizer to appropriate endpoints

Attachment
Attachment
Attachment
Attachment

Create user pool trigger on Post confirmation event to store user in db !!!

Attachment
Attachment

Build FFmpeg with dumpwave-filter patch applied or use prepared lambda package humeniukd/ffmpeg-lambda.

Create two s3 buckets first for incoming audio and second for storing processed mp3 along with json.

For incoming bucket setup trigger for PUT event to execute wf-lambda function.

Upload policy endpoint for generating presigned s3 url to PUT/POST new uploads

After processing of the track is finished successfully we send message to dedicated fifo queue. Outdated tracks(now — created_at < [reasonable time delta] AND status == ‘preparing’) deleted.

Create ES domain. Attach policy to access Kibana(in our case from ext acc lambda and from local ip):

{  "Version": "2012–10–17",  "Statement": [    {      "Effect": "Allow",      "Principal": {        "AWS": "arn:aws:iam::HIDDEN:role/yes"      },      "Action": "es:",      "Resource": "arn:aws:es:eu-central-1: HIDDEN:domain/ohyo/"    },    {      "Effect": "Allow",      "Principal": {        "AWS": ""      },      "Action": "es:",      "Resource": "arn:aws:es:eu-central-1: HIDDEN:domain/ohyo/*",      "Condition": {        "IpAddress": {          "aws:SourceIp": "AA.BB.CC.DD"        }      }    }  ]}

Create mapping for tags autocomplete suggested

Screenshot 2021-01-22 at 10.52.53
Screenshot 2021-01-22 at 10.52.53

Put tags to new index

Screenshot 2021-01-22 at 10.54.06
Screenshot 2021-01-22 at 10.54.06

Create endpoint to retrieve tags for autocompletion

Screenshot 2021-01-22 at 22.30.45
Screenshot 2021-01-22 at 22.30.45

Create endpoint to save track metadata

Create endpoint to resolve track/user by permalink

To respond with status 404 lambda should throw Error with message text recognised by API Gateway:

Screenshot 2021-01-31 at 15.39.25
Screenshot 2021-01-31 at 15.39.25

-Put item to dynamodb(update user)

Export API as swagger JSON

Screenshot 2021-02-09 at 22.06.20
Screenshot 2021-02-09 at 22.06.20

Generate types on the FE side using yarn generate:types

Screenshot 2021-02-09 at 22.10.05
Screenshot 2021-02-09 at 22.10.05

-Refresh ES index for search

Configure api gateway template mapping for skipping empty fields

Create user stream pagination using user_id as partition key and created_at as sort key

If LastEvaluatedKey is present use it for next url query params

Set up dynamodb stream to process newly created comments

To POST artwork img configure api to accept encodings such as

Screenshot 2021-02-25 at 15.15.17
Screenshot 2021-02-25 at 15.15.17
  1. Go to the API Gateway settings tab for your API and add multipart/form-data, image/jpeg to the binary media typessection.

  2. Add Content-Type and Accept to the request headers for your proxy method

  3. Add Access-Control-Allow-Methods to Method Response headers

  4. Re-deploy the API

Tags:
Hubs:
Total votes 2: ↑1 and ↓1+2
Comments1

Articles