I am trying to use a launch template for AWS batch jobs. The user-data template file is:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
--==BOUNDARY==
Content-Type: text/cloud-boothook; charset="us-ascii"
#cloud-boothook
#!/bin/bash
cloud-init-per once docker_options echo 'OPTIONS="$${OPTIONS} --storage-opt dm.basesize=20G"' >> /etc/sysconfig/docker
--==BOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"
packages:
- amazon-efs-utils
runcmd:
- mkdir -p ${efs_directory}
- echo "${efs_id}:/ ${efs_directory} efs _netdev,tls,iam 0 0" >> /etc/fstab
- mount -a -t efs defaults
--==BOUNDARY==--
And the code to generate the user data for a launch template is:
resource "aws_launch_template" "launch_template" {
name = "launch_template"
update_default_version = true
user_data = base64encode(templatefile("${path.module}/launch_template_user_data.tpl", {
efs_id = aws_efs_file_system.efs.id
efs_directory = "/mnt/efs"
}))
}
The rules for a MIME multipart file are:
A MIME multi-part file consists of the following components:
- The content type and part boundary declaration: Content-Type: multipart/mixed; boundary="==BOUNDARY=="
- The MIME version declaration: MIME-Version: 1.0
- One or more user data blocks that contain the following components:
- The opening boundary that signals the beginning of a user data block:
–==BOUNDARY==. You must keep the line before this boundary blank. - The content type declaration for the block: Content-Type:
text/cloud-config; charset="us-ascii". For more information about
content types, see the Cloud-Init documentation. You must keep the
line after the content type declaration blank. - The content of the user data, such as a list of shell commands or
cloud-init directives.
- The opening boundary that signals the beginning of a user data block:
- The closing boundary that signals the end of the MIME multi-part
file: –==BOUNDARY==–. You must keep the line before the closing
boundary blank.
As far as I can tell, I am following these rules. Why is this user data file not a valid MIME multipart file?
2
Answers
Are you trying to create this launch template for AWS Batch? If yes, you will have to tell put the latest version of the launch template at the time of creating AWS Batch compute environment –
I had a similar problem. Try: