Last active
March 19, 2020 19:07
-
-
Save egafni/cca04b1dab3f1cd16790c8ebd6fa1aaf to your computer and use it in GitHub Desktop.
Create job template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base64 import encodebytes | |
import json | |
name = "pipe-template_v4" | |
user_data=b"""MIME-Version: 1.0 | |
Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" | |
--==MYBOUNDARY== | |
Content-Type: text/x-shellscript; charset="us-ascii" | |
#cloud-boothook | |
#!/bin/bash | |
cloud-init-per once docker_options echo 'OPTIONS="${OPTIONS} --storage-opt dm.basesize=40G"' >> /etc/sysconfig/docker | |
sudo mkfs.xfs /dev/nvme2n1 | |
sudo mkdir /scratch | |
sudo mount /dev/nvme2n1 /scratch | |
--==MYBOUNDARY==--""" | |
d = { | |
"LaunchTemplateName": name, | |
"LaunchTemplateData": { | |
"BlockDeviceMappings": [ | |
{ | |
"DeviceName": "/dev/xvdcz", | |
"Ebs": { | |
"Encrypted": True, | |
"VolumeSize": 50, | |
"VolumeType": "gp2" | |
} | |
} | |
], | |
"UserData": encodebytes(user_data).decode() | |
} | |
} | |
with open('job_template.json', 'w') as fp: | |
json.dump(d, fp=fp) | |
!aws ec2 create-launch-template --cli-input-json file://job_template.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment