Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use the user_data? #86

Open
has12zen opened this issue Jan 3, 2022 · 1 comment
Open

how to use the user_data? #86

has12zen opened this issue Jan 3, 2022 · 1 comment
Labels
question Further information is requested

Comments

@has12zen
Copy link

has12zen commented Jan 3, 2022

can you provide an example cloud-init-file and shell script and how to use it in user_data?
I have created an example repo: https://github.com/has12zen/terraform-oci-compute-instance
please can you help me.

@has12zen has12zen added the question Further information is requested label Jan 3, 2022
@kral2
Copy link
Contributor

kral2 commented Jan 3, 2022

Hi @has12zen

This is how you tell compute-instance module to inject a file using user_data module argument:

# declare a Variable Input to be used as a module argument and assign it a value
variable "some_user_data_variable" {
  description = "provide a shell script or Cloud-Init configuration file to be passed to a compute instance to be executed at instance's first boot" 
  type = string
  default = "path/to/your/file"
}

# declare your module using the variable you just created
module "a_compute_instance" {
  source  = "oracle-terraform-modules/compute-instance/oci"
  version = "2.3.0"
  ... // insert all required arguments
  user_data = filebase64(var.some_user_data_variable) // add `user_data` argument
}

You can have a look at https://github.com/kral2/iacbox to see how it can be used in a real Terraform configuration. Pay attention particularly to these lines:

The file type will be automatically detected and then executed by Cloud-Init, whether it is a shell script or a cloud-init configuration. No additional configuration needed.

I will probably update #74 to include examples in the module's repo. In the meantime, this issue should provide the necessary guidance to use the existing feature.

Please feel free to additional feedback if you think you are still missing something to use this feature 👍

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

No branches or pull requests

2 participants