Skip to content

chakch/pulumi-handson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pulumi-handson

If you are here, this means that you belive that you can code your infrastructure using your favorite programming language.

alt text

In this hands-on, we are going to read a rssFeed, convert it to MP3 and save the feed in database.

We will use the folowing services:

  • Lambda
  • CloudWatch
  • DynamoDB
  • Polly
  • S3
  • Api-gateway

So let's get started 😊

First Step : Prepare the field

For this hands-on, install node version 8.9 Use node version manager to handle multiple node versions

The installation instructions are available here: https://github.com/creationix/nvm

  • Check your install: nvm --version

  • Install node 8.9.4 using : nvm i 8.9.4

  • Check you node default version: node --version

  • Use this command nvm use 8.9.4 to switch node version

  • Install pip:

https://pip.pypa.io/en/stable/installing/

  • Install AWS Command line interface

pip install awscli --upgrade --user

  • Verify that the AWS CLI installed correctly

aws --version

To Install Pulumi, Copy and paste this command in your terminal : curl -fsSL https://get.pulumi.com | sh

  • Check you pulumi version: pulumi version

Second Step : Prepare the weapon

Checkout the projet and start coding ☁️

  • In th main root of the project you have to run npm i to install the pulumi depencencies
  • you need also to define your Pulumi stack pulumi stack init : you can call your stack by using the previous command
  • you need to set francfort as aws region pulumi config set aws:region eu-central-1

Third Step : Fight

Create the Rss reader function

alt text

The RssReader function read every day the aws rssFeed and save it on dynamoDB

The function code is availaible on the package rs-reader

In lambda service, use the test functionality available on the AWS console to test the created function. You don't need to specify any event or data, just save the test and click on test to trigger your lambda function.

Select DynamoDB service and check if you have the latest AWS's blog articles

Create the audio transcoder function

alt text

  • Create the S3 bucket: https://pulumi.io/reference/pkg/nodejs/@pulumi/aws/s3/#Bucket

  • Create the AudioTranscoderRole Your function should be able to to acces to cloudwatch, dynamoDB,polly and s3

    [{ Action: "sts:AssumeRole", Principal: { Service: "lambda.amazonaws.com" }, Effect: "Allow", Sid: "" }]

    [{ Action: ["polly:", "cloudwatch:", "s3:","dynamodb:", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"], Effect: "Allow", Resource: "*" }]

  • Create your function with the created role

  • Create a connect the dynamoDB stream to the AudioTrancoder function the function will be triggred when new item is added to the table https://pulumi.io/reference/pkg/nodejs/@pulumi/aws/dynamodb/#TableEventSubscription

  • Add the the bucket name to the AudiTranscoder function environement variable

  • launch pulumi up to update your stack

Trigger the RssReader Manually:

alt text

Sometimes,we need to sychronize the articles manually. To do this we make a http call.

Releases

No releases published

Packages

No packages published