Launches an EC2 instance on AWS, that downloads the g6t/g6tr
repo, then downloads the newest Gradient Docker image with RStudio and
launches RStudio Server with the home directory set to g6t/g6tr, with a
pre-defined username and password for RStudio Server access. Other wrappers
like g6tr_stop, g6tr_start, g6tr_terminate manage to
stop working instance, start stopped instance and terminate the instance.
Usage
g6tr_ec2_stop(instance_id = NULL, instance_ip = NULL)
g6tr_ec2_terminate(instance_id = NULL, instance_ip = NULL)
g6tr_ec2_start(
instance_id = NULL,
instance_name,
pemfile_path = Sys.getenv("AWS_PEM")
)
g6tr_ec2_launch(
image_id = "ami-08932e4b8e3890138",
image_type = c("t2.large", "t2.xlarge", "t2.2xlarge", "t2.micro", "t2.nano",
"t2.small", "t2.medium"),
image_security_group = "sg-cb0bf4b8",
image_keypair = "20170822",
image_name = "Made From R",
rserver_username = "gradient",
rserver_password = "marcin",
docker_tag = c("rest-fonts", "minimal-3.6", "minimal-3.5"),
docker_username = Sys.getenv("DOCKER_USERNAME"),
docker_password = Sys.getenv("DOCKER_PASSWORD"),
github_username = Sys.getenv("GITHUB_USERNAME"),
github_password = Sys.getenv("GITHUB_PASSWORD"),
amazon_key_id = Sys.getenv("AWS_ACCESS_KEY_ID"),
amazon_secret_key = Sys.getenv("AWS_SECRET_ACCESS_KEY"),
pemfile_path = Sys.getenv("AWS_PEM")
)Arguments
- instance_id
The instance ID. Either string or ec2_instance object, returned by
g6tr_ec2_launch- instance_ip
The instance IP address
- instance_name
The instance name to be started. Used in
g6tr_ec2_start.- pemfile_path
local path to the image_keypair file
- image_id
the id of an AMI from this section https://console.aws.amazon.com/ec2/home?region=us-east-1#Images:sort=creationDate to be used as a source machine
- image_type
the size of the machine https://aws.amazon.com/ec2/instance-types/
- image_security_group
the name of the security group to be used to set the access (use the defualt one) https://console.aws.amazon.com/ec2/home?region=us-east-1#SecurityGroups:sort=groupName
- image_keypair
the name of the keypair that matches PEM file for ssh authentication https://console.aws.amazon.com/ec2/home?region=us-east-1#KeyPairs:sort=keyName
- image_name
custom name to be set for the machine
- rserver_username
the username for RStudio Server
- rserver_password
the authentication password for RStudio Server
- docker_tag
the docker tag name to be used to launch docker container, one of
rest-fonts(default),minimal-3.6orminimal-3.5- docker_username
the username to hub.docker.com portal, so that gradientmetrics/g6tr_github:rstudio can be pulled
- docker_password
the password to hub.docker.com portal, so that gradientmetrics/g6tr_github:rstudio can be pulled
- github_username
the username to github.com portal, so that g6t/g6tr can be cloned
- github_password
the password to github.com portal, so that g6t/g6tr can be cloned
- amazon_key_id
the access key ID from aws.amazon.com, so that s3 bucket can be mounted
- amazon_secret_key
the secret access key from aws.amazon.com, so that s3 bucket can be mounted
Details
See `Running Dockerized RStudio Server on AWS EC2` article/vignette under docs.gradientmetrics.com
Examples
# set .Renviron
# so that you provide those environmental variables
# AWS_ACCESS_KEY_ID =
# AWS_DEFAULT_REGION = us-east-1
# AWS_PEM =
# AWS_SECRET_ACCESS_KEY =
# DOCKER_PASSWORD =
# DOCKER_USERNAME =
# GITHUB_PASSWORD =
# GITHUB_USERNAME =
if (FALSE) { # \dontrun{
instance_1 <-
g6tr_ec2_launch(
rserver_username = "marcin",
rserver_password = "secretpassword",
image_name = "Making tests",
image_keypair = "20170822",
pemfile_path = Sys.getenv("AWS_PEM")
)
instance_2 <-
g6tr_ec2_launch(
rserver_username = "marcin",
rserver_password = "secretpassword",
image_name = "Making tests 2",
image_keypair = "20170822",
pemfile_path = Sys.getenv("AWS_PEM")
)
g6tr_ec2_stop(instance_1)
g6tr_ec2_start(instance_1)
g6tr_ec2_stop(instance_1)
g6tr_ec2_terminate(instance_1)
g6tr_ec2_stop(instance_ip = "3.81.159.227")
instance_3 <- g6tr_ec2_start(instance_name = "Making tests 2")
g6tr_ec2_terminate(instance_3)
} # }