Category Archives: Cloud

A Step by Step Guide to Deploy CloudFoundry on AWS

1. Configure Below on AWS

  • VPC ( Virtual Private Cloud )
  • IAM USER
  • Elastic IP
  • Key Pair
  • Security Group
  • Route 53

a. VPC –  Configuring VPC

Select Launch VPC Wizard

sys

Click on Select to continue

Enter IPv4 details and click on create VPC

VPC Created Successfully

b. IAM USER

Go to IAM under Services

Click on AddUser

Enter Username and Select on Next:Permissions

Select Administrator Access  under policies and click on Review

Click on Create User

User Create Successfully and download the CSV file

c. Elastic IP

Select Elastic IP’s from EC2 Dashboard

Select Allocate new address

Select Allocate Address

IP Created successfully

d.Key Pair

Select Key Pairs from EC2 Dashboard

Click on Create Key Pair

Enter the name and click on Create

Key Pair  Gets created and .pem file is downloaded automatically

e.Security Group

Select Security Groups from EC2 Dashboard

Select Create Security Group

Enter the details and click Create

Bosh Group is Created as shown below

Select bosh security group, Edit inbound rules and add as shown below

f. Route 53

Select Route53  from Services

Click on Hosted Zones

Click on Create Hosted Zone

Enter the domain details and click on create

nbos.co dns entry is created

Add *.nbos.co address record and save Record

 

2. Create an Instance to Deploy Bosh Director

a. Create  EC2 Instance

Select Launch Instance from EC2 Dashboard

b. Select Amazon Linux

c. Select t2.micro and click Next

d. Select Network and subnet as shown below and proceed to Configure security Group

e. Select bosh security group and click on Review and Launch

f. Click on Launch to Launch the instance

g. Wait till instance is launched and showed running

3. Configure bosh cli and deploy bosh director

a. Login to the EC2 instance

b. Verify the bosh version

c. Install the following packages

d. make directory bosh

e. clone bosh Director Template

Update cloud-config.yml file in bosh-deployment/aws

f. Deploy Bosh Director using create-env

Wait till it completes

g. Connect to the bosh director

4. Deploy Cloud Foundry

a. clone cf-deployment

b. upload stemcell to director

c. update  the cf-deployment.yml under cf-deployment with content below

d. Deploy the cloud foundry

Wait till the deployment completes

e. Update the  Elastic IP to the router instance created by cf-deployment which is mapped to *.nbos.co in DNS

5. Login to cf

a. Set the cf target

b. Retrieve the admin password from  cf-deployment/deployment-vars.yml generated while deploying cf-deployment

c. Verify cf API

 

Overview: Intercom lets you send custom attributes about your customers. This means that you can filter your user list and send messages when users meet criteria specific to your business.

You send custom attributes by adding it to your intercomSettings code snippet as additional key/value pairs. Make sure to double check that your custom attribute keys always have a JSON-valid value; this means double quotes around strings and sending null as a value when there isn’t a value for that user. It’s also important to note that:

