Skip to content

Instantly share code, notes, and snippets.

@davidski
Created November 5, 2015 22:27
Show Gist options
  • Save davidski/784f40ec94b4bb88d1f9 to your computer and use it in GitHub Desktop.
Save davidski/784f40ec94b4bb88d1f9 to your computer and use it in GitHub Desktop.
Scrubbed version of RStudio CloudFormation template as referenced at http://blog.severski.net/2015/11/creating-rstudio-server-instance-on-aws.html
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Spin up a RStudio Server instance with a HTTPS off-loading ELB.",
"Parameters" : {
"SSLcertificate" : {
"Type" : "String",
"Default" : "arn:aws:iam::ACCOUNT)NUMBER:server-certificate/rstudio-cert",
"Description" : "Enter the ARN of the server certificate for ELB front-end. Default is rstudio-cert."
},
"MaxSpotPrice" : {
"Type" : "Number",
"Default" : "0.10",
"Description" : "Enter maximum spot price."
},
"KeyName" : {
"Description" : "The EC2 Key Pair to allow SSH access to the instances.",
"Default" : "keypair_name",
"Type" : "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "Must be the name of an existing EC2 KeyPair."
},
"RStudioAMI" : {
"Type" : "String",
"Default" : "ami-1",
"Description" : "Enter the AMI image ID of the RStudio Server image."
}
},
"Resources" : {
"InstanceConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"AssociatePublicIpAddress" : "true",
"ImageId" : {"Ref" : "RStudioAMI" },
"SecurityGroups" : [ "sg-1" ],
"KeyName": {"Ref" : "KeyName" },
"InstanceType" : "m4.2xlarge",
"SpotPrice" : { "Ref" : "MaxSpotPrice" },
"BlockDeviceMappings" : [ {
"DeviceName" : "/dev/sda1",
"Ebs" : {
"VolumeSize" : "40",
"VolumeType" : "gp2"
}
} ]
}
},
"MyServerGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"VPCZoneIdentifier" : [ "subnet-1", "subnet-2" ],
"LaunchConfigurationName" : { "Ref" : "InstanceConfig" },
"MinSize" : "1",
"MaxSize" : "1",
"LoadBalancerNames" : [ { "Ref" : "myELB" } ],
"Tags" : [
{
"Key" : "Name",
"Value" : "rstudio-server",
"PropagateAtLaunch" : "true"
},
{
"Key" : "Project",
"Value" : "rusers",
"PropagateAtLaunch" : "true"
}
]
}
},
"myELB" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"SecurityGroups" : [ "sg-1", "sg-2" ],
"Scheme" : "internet-facing",
"Subnets": [ "subnet-1", "subnet-2" ],
"Listeners" : [ {
"LoadBalancerPort" : "443",
"InstancePort" : "8080",
"Protocol" : "HTTPS",
"InstanceProtocol" : "HTTP",
"SSLCertificateId" : { "Ref" : "SSLcertificate" }
} ],
"Tags" : [
{
"Key" : "Name",
"Value" : "rstudio-server"
},
{
"Key" : "Project",
"Value" : "rusers"
}
]
}
},
"myDNS" : {
"Type" : "AWS::Route53::RecordSetGroup",
"Properties" : {
"HostedZoneName" : "example.tld.",
"Comment" : "Zone alias targeted to myELB LoadBalancer.",
"RecordSets" : [
{
"Name" : "rstudio.example.tld.",
"Type" : "A",
"AliasTarget" : {
"HostedZoneId" : { "Fn::GetAtt" : ["myELB", "CanonicalHostedZoneNameID"] },
"DNSName" : { "Fn::GetAtt" : ["myELB","CanonicalHostedZoneName"] }
}
}
]
}
}
},
"Outputs" : {
"URL" : {
"Description" : "The URL to access RStudio",
"Value" : { "Fn::Join" : [ "", [ "https://", { "Fn::GetAtt" : [ "myELB", "DNSName" ]}]]}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment