July 12, 2017

How do you protect the data stored in Amazon S3?


Well, its not just the data stored in Amazon S3 needs to be safe but during the onward & return journey as well.

That broadly classifies  the data protection into categories  as protecting data while in-transit (as it travels to and from Amazon S3) and at rest (while it is stored on disks in Amazon S3 data centers).




· Server-Side Encryption – User requests Amazon S3 to encrypt the object before saving it on disks in its data centers and decrypt it when object are downloaded. Has 3 different types as listed in the image based on who manages the keys.
· Client-Side Encryption – The data is encrypted on the client-side and the encrypted data is uploaded to Amazon S3. In this case, user manage the encryption process, the encryption keys, and related tools.

July 4, 2017

Manage the S3 Data till end of life, efficiently

AWS S3 provides Lifecycle management process to manage the data till end of life in a cost efficient way.
Lifecycle of a object in the bucket or entire bucket can be managed using Lifecycle rules
Lifecycle rules enable you to automatically transition objects to the less expensive S3 storage option say Standard - Infrequent Access Storage Class, and/or archive objects to the Glacier Storage Class, and/or remove objects after a specified time period.
Each rule has an action either Transaction action or Expiration actions.

You can apply rules to either all the objects in the bucket or all the objects that share the specified prefix.





Moving the object directly from S3 to Glacier and S3 to Expire / Delete is also possible.
The object should be in Glacier for min of 90 days before delete; even otherwise it will be charged for 90 days as per the Glacier pricing model.
Old UI for Lifecycle management is pretty self-explanatory than the New UI, hence you may switch to Old UI & try for better clarity.

May 29, 2017

How to split up the Terminal on MAC?

Here is a quick tip to split the Mac - terminal horizontally to facilitate the switch between edit and execution in no time.

GNU Screen (screen from terminal) lets you do that on Mac

• Launch Terminal
• Type screen from Terminal
• Split Screen Horizontally: Press ctrl+a then release everything then press shift+s splits the screen
• Switch to other split: ctrl+a then Tab switches to the other split
• Create bash prompt in new split: ctrl+a then c creates a bash prompt; type exit to come out of command prompt.
• Un-split: ctrl + a then d to un-split the terminal

Note:
  1. Unlike Linux, the GNU Screen on MAC, lets you split the terminal only horizontally but not vertically. The above steps have been verified in OS X version 10.11.6
  2. Caveatctrl + a does not take the cursor to the beginning of the bash prompt in split window, as it is expecting for next command (either Tab or c )

iTerm for macOSX
Alternatively you may also download iTerm for macOS from here, which helps to split both vertically and horizontally
Use cmd + d for vertical split and cmd + shift + d for horizontal split
To navigate between the vertical splits in left/right or up/down fashion use cmd + [ / cmd + ]
iTerm 2 because of these features.

April 19, 2017

Python script for file handling - Read & Write

# Basic File Handling in Python - Read & Write
# coding: utf-8 # for Non-ASCII character support

# Writing to a file
f = open("<file path>/file_read_write.txt", "w");
f.write("Name                    Age                  \n")
f.write("-----------------------------------------\n")

mystring = "%s                   (%d) \n" % ("Ram", 32)
f.write(mystring)

f.close() 

# Reading from a file
f = open("<file path>/file_read_write.txt", "r") 
print f.read() 

f.close()

Note:
you may also try the following commands for selective read(s)
    print f.read(4)
    print f.readline()
    print f.readline(3)

April 6, 2017

How to validate an email address using Python Script?

Code snippet to validate the email id taken as an input via command line

# Python script to validate input email address
# for system input
import sys
print(sys.argv)

# for regular expression
import re
print "\n" 

email_id = raw_input("Please enter your email id: ")
if re.match("[^@]+@[^@]+\.[^@]+", email_id):
print "Hurray! you have entered a valid email id: ", email_id
else:
print "Better luck next time with a valid email id"