Showing posts with label aws. Show all posts
Showing posts with label aws. Show all posts
Elastic IP
Elastic IP is
1)Static IP
2)Attached with AWS account
3)Not with ec2 instance
4)You can map elastic ip to another ec2 instance.
reference: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
reference: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
Elastic BeanStalk command line usage create application, create environment, deploy, terminate, git branch
Elastic BeanStalk
#create elastic bean stalk applicaiton
eb init
#create elastic bean stalk environment for current applicaiton
eb create
#push current branch the code to current default environment of current applicaiton
eb deploy
# list environment for the current application
eb list
#set default environment name for git branch
eb use
#connect to ec2 instace
eb ssh
#show slogs
eb logs
#open amazon console of elasticbean for this application
eb console
#check environment health
eb health
#sets environment variable of the current environment, current applicaton
eb setenv name="ikbhal" age=20
#print the enviroment variable of the current enviromnet, current application
eb printenv
#status of the environment
eb status
status: updating, terminating
health: Grey, Green
#terminate the environment
eb terminate
#list all the git branch
git branch
#change the git branch
git chekcout
#delete the git branch
git branch -d
note: you can not delete the current branch
#to force delte git branch
git branch -D
#merge to master
git checkout master
git merge
#create elastic bean stalk applicaiton
eb init
#create elastic bean stalk environment for current applicaiton
eb create
#push current branch the code to current default environment of current applicaiton
eb deploy
# list environment for the current application
eb list
#set default environment name for git branch
eb use
#connect to ec2 instace
eb ssh
#show slogs
eb logs
#open amazon console of elasticbean for this application
eb console
#check environment health
eb health
#sets environment variable of the current environment, current applicaton
eb setenv name="ikbhal" age=20
#print the enviroment variable of the current enviromnet, current application
eb printenv
#status of the environment
eb status
status: updating, terminating
health: Grey, Green
#terminate the environment
eb terminate
#list all the git branch
git branch
#change the git branch
git chekcout
#delete the git branch
git branch -d
note: you can not delete the current branch
#to force delte git branch
git branch -D
#merge
git checkout master
git merge
Labels:
application,
aws,
cli,
console,
create,
deploy,
eb,
environment,
health,
init,
list,
logs,
merge,
printenv,
setenv,
ssh,
status
How to create controller in yeoman and push to aws elastic bean stalk
yo angular
yo angular:controller testController
..add some directives / views etc..
grunt server -- serves up pages correctly on port 9000
grunt -- which creates the dist folder
reference: http://stackoverflow.com/questions/18325510/how-to-deploy-a-yeoman-build-to-aws-node-js
Install AWS cli(command line) on mac?
reference: http://docs.aws.amazon.com/cli/latest/userguide/installing.html#install-bundle-other-os
Requirement:
2.6.5+ or 3.3+
sudo pip install awscli
to upgrade
suod pip install --upgrade awscli
Requirement:
2.6.5+ or 3.3+
sudo pip install awscli
to upgrade
suod pip install --upgrade awscli
How to create AWS instance profile via command line?
1)Create instance profile
aws iam create-instance-profile
2)Attach role to instance profile
aws iam add-role-to-instance-profile
# Create the role and attach the trust policy that enables EC2 to assume this role.
aws iam create-role --role-name Test-Role-for-EC2 --assume-role-policy-document file://C:\policies\trustpolicyforec2.json
# Embed the permissions policy (in this example an inline policy) to the role to specify what it is allowed to do.
aws iam put-role-policy --role-name Test-Role-for-EC2 --policy-name Permissions-Policy-For-Ec2 --policy-document file://c:\policies\permissionspolicyforec2.json
# Create the instance profile required by EC2 to contain the role
aws iam create-instance-profile --instance-profile-name EC2-ListBucket-S3
# Finally, add the role to the instance profile
aws iam add-role-to-instance-profile --instance-profile-name EC2-ListBucket-S3 --role-name Test-Role-for-EC2
What is Amazon instance profile?
if you are using AWS ec2 or AWS serive that uses AWS ec2 then
you have to store role in intance profile
end
instance profile is container that store role
will attach to AWS ec2.
you have to store role in intance profile
end
instance profile is container that store role
will attach to AWS ec2.
Create role for AWS service via command line
1)Create role
aws iam create-role
2)attch policy to role
2.1)Attach managed poilicy to role
aws iam attach-role-plicy
or
2.2)Attach inline policy
aws iam put-role-plicy
aws iam create-role
2)attch policy to role
2.1)Attach managed poilicy to role
aws iam attach-role-plicy
or
2.2)Attach inline policy
aws iam put-role-plicy
What is service role in AWS?
Service is role is AWS Role
this is for AWS Service
Through which we grant permission to service.
Services like: AWS ec2, AWS data pipeline, AWS ops work, AWS elastic Bean Stalk.
These resources will access AWS resources.
You can create role to determine what the services is allowed to do with these resources.
Assign the policy to role
This policy can be AWS managed policy
or custom policy
or policy base from AWS Managed policy.
this is for AWS Service
Through which we grant permission to service.
Services like: AWS ec2, AWS data pipeline, AWS ops work, AWS elastic Bean Stalk.
These resources will access AWS resources.
You can create role to determine what the services is allowed to do with these resources.
Assign the policy to role
This policy can be AWS managed policy
or custom policy
or policy base from AWS Managed policy.
AWS Dynamo DB operations
package com.amazonaws.codesamples.datamodeling;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
public class ObjectPersistenceCRUDExample {
static AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider());
public static void main(String[] args) throws IOException {
testCRUDOperations();
System.out.println("Example complete!");
}
@DynamoDBTable(tableName="ProductCatalog")
public static class CatalogItem {
private Integer id;
private String title;
private String ISBN;
private Set bookAuthors;
@DynamoDBHashKey(attributeName="Id")
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }
@DynamoDBAttribute(attributeName="Title")
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
@DynamoDBAttribute(attributeName="ISBN")
public String getISBN() { return ISBN; }
public void setISBN(String ISBN) { this.ISBN = ISBN;}
@DynamoDBAttribute(attributeName = "Authors")
public Set getBookAuthors() { return bookAuthors; }
public void setBookAuthors(Set bookAuthors) { this.bookAuthors = bookAuthors; }
@Override
public String toString() {
return "Book [ISBN=" + ISBN + ", bookAuthors=" + bookAuthors
+ ", id=" + id + ", title=" + title + "]";
}
}
private static void testCRUDOperations() {
CatalogItem item = new CatalogItem();
item.setId(601);
item.setTitle("Book 601");
item.setISBN("611-1111111111");
item.setBookAuthors(new HashSet(Arrays.asList("Author1", "Author2")));
// Save the item (book).
DynamoDBMapper mapper = new DynamoDBMapper(client);
mapper.save(item);
// Retrieve the item.
CatalogItem itemRetrieved = mapper.load(CatalogItem.class, 601);
System.out.println("Item retrieved:");
System.out.println(itemRetrieved);
// Update the item.
itemRetrieved.setISBN("622-2222222222");
itemRetrieved.setBookAuthors(new HashSet(Arrays.asList("Author1", "Author3")));
mapper.save(itemRetrieved);
System.out.println("Item updated:");
System.out.println(itemRetrieved);
// Retrieve the updated item.
DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.ConsistentReads.CONSISTENT);
CatalogItem updatedItem = mapper.load(CatalogItem.class, 601, config);
System.out.println("Retrieved the previously updated item:");
System.out.println(updatedItem);
// Delete the item.
mapper.delete(updatedItem);
// Try to retrieve deleted item.
CatalogItem deletedItem = mapper.load(CatalogItem.class, updatedItem.getId(), config);
if (deletedItem == null) {
System.out.println("Done - Sample item is deleted.");
}
}
}
What is Amazon EBS?
Elastic Block Storage
This is storage which lives independent of ec2 instance state
Its available only in one region
Need:
data change frequently
long term storage
Use
File system
Database
Messaging QuUE
This is storage which lives independent of ec2 instance state
Its available only in one region
Need:
data change frequently
long term storage
Use
File system
Database
Messaging QuUE
AWS code pipeline
continuous delivery
when you make changes to your applicaiton
it collects/git pull
builds it
test it
deploy it
in real time
Available Regions:
US East(N. Virginia)
Code reposity support:
Amazon s3
Github
when you make changes to your applicaiton
it collects/git pull
builds it
test it
deploy it
in real time
Available Regions:
US East(N. Virginia)
Code reposity support:
Amazon s3
Github
Play framework deployment on Amazon AWS ec2
refrence : http://www.javacirecep.com/cloud/deploy-play-scala-applications-on-amazon-ec2/
Linux flavour: Amazon Linux AMI
Linux flavour: Amazon Linux AMI
sudo yum remove java-1.7.0-openjdk sudo yum install java-1.8.0
ec2 type choice info
https://aws.amazon.com/ec2/pricing/
Amazon ec2 container service
Amazon ec2 container service free of charge
Only charge for ec2
It provides all the container functionalities
manage more containers
Only charge for ec2
It provides all the container functionalities
manage more containers
AWS ec2 selection decision for Play Framework 2.4
Amazon Linux/Ubuntu/Cent OS
not decide, even the below discussion is for creating binary distribution of package
Reference:
activator clean compile dist
use nginx as front load balancer for port forwarding from 80 to 9000
old reference might not work exactly
SCRIPT: /al-start.sh
chmod +x start nohup ./start -server -Dconfig.resource=application-prod.conf -Dhttp.port=9000 &
A few notes about this script:
- I created this script so I don’t have to edit the Play
startscript.- It uses a Play configuration file named application-prod.conf. That file just needs to be on the classpath, so having it in the Play application conf folder is all you need.
- It runs the server on port
9000. You don’t need to specify that on the command line, but I have a bad memory, so if I want to change this later, it’s easiest to specify it now.Another note about the production environment: Port80on the kbhr.co website is served by Nginx, and it does a proxy to serve the Play application.
Subscribe to:
Posts (Atom)