All Projects → cloudyr → Aws.ec2

cloudyr / Aws.ec2

AWS EC2 Client Package

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Aws.ec2

Spark Jupyter Aws
A guide on how to set up Jupyter with Pyspark painlessly on AWS EC2 clusters, with S3 I/O support
Stars: ✭ 259 (+451.06%)
Mutual labels:  aws, ec2, aws-ec2
Amazon Ec2 Instance Selector
A CLI tool and go library which recommends instance types based on resource criteria like vcpus and memory
Stars: ✭ 146 (+210.64%)
Mutual labels:  aws, ec2, aws-ec2
Udacity Data Engineering Projects
Few projects related to Data Engineering including Data Modeling, Infrastructure setup on cloud, Data Warehousing and Data Lake development.
Stars: ✭ 458 (+874.47%)
Mutual labels:  aws, aws-ec2
Rattlesnakeos Stack
Build your own privacy and security focused Android OS in the cloud.
Stars: ✭ 490 (+942.55%)
Mutual labels:  aws, ec2
Aws
A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.
Stars: ✭ 493 (+948.94%)
Mutual labels:  aws, ec2
Bridgy
cloud inventory + ssh + tmux + sshfs
Stars: ✭ 374 (+695.74%)
Mutual labels:  aws, ec2
Bastillion Ec2
A web-based SSH console to execute commands and manage multiple EC2 instances simultaneously running on Amazon Web Services (AWS).
Stars: ✭ 410 (+772.34%)
Mutual labels:  aws, ec2
Automating Aws With Python
automating AWS with Python using boto3 library
Stars: ✭ 41 (-12.77%)
Mutual labels:  aws, aws-ec2
Aws Gate
Better AWS SSM Session manager CLI client
Stars: ✭ 294 (+525.53%)
Mutual labels:  aws, ec2
Ecs Refarch Continuous Deployment
ECS Reference Architecture for creating a flexible and scalable deployment pipeline to Amazon ECS using AWS CodePipeline
Stars: ✭ 776 (+1551.06%)
Mutual labels:  aws, ec2
Geodesic
🚀 Geodesic is a DevOps Linux Distro. We use it as a cloud automation shell. It's the fastest way to get up and running with a rock solid Open Source toolchain. ★ this repo! https://slack.cloudposse.com/
Stars: ✭ 629 (+1238.3%)
Mutual labels:  aws, ec2
Aws Ec2 Ssh
Manage AWS EC2 SSH access with IAM
Stars: ✭ 796 (+1593.62%)
Mutual labels:  aws, aws-ec2
Practicalnode
Practical Node.js, 1st and 2nd Editions [Apress] 📓
Stars: ✭ 3,694 (+7759.57%)
Mutual labels:  aws, aws-ec2
Terraform Aws Ec2 Instance
Terraform module which creates EC2 instance(s) on AWS
Stars: ✭ 344 (+631.91%)
Mutual labels:  aws, aws-ec2
Security monkey
Security Monkey monitors AWS, GCP, OpenStack, and GitHub orgs for assets and their changes over time.
Stars: ✭ 4,244 (+8929.79%)
Mutual labels:  aws, aws-ec2
Ec2instances.info
Amazon EC2 instance comparison site
Stars: ✭ 3,619 (+7600%)
Mutual labels:  aws, ec2
Moto
A library that allows you to easily mock out tests based on AWS infrastructure.
Stars: ✭ 5,428 (+11448.94%)
Mutual labels:  aws, ec2
hammertime
AWS EC2, ASG, RDS Power cycling
Stars: ✭ 12 (-74.47%)
Mutual labels:  ec2, aws-ec2
Aws Scalable Big Blue Button Example
Demonstration of how to deploy a scalable video conference solution based on Big Blue Button
Stars: ✭ 29 (-38.3%)
Mutual labels:  aws, ec2
Aws Security Viz
Visualize your aws security groups.
Stars: ✭ 511 (+987.23%)
Mutual labels:  aws, ec2

AWS EC2 Client Package

aws.ec2 is a simple client package for the Amazon Web Services (AWS) Elastic Cloud Compute (EC2) REST API, which can be used to monitor use of AWS web services.

To use the package, you will need an AWS account and to enter your credentials into R. Your keypair can be generated on the IAM Management Console under the heading Access Keys. Note that you only have access to your secret key once. After it is generated, you need to save it in a secure location. New keypairs can be generated at any time if yours has been lost, stolen, or forgotten. The aws.iam package profiles tools for working with IAM, including creating roles, users, groups, and credentials programmatically; it is not needed to use IAM credentials.

