Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label AWS. Show all posts
Showing posts with label AWS. Show all posts

Sunday 15 October 2017

Mount S3 Bucket using IAM Role on Ubuntu 16.04

Mount S3 Bucket using IAM Role on Ubuntu 16.04


Q. What Is Amazon S3?

-- Amazon Simple Storage Service is storage for the Internet. It is designed to make web-scale computing easier for developers. Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web.

Step: 1. Create a new Policy to Access the target S3 Bucket : 

1















-- Enter Policy Name, Description and the Policy Document as given below :

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetBucketLocation",
        "s3:ListAllMyBuckets"
      ],
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": ["arn:aws:s3:::bucket-name"]
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
        "s3:GetObject",
        "s3:DeleteObject"
      ],
      "Resource": ["arn:aws:s3:::bucket-name/*"]
    }
  ]
}

2



















Step: 2. Create a New Role using "Amazon EC2" Service Role Type :

-- Click on “Create new Role” and Select Role Type as Amazon EC2.

3
















-- Next select “s3access” policies to Attach.

4










-- Enter Role Name, Description as given below and click on “Create Role” button.

5



















-- The Attach Policy of the new Role should look like below:

6



















Step: 3. Attach IAM Role to the running Instance or Launching new Instance :

7
















-- Select Role name from drop-down box and click on “Apply” button.

8









9








Step: 4. Mount S3 Bucket to an Instance :

-- Login to instance using console and follow the steps below :

# apt-get update -y
# apt-get install build-essential libfuse-dev libcurl4-openssl-dev libxml2-dev \
    mime-support automake libtool git
# cd /tmp
# git clone https://github.com/s3fs-fuse/s3fs-fuse.git
# cd s3fs-fuse/
# ./autogen.sh
# ./configure
# make
# make install
# mkdir /s3backups
# chmod 755 /s3backups

-- Now Mount the S3 Bucket using IAM Role :

# s3fs -o iam_role="EC2RoleForS3Access" bucket-name /s3backups
# df -Th

[OUTPUT]
Filesystem     Type         Size       Used  Avail   Use%  Mounted on
s3fs                 fuse.s3fs  256T     0         256T   0%      /s3backups

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog



Tuesday 29 March 2016

Install & Configure AWS API Tool on EC2 Instance

Install & Configure AWS API Tool on EC2 Instance
Q. What is AWS API Tool ?


 Ans: The API tools serve as the client interface to the Amazon EC2 web service. You can use the CLI tools to manage your Amazon EC2 resources (such as instances, security groups, and volumes) and your Amazon VPC resources (such as VPCs, subnets, route tables, and Internet gateways).

Step: 1. Install Java :

# yum -y install java-1.7.0-openjdk
# export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
# java -version

Step: 2. Download & Unzip Amazon EC2 CLI Tools :

# yum -y install wget zip unzip
# cd /tmp
# wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
# unzip ec2-api-tools.zip

Step: 3. Install the Amazon EC2 CLI Tools :

# mkdir /usr/local/ec2
# mv ec2-api-tools-1.7.5.0 /usr/local/ec2/apitools/

Step: 4. Set Variables :

# export EC2_HOME=/usr/local/ec2/apitools
# export PATH=$PATH:$EC2_HOME/bin

Step: 5. Add variables to Startup Script :

# cd /etc/profile.d/
# vi aws.sh

export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
export EC2_HOME=/usr/local/ec2/apitools
export PATH=$PATH:$EC2_HOME/bin

-- Save & Quit (:wq)


# chmod +x aws.sh
# source aws.sh

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Thursday 28 January 2016

How To Add Swap Space to Amazon EC2 Linux


Add Swap Space

 METHOD: 1

Step: 1. Attach the EBS volume to the instance in AWS Panel :

Note: The device you set it to (in my case, /dev/xvdg).

Step: 2. To see which Devices are Active on your Instance :

Go to Terminal & Type :

# fdisk -l

Step: 3. Setup the SWAP Area :

# mkswap -f /dev/xvdg

(the -f option is to force the command to proceed – omit it if you are unsure about the target)

Step: 4. In order to have the SWAP Space Available after a Boot :

# vi /etc/fstab   

/dev/xvdg       swap    swap    defaults        0  0

-- Save & Quit (:wq)

Step: 5. Finally, We can turn on SWAP (without a reboot) :
   
# swapon /dev/xvdg

Step: 6. To Check SWAP : 

# free -m

METHOD: 2

Step: 1. Type the following command with count being equal to the desired block size :

# dd if=/dev/zero of=/swapfile bs=1M count=1024

Step: 2. Setup the SWAP file with the command :

# mkswap /swapfile

Step: 3. To Enable the SWAP file Immediately but not Automatically at Boot Time :

# swapon /swapfile

Step: 4. To Enable it at the Boot Time  :

# vi /etc/fstab

/swapfile     swap     swap     defaults     0 0

-- Save & Quit (:wq)

Step: 5. To Check SWAP : 

# free -m


Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Wednesday 27 January 2016

How to Attach & Mount S3 Bucket on CentOS/RHEL & Ubuntu using S3FS

Install S3 Bucket


Q. What Is Amazon S3?

-- Amazon Simple Storage Service is storage for the Internet. It is designed to make web-scale computing easier for developers. Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web.


Step: 1. Install Required Packages :

For CentOS/RHEL Users:

# yum -y install gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap

For Ubuntu Users:

# apt-get -y install build-essential libcurl4-openssl-dev libxml2-dev mime-support

Step: 2. Install Latest Fuse :

For CentOS/RHEL Users:

# yum -y install fuse fuse-devel

For Ubuntu Users:

# apt-get -y install fuse fuse-utils

Step: 3. Download and Compile Latest S3FS :

# cd /usr/src/
# wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/s3fs/s3fs-1.74.tar.gz
# tar xzf s3fs-1.74.tar.gz
# cd s3fs-1.74
# ./configure --prefix=/usr/local
# make && make install

Step: 4. Make a File in /etc/passwd-s3fs & Put the Bucket_name, Access Key & Secret Key :

# vi /etc/passwd-s3fs

bucket_name:Aws_Access_Key:Aws_Secret_Key

-- Save & Quit (:wq)

Step: 5. Give Permission :

# chmod 640 /etc/passwd-s3fs

Step: 6. To Mount the S3 :

# mkdir /s3backups
# chmod -Rf 755 /s3backups
# /usr/local/bin/s3fs bucket_name /s3backups -ouse_cache=/tmp -o use_rrs=1

Step: 7. For Permanently Mount s3 :

# vi /etc/fstab

s3fs#bucket_name /s3backups fuse _netdev,use_cache=/tmp,use_rrs=1,allow_other 0 0

-- Save & Quit (:wq)

Step: 8. Unmount s3 :

# fusermount -u /s3backups

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog


Copyright © 2016 Kousik Chatterjee's Blog