signaturescience / focustools

Forecasting COVID-19 in the US
https://signaturescience.github.io/focustools/
GNU General Public License v3.0
0 stars 0 forks source link

set up ec2 instance launch template #24

Closed vpnagraj closed 3 years ago

vpnagraj commented 3 years ago

in addition to the bootstrapping (#23) we can / should define the ec2 instance details (instance type, AMI, availability zone, etc) in code.

an example of how to configure launch template from a previous project:

https://github.com/signaturescience/kube#launch

vpnagraj commented 3 years ago

this is all set now.

the workflow to set up / use the launch template:

  1. start an ec2 instance with desired configurations (AMI, instance type, bootsrap script, storage config, IAM role, etc)

  2. get launch template data from running instance and store as json:

aws ec2 get-launch-template-data \
    --instance-id {ID-OF-RUNNING-INSTANCE-HERE} \
    --query "LaunchTemplateData" > launch.json
  1. create a launch template through the API:
aws ec2 create-launch-template \
    --launch-template-name {DESIRED-LAUNCH-TEMPLATE-NAME-HERE} \
    --version-description WebVersion1 \
    --tag-specifications 'ResourceType=launch-template,Tags=[{Key=purpose,Value=production}]' \
    --launch-template-data file://launch.json
  1. stop the original instance

  2. and whenever you want to boot a new instance from launch template:

aws ec2 run-instances --launch-template LaunchTemplateId={ID-OF-LAUNCH-TEMPLATE-DEFINE-ABOVE-HERE} 
stephenturner commented 3 years ago

keeping open, reassigning to me, i want to try this after we submit next week.

vpnagraj commented 3 years ago

right on. keep me posted when you start looking at it. i can walk you through the details (mostly step 1 above). we'll also need to work some IAM magic to make sure the instance you create can read/write to the bucket.

stephenturner commented 3 years ago

Sure thing. I fully anticipate this will take some iteration. Anything involving IAM takes me some iteration.

vpnagraj commented 3 years ago

@stephenturner im triaging your request to test this over to https://github.com/signaturescience/focustools/issues/42

we can focus the conversation over there.