oracle-terraform-modules / terraform-oci-compute-instance

Terraform Module for creating Oracle Cloud Infrastructure compute instances
https://registry.terraform.io/modules/oracle-terraform-modules/compute-instance/oci/latest
Other
46 stars 62 forks source link

make cloudinit content easier to pass to instance #74

Open kral2 opened 3 years ago

kral2 commented 3 years ago

Community Note

Description

Currently, cloud-init script content can be passed to an instance using var.user_data. This is in line with the provider argument, but it is not really explicit from a user perspective. Also, the content of user_data needs to be provided in the correct format: a base64-encoded string.

The proposition is to use var.cloud_init_file to provide the content of user_data to oci_core_instance. This would effectively deprecate var.user_data from the module.

Cloud-init files being mostly multi-line, it is probably more easy to restrict the input to be a file, rather than allow for any arbitrary string. Multi-line strings are possible using HEREDOC strings, but it would only add complexity without real benefits for the user.

New or Affected Resource(s)

oci_core_instance

Potential Terraform Configuration

metadata = {
...
user_data = var.cloud_init_file != "disabled" ? "${filebase64(var.cloud_init_file)}" : null
...
}

References

Terraform Filebase64 Function

vadyochik commented 2 years ago

i do really think the proposition is useless and current implementation is totally fine..

what';s wrong with the example you provided in that issue #86 ??

user_data = filebase64(var.some_user_data_variable)

and what do you propose instead of this:

  user_data = base64encode(
    templatefile(
      "${path.module}/cloud-init.sh.tftpl",
      {
        image            = var.image,
        args             = var.image_args,
        vpn_vendor       = var.vpn_vendor,
        vpn_username     = var.vpn_username,
        vpn_password     = var.vpn_password,
      }
    )
  )

??