To use the package, you will need an AWS account and to enter your credentials into R. Your keypair can be generated on the IAM Management Console under the heading Access Keys. Note that you only have access to your secret key once. After it is generated, you need to save it in a secure location. New keypairs can be generated at any time if yours has been lost, stolen, or forgotten. The aws.iam package profiles tools for working with IAM, including creating roles, users, groups, and credentials programmatically; it is not needed to use IAM credentials.

A detailed description of how credentials can be specified is provided at: https://github.com/cloudyr/aws.signature/. The easiest way is to simply set environment variables on the command line prior to starting R or via an Renviron.site or .Renviron file, which are used to set environment variables in R during startup (see ? Startup). They can be also set within R:

Sys.setenv("AWS_ACCESS_KEY_ID" = "mykey",
           "AWS_SECRET_ACCESS_KEY" = "mysecretkey",
           "AWS_DEFAULT_REGION" = "us-east-1",
           "AWS_SESSION_TOKEN" = "mytoken")

Code Examples

The basic idea of the package is to be able to launch and control EC2 instances. You can read this blog post from AWS about how to run R on EC2.

A really simple example is to launch an instance that comes preloaded with an RStudio Server Amazon Machine Image (AMI):

# Describe the AMI (from: http://www.louisaslett.com/RStudio_AMI/)
image <- "ami-3b0c205e" # us-east-1
#image <- "ami-93805fea" # eu-west-1
describe_images(image)

# Check your VPC and Security Group settings
## subnet
subnets <- describe_subnets()
## security group
my_sg <- create_sgroup("r-ec2-sg", "Allow my IP", vpc = subnets[[1L]])
## use existing ip address or create a new one
ips <- describe_ips()
if (!length(ips)) {
    ips[[1L]] <- allocate_ip("vpc")
}

# create an SSH keypair
my_keypair <- create_keypair("r-ec2-example")
pem_file <- tempfile(fileext = ".pem")
cat(my_keypair$keyMaterial, file = pem_file)

# Launch the instance using appropriate settings
i <- run_instances(image = image, 
                   type = "t2.micro", # <- you might want to change this
                   subnet = subnets[[1L]], 
                   sgroup = my_sg,
                   keypair = my_keypair)
Sys.sleep(5L) # wait for instance to boot

# associate IP address with instance
instance_ip <- get_instance_public_ip(i)
if (is.na(instance_ip)) {
    instance_ip <- associate_ip(i, ips[[1L]])$publicIp
}
# authorize access from this IP
try(authorize_ingress(my_sg))
try(authorize_egress(my_sg))

With the instance up and running, you can now access it a number of ways. Given it's an RStudio Server instance, you can just navigate to the public IP address via your browser:

# open RStudio server in browser
browseURL(paste0("http://", instance_ip))

Or you can login via ssh or putty on the command line. Thanks to the ssh package, you can also create an SSH connection directly in R:

# log in to instance
library("ssh")
session <- ssh::ssh_connect(paste0("[email protected]", instance_ip), keyfile = pem_file, passwd = "rstudio")

# write a quick little R script to execute
cat("'hello world!'\nsprintf('2+2 is %d', 2+2)\n", file = "helloworld.R")
# upload it to instance
invisible(ssh::scp_upload(session, "helloworld.R"))

# execute script on instance
x <- ssh::ssh_exec_wait(session, "Rscript helloworld.R")

## disconnect from instance
ssh_disconnect(session)

Another option is to again use ssh to setup an interactive session that will be usable with remoter. This requires running

remoter::server()

on the instance and then logging into it locally with remoter::client(). This is left as an exercise for advanced users.

Regardless of how you access the instance, make sure to turn it off and clean up after yourself:

## stop and terminate the instance
stop_instances(i[[1L]])
terminate_instances(i[[1L]])

## revoke access from this IP to security group
try(revoke_ingress(my_sg))
try(revoke_egress(my_sg))

## delete keypair
delete_keypair(my_keypair)

## release IP address
release_ip(ips[[1L]])

Installation

CRAN Downloads Travis Build Status codecov.io

This package is not yet on CRAN. To install the latest development version you can install from the cloudyr drat repository:

# latest stable version
install.packages("aws.ec2", repos = c(getOption("repos"), "http://cloudyr.github.io/drat"))

Or, to pull a potentially unstable version directly from GitHub:

if(!require("remotes")){
    install.packages("remotes")
}
remotes::install_github("cloudyr/aws.ec2")

cloudyr project logo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].