awslabs / awslabs/aws-batch-helpers
Add LaunchTemplate Example
- Dominant language
- Python
- Stars
- 134
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
I hope I am in the right place for this comment:
I spent quite a bit of time working to get a aws batch launch template through a cloud formation template. I needed extra data volume on an EC2 instance I was hoping you could add this to as a second example instead of creating a new EC2 instance which is not required when you have LaunchTemplate that can be used in AWS Batch, thankfully!
What was really difficult to figure out was the version on ``` ComputeEnvironment``` ref to the latest LaunchTemplate:
```
SpecialComputeEnvironment:
Type: "AWS::Batch::ComputeEnvironment"
Properties:
Type: MANAGED
ComputeEnvironmentName: !Sub "Special-ComputeEnvironment-${AWS::Region}-1"
ServiceRole: !Ref SpecialServiceRole
ComputeResources:
MaxvCpus: 256
SecurityGroupIds:
- !Ref SecurityGroup
Subnets: !Ref Subnets
Type: EC2
MinvCpus: 0
ImageId: ami-007571470797b8ffa # ami-0a6a36557ea3b9859
InstanceRole: !Ref SpecialInstanceProfile
InstanceTypes:
- optimal
LaunchTemplate:
**LaunchTemplateId: !Ref SpecialComputeLaunchTemplate**
**Version: !GetAtt SpecialComputeLaunchTemplate.LatestVersionNumber**
DesiredvCpus: 0
State: ENABLED
```
And the LaunchTemplates UserData:
```
SpecialComputeLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: "Special-inc-volume-encrypt"
LaunchTemplateData:
BlockDeviceMappings:
- DeviceName: '/dev/sdb' # Amazon ECS-Optimized Amazon Linux 2 ami accepts EDS vol /dev/sd[b-l]
Ebs:
DeleteOnTermination: true
Encrypted: true
VolumeSize: 250
VolumeType: "gp2"
UserData:
"Fn::Base64": !Sub |
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="
--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"
#!/bin/bash
mkfs.ext4 /dev/sdb
(
echo n # Add a new partition
echo p # Primary partition
echo 1 # Partition number
echo # First sector (Accept default: 1)
echo # Last sector (Accept default: varies)
echo w # Write changes
) | fdisk /dev/sdb
mkfs.ext4 /dev/xvdb1
mkdir /data
echo " /dev/xvdb1 /data ext4 defaults 0 2" >> /etc/fstab
mount -a
serSpeciale docker restart
--==MYBOUNDARY==
```
https://github.com/vfrank66/awsbatchlaunchtemplate
Contributor guide
Research direction
Start by comparing the linked awsbatchlaunchtemplate example with the repository's existing AWS Batch examples. No repository file or test is named, so first locate the example or documentation entry point; done means the LaunchTemplate-based configuration is included as a second example and clearly shows the ComputeEnvironment version reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, shell
- Domain
- cloud, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100