Showing posts with label S3. Show all posts
Showing posts with label S3. Show all posts

Wednesday, 30 September 2020

AWS code pipeline with S3 and Github connection

 AWS code pipeline

is a fully managed continuous delivery service that helps you to automate your release pipelines for fast and reliable application and infrastructure updates.
Automates the build,test and deploy phases of release process every time there is a change in code based on release model you defined.
This enables you to every time you deliver features and updates of app.
We can easily integrate AWS services such as GitHub or with your custom plugin.

First Host a static website on AWS S3.

Create a bucket with name 
Click on "Properties" tab after selecting on Bucket.

Click on static website hosting



Make a note of End point and click "Save".
Edit the block public access and enable public access , so that you can access this bucket outside.



Click "Save"

Click "confirm".

Add a bucket policy that your content in the bucket will be publicly available
Bucket policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::mywebsite3009/*"
            ]
        }
    ]
}

Click "save"

you can ignore the following warning message if you would like to give access to the public.

Create "entry.html" with following content and upload the same to the created bucket.

entry.html:
<html>
<head>
    <title>My static Website Home Page</title>
</head>
<body>
  <h1>Welcome to my sample website</h1>
  <p>Am hosted on Amazon S3!</p>
</body>
</html>

Upload to the S3 bucket

Now you can copy the endpoint and paste it in the browser.

In my case the below is the figure .




We have now successfully hosted static website on S3.

Now we can select "codepipeline" under AWS services

 


Enter the pipeline name and accept the default values as below and select "Next".

Select "Github" as a source and click on "connect github"

Give your Github account name and select the repository name.

click on "install" then select "connect".


Then select "Next"

For now you can skip build stage.

Under "Deploy" select below values.



Select "Next" and review the details and select "create pipeline"

Now we have created successfully created pipeline.



Change something in "my-app" source code and check the git status.



and push the changes to github.


In another way 

you can have same website files which are uploaded to S3 and github will be same.
So that when you change the code of your website , it automatically reflect the change when you push.

Since have my Java project connected with S3 via pipeline, when you push the changes of your updated java file to github. the updated file will be shown under S3.



Now you can open sample.java , it will be shown as we have updated as below

Sample.java:
public class sample {

public static void main(String args[]){
System.out.println("Thiis is my app which is created in pipeline");
}

}

This is how codepipeline will work with static website, java project and github changes.





Thank you for reading.

Wednesday, 2 September 2020

Simple Storage Service - Part1

 In short form its known as S3.

S3: it provides developers and IT teams with secure,durable,highly scalable object storage.

  • Is a safe place to store your files
  • It is object based storage
  • The data is spread across multiple devices and facilities.
  • File size can be 0B to 5 TB.

S3 names must be unique globally,because when we create buckets it will create URLs like below

https://mysamplebucket.eu-east-1.amazonaws.com

It means that 

mysamplebucket: Bucket name

eu-east-1: region name , where you have created bucket.

it ends and starts with amazonaws.com and https:// respectively.When you upload file to S3 , you will receive 200 code when upload is successful.

S3 objects consists of the following.

  1. Key
  2. Value
  3. Version ID
  4. Metadatada
  5. Subresources: Access control lists and torrent.
How consistency works in S3
  • Read after write consistency for PUTS of new objects.
  • Eventual consistency for PUTS and DELETES
It has following guarantees from Amazon.
  • Built for 99.99% availability for the S3 platform
  • Amazon guarantee 99.9% availability.
  • Amazon guarantee 99.99999999999% durability for S3 information.
Different Tiers of S3.

S3 StandardGlacier
Availability:99.9%Most cheaper and secure ,durable when you want to archeive the data.
Durability: 99.999999999%You can store any amount of data with cheaper that is more less than the on-premises cost.
S3 IA(Infrequent Access)Retrieval times are configurable from mins to hours.
Access data infrequentlyS3 Glacier-Deep archive
Rapid accessis a lowest cost storage option
Lower fee than S3 standardoffers 12hrs of retrieval time is acceptable.
Charged for retrieval of data
S3 -One Zone IAS3 -Intelligent tiering
For where you want lower cost options for In frequently accessed data but do not required data resilience.Moves the data to the most cost effective tier without impacting the data performance and operational overhead.

 
How to create S3 bucket

Enter Name and region of the bucket and click on "Next" button.


Click on "next" by accepting default values in the next screen.

By default "Block public accessing" be enabled , you no need to change any settings and click on "Next".


It will show all the details which you selected to create bucket as below , then click on "Create bucket".


Now Bucket is created as below


We have uploaded a file , just by clicking on bucket name and add the file which you wants to upload.
Once its successfully uploaded , you can see your uploaded file in the bucket.


Just select the file you can see the file details like below

Just observe the Object URL , it has the format as we explained earlier.
https://bucketname.s3.region name.amazonaws.com/filename.

As you know that we didn't enable public access of the file , So when you click on that ,you can see below screen.

To make public, you can do as below.

Uncheck the "Block all public access" and click on Save.


then select the file which you would like to see and click on "Make public" and browser returns "success" message .



Now i can see the image as below


So, to give access to anyone in the world , just you can share the object URL to the intended members to view the file.

If you want to change the object store S3 type , click on the 

Click on standard as below


it will open the screen and select "Storage class" as below


We can change the storage class type as you required.


Access control lists: it will set fine grained access permissions to individual objects to allow access.

To allow access all the files in the bucket , you can provide access using "bucket policy".

S3 Price is depends on the below.
  1. Storage
  2. input and retrieval
  3. transfer
  4. management and replication.
S3 buckets can be accessed logs of the another bucket like who access it etc , that will be shared to another bucket or to another account.

Encryption in S3.

When you are accessing an object using https:// , it will be encrypted while transferring the data.

Encryption at rest is achieved by the below
There are two types of encryption.
  1. Server side encryption
  2. Client Side encryption
Server side encryption can be achieved by using 
  • S3 managed keys
  • AWS Key Management service 
  • Server side encryption with customer provided keys.
Client side encryption : you can do the data by encrypting and upload it to S3.

S3 Versioning:

Versioning can be enabled and we won't disable once its enabled but we can suspend.
By Using versioning we can take a backup of the object based on version.
By using MFA Delete capability which uses multi factor authentication to provide exttra layer of security to the object.
  • when we upload any file as a first version , it will be private and we need to make it as public.
  • Once the file is uploaded , we need check the access 
  • The same file you can upload with some modifications in the file, now both files will be existed but the latest version file will not be accessed , to access that you need to make it as a public.
  • You can do some more modifications to the file and check the access , still you are not able to access, you need to follow the same to make it public.
First simple text file uploaded as first version.


Now the file is visible.

Enable the versioning as below


When versioning enabled , you can see below UI .


and you can't see all the versions by default,if you want select "show" to see the versions of your files.

Again we need to make as public for the latest file which you upload to see the content of the file.


Now delete the latest version of the file , when you select "Delete" it will just create a copy with "Delete marker" but still the file will stored, so that we can access prev version of the file.

So, what we need to do is we need to delete individual versions to make successful delete.

Thank you for readingπŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