1. Field names must not contain Periods (‘.’) or Dollar (‘$’) characters
2. Field values must be JSON Strings, Numbers or Booleans – Objects and Arrays will be rejected.
3. Keys cannot contain characters such as ~`!@#%^&*'{}|\'” or the NULL character.
4. Keys are case-sensitive.
5. Values cannot be nested hashes or arrays.
6. We only allow custom data attributes of string type to have up to 255 characters.

Here are some custom attribute examples:

Here are some screen shots for seeing the custom attributes in intercom.

Overview:
This is a chat app you can use to catch your website visitors and convert them into customers. Engage your visitors on your website or those who use your app, and text them via chat or email. It helps to you will communicate with visitors about your website. You can clarify any questions on your website, you can immediately reply to visitors. It will boost your business growth.

Feature your brand and make a personal connection.
Personal: Show the names and faces of your team so people know there’s a real person on the other end.
Modern: Typing indicators, read receipts, stickers, GIFs, and emojis make for a friendly and fun experience.
Customizable: Match Intercom to your company’s brand to make it feel like your own.

Start live conversations with website visitors, and retain signed-up users.

Install Intercom on your website:
1. create your account or login (https://app.intercom.io/admins/sign_in)
2. Install Intercome
3. start your free trial –> If you are not complete this step, intercom live chat is not working.

Here’s how your free trial works:
1. You’ll get a 14 day free trial of each product, which you can start at any time.
2. After your free trial ends, Intercom’s products start at $49/month.
3. If you cancel in the first 14 days you won’t be charged.

“Install Intercome”  –> You can complete this step in setup guide section, then you will get the javascript code, take that code and put into your website pages.

How to use the code:

1. Paste the code right before the closing body tag(</body>) of every page where you want the Intercom Messenger to appear.
2. Make sure to replace ‘APP_ID’ with your app ID.
3. Open your website in your development environment to activate the code install.

In the setup guide you’ll see the code snippet you need to install. Or you can quickly grab it from here instead:

Here’s the JavaScript code:

After adding the above javascript code in your web page(.jsp/.html) then intercome live chat button appears in below right corner side of the page.

What is Docker?

Docker is the world’s leading software container platform which is designed to make it easier to create, deploy, and run applications. The main intention of Docker is to run multiple processes and apps separately from one another to make better use of your infrastructure while retaining the security you would have with separate systems.

How does Docker work?

The docker technology uses the Linux® kernel and features of the kernel, like Cgroups and namespaces, to segregate processes so they can run independently.

Docker provides an image-based deployment model. This makes it easy to share an application, or set of services, with all of their dependencies across multiple environment

Where to use Docker?

  • Developers use Docker to eliminate “works on my machine” such as problems when collaborating on code with co-workers.
  • Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density.

How to use Docker?

To use a docker, we need to define a custom image or pull one from Docker hub. And by using an image create a container.

What is Docker Image?

Docker Image is a list of read-only layers that represent file-system differences. Layers are stacked on top of each other to form a base for a container’s root filesystem. To put in simple word an image is a blue print (or class) of Container.

What is Docker container?

Container is running instance of a Docker image which allow a developer to pack an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

Are you planning to move your existing GB’s or TB’s data to s3?
Below nodejs script might help you to get started and upload your data to S3.

PreRequsite:

Ensure that aws-sdk node module is configured. If not follow AWS documentation https://aws.amazon.com/sdk-for-node-js/

s3 Options:

Usually accessKeyId and secretAccessKey is enough to make it happening. But if you are behind proxy, use those commented s3Options fields accordingly.

Source Directory

For windows directory delimiter needs tobe delimited, eg c:\\mysite\\uploads

For Linux you can use something like ‘/var/www/site/uploads’

 

Use Case:

A PHR(Patient Health Record) application  gets health reports of patient from various hospitals and labs. Patient Health records are in XML format which needs to be processed  and stored into Database.

Lets see how we can use Amazon AWS to implement this use case.

Step1: Create a Amazon Simple Storage Service (S3) bucket where documents to be uploaded.

Step2: Create a AWS Lambda Function  using NodeJs. Configure  Lambda function to get triggered on   XML upload to S3. Check below screen shot.

Step3: 

Create a Mysql Database using AWS Relational Database‎ (RDS).

Step 4: 

Lambda NodeJs code can be dowloaded from Wavelabs Git Repo.

Package the JS file into zip file and upload the NodeJS Lambda function. Make necessary changes in index.js file as per your requirements.

Ouput:

From AWS dashboard, upload  sample xml file( use file  patient.xml from repo) to s3 bucket.

Connect to Mysql using command line or using workbench and see the results.

What is proxy:
———————-
A proxy server is an intermediary between your PC or device and the Internet. This server makes requests to websites, servers and services on the Internet for you. It is actually a server which helps us maintaining our privacy on the Internet. It is just like a wall between you and the Internet.
When you use a proxy, the webpage on the other side won’t be able to see you, webpage interacts with the proxy and proxy in return shows us the webpage.

A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource, available from a different server. The proxy server evaluates the request according to its filtering rules.

A proxy server can be placed in the user’s local computer or at various points between the user and the destination servers on the Internet.

proxy_server1

Advantages:
——————-
Hiding machine or other servers from public. It provides security.
To speed up access to resources (using caching). Web proxies are commonly used to cache web pages from a web server.
To open blocked sites in college schools and some times in offices.
To bypass security/parental controls.
To protect your real identity on internet.

Proxy server settings:
———————————
In twilio client library <7.x old version, we are setting the manually proxy server seetings and add host and port number.
When we are making a twilio api call through proxy server, then we need to configure our proxy host and port number in our customized class.
We are extending the twilio com.twilio.sdk.TwilioRestClient, then set proxy server settings and add host and port number.

In twilio client library (7.1.0) new version, twilio client build every thing for related the proxy server settings,
just we have to add our proxy server host and port number.

When we are making a twilio api call through proxy server, then we need to configure our proxy host and port number in our customized class.
We are extending the twilio NetworkHttpClient, then set our server host and port numbers in customized class constructor.

or

Add the twilio api url into your proxy server configuration file:
——————————————————————————————
And make sure you will add the below url entry in squid filter and restart proxy

Twilio new client version:
————————————–
Twilio new client version 7.x, follow the below code.

Twilio old client version:
———————————–
Twilio old client version <=6.x, then follow the below code.

 

Overview: Get the available twilio phone number from your twilio account configured phone numbers using java, if there is no phone number configured in your twilio account, you can Buy a Number from your twilio account. Your account will be charged when you provision the number, and the number will appear on the Manage Numbers page in your account.

If you want to buy more than one twilio phone numbers, you must upgrade your Twilio account in order to provision additional phone numbers. Once you configured all the twilio phone numbers, then you will get any one number, and that number you will use to send SMS/MMS, make a Voice call.

The following are the types of phone numbers Twilio provides:
— Local numbers
— National numbers
— Toll free numbers
— Mobile numbers

Local numbers: Local numbers are telephone numbers which are assigned to a specific region.
These numbers are typically used by individuals, local businesses and can be considered the most general type of numbers.

use the following maven dependency or set the external jar file for the below version.

Using the below java code snippet for getting the local available twilio phone number.

National numbers: National numbers are telephone numbers which are not region-specific and were designed to be reachable from an entire country at the same cost.

Toll free numbers: Toll free numbers are telephone numbers that are free of charge for the calling party,
and are typically used by businesses when they prefer fully take on the cost of calls for their users. Similar to a geographic area code.

Note: Twilio currently provides toll free numbers in United States, Canada and United Kingdom.
In the United States and Canada, toll-free numbers are enabled for both voice and SMS messaging.
Toll-free numbers in the United Kingdom cannot yet be used to send messages.

Using the below java code snippet for getting the local phone number.

Mobile numbers: Mobile numbers are often the only type of number in the given country that can be used for sending and receiving messages.

Use the following maven dependency or add the external jar file for the below version.

Use the below java code snippet for getting the mobile number from your twilio account. Here using the

<!– [Format Time: 0 le prix du viagra au maroc.0013 seconds] –>

 

Overview:
“ngrok” can be useful for sharing our local application website information to any one. Get some reviews of local application from remote users. Based on that reviews, we will develop a good application. Suppose if your local application running in tomcat server, then run the ngrok, it detects the tomcat server based on port number, then ngrok creates a public url. This public url access to every one.

If you are using a third party api and you want to have webhook from that third party to your application, in that case you need a public url. This public url to get access to some third party apis.

ngrok creates a secure public URL (https://yourapp.ngrok.io) to a local webserver on your machine. It creates a different public url for every restart.

Save time and be more productive. Show off in-progress work for feedback and build webhook integrations with ease. Use ngrok’s unique request inspection and replay to iterate quickly.

Don’t configure port forwarding on your router or waste time setting up dynamic DNS solutions. ngrok works everywhere with no changes, even when a device changes networks.

Steps to install ngrok:
1. Download ngrok
2. On Linux or OSX you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip.
Unzip – unzip /path/to/ngrok.zip

3. Run the ngrok:
ngrok allows you to expose a web server running on your local machine to the internet. Just tell ngrok what port your web server is listening on.

If you don’t know what port your web server is listening on, it’s probably port 80, the default for HTTP.
Example: Expose a web server on port 80 of your local machine to the internet

When you start ngrok, it will display a UI in your terminal with the public URL of your tunnel and other status and metrics information about connections made over your tunnel.
See the below ngrok console UI

4. More about ngrok Features

ngrok’s Benefits:
1. In our local machine running the web server, then start the ngrok, it will give a unique url and that will be valid for until you stop the ngrok. So it saves time as you don’t have to change it on every restart of the web server.

2. It can use the service without any sign-up. Just download and install. Also it is available to everyone. If extra features needed you can buy.

3. It provides url with both http protocols (http and https)

Overview:
Connect buyers and sellers through an intermediate Twilio phone number to keep personal numbers private.

See the below screenshot for the twilio voice calling flow.

TwilioMaskedPhoneNumbers

Step 1. PROVISION TWILIO PHONE NUMBERS
Purchase a pool of phone numbers from the Twilio self-service portal or the Twilio phone number API. You can search for phone numbers with a specific country and area code.

Step 2: MAP TWILIO PHONE NUMBERS TO USERS
Implement the mapping between the provisioned Twilio phone numbers and your users. In this example, xxx-xxxx is associated to Arya and Bran’s personal phone numbers for the duration of their business relationship.

Step 3: ARYA CALLS TWILIO NUMBER XXX-XXXX
When Arya calls xxx-xxxx, Twilio receives the call and makes an HTTP request to your web server. We are configure the call back url in twilio phone number configuration page.

See the below image for the voice call configuration in twilio
TwilioVoceCallConfiguration

See the below code snippet for making a call from caller phone number to Twilio phone number.

Build some constants, see the below code snippet