Skip to content

Conversation

delagoya
Copy link

@delagoya delagoya commented Nov 8, 2024

Added the launch_template_custom_user_data variable to the metaflow-computation submodule.
Addresses issue #99

@mt-ob
Copy link

mt-ob commented Nov 26, 2024

I wonder if the variable should expect raw string instead? and we can then use terraform's base64encode. function: https://developer.hashicorp.com/terraform/language/functions/base64encode

so, something along the lines of:

variable "launch_template_custom_user_data" {
  type        = string
  description = "Custom user data script for the launch template provided as a string."
  nullable    = true
  default     = null
}

and

resource "aws_launch_template" "cpu" {
    # ... other configuration ...

    user_data = var.launch_template_custom_user_data != null ? base64encode(var.launch_template_custom_user_data) : null
}

One can then supply the variable as:

  launch_template_custom_user_data = <<-EOF
    #!/bin/bash
    echo "Hello, World!"
    yum update -y
  EOF

@delagoya
Copy link
Author

If that makes for a better user experience I think that would be a good change. Will implement and submit a new version after ReInvent.

@delagoya
Copy link
Author

Made the changes in the documentation to note that userdata must be MIME encoded and the ec2.tf will base64 encode if defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants