How to use user_data in Terraform? - Part-23

Поділитися
Вставка
  • Опубліковано 19 вер 2024

КОМЕНТАРІ • 47

  • @thamizharasanrp7404
    @thamizharasanrp7404 Рік тому +1

    Thanks Rahul . Just file function used to execute the script inside the EC2 instance . where file provisioner is used to just copy the files.

  • @vishnuvardhan-zr1vy
    @vishnuvardhan-zr1vy Рік тому +3

    Hi Bro, your videos too good, very informative, please do videos on Devops tools also

  • @lakerfan4life308
    @lakerfan4life308 20 днів тому

    Thanks for the video. It's clear and understandable. Is it also possible to pass a powershell script. eg. ps1 In place of the .sh in your video demonstration?

  • @rajivverma4338
    @rajivverma4338 Рік тому +1

    but we can do the same using remote-exec also right ? where my script having installation step will be executed while setting up EC2 instance .. can you please clarify ?

    • @RahulWagh
      @RahulWagh  Рік тому

      Here is my answer
      Terraform's user_data argument allows you to provide data to the instance at launch time, typically used to run scripts or set configuration on the instance. This data is passed to the instance in the form of a script, which is executed by the cloud-init process on the instance.
      The remote-exec provisioner in Terraform allows you to execute commands on a running resource after it has been created. This can be useful for running scripts or making configuration changes on the instance after it has been launched. Unlike user_data, the remote-exec provisioner requires a connection to the running instance in order to execute commands.
      In summary, user_data is used to configure the instance at launch time and remote-exec is used to configure the instance after it has been launched.

    • @AbhishekAAmle
      @AbhishekAAmle Рік тому

      @@RahulWagh , Thanks for Terraform series. But, I am also bit confused between files, remote_exec and user_data. Could you please help us to differentiate between them, when to use them

  • @happylearningtricks
    @happylearningtricks Рік тому

    Excellent explanation - thank you

  • @narendernls
    @narendernls Місяць тому

    How we can use user_data for for window instance. I am trying to create directory and pull the zip file from s3 to new instance the user data is not working. Please help

  • @abc-cg2pi
    @abc-cg2pi 11 місяців тому

    I have a question that if the ec2 instance located in a private subnet without a public ip, it seems user_data does not execute the script.

    • @RahulWagh
      @RahulWagh  11 місяців тому

      No user_data should always work irrespective of public and private subnet. May you are trying to access the ec2 present in the private subnet from outside of awe ?

  • @dannotes9396
    @dannotes9396 Рік тому

    Hello Rahul, thanks for the video.
    One quick question how we can achieve restart and resume in terraform along with this?
    e
    like I have to install IIS feature and do restart. then proceed to deploy application. Any thoughts? would be appreciated. Thank you

  • @karimelbawab2897
    @karimelbawab2897 Рік тому +1

    Amazing, that was really helpful, thank you (Y)

  • @vamsiniit
    @vamsiniit Рік тому

    Hi Rahul,
    First of all I would like say Thanks to you, for such a wonderful terraform series you made and sharing in public, Thanks alot.
    I have one query, while spin up virtual machine does the ssh keys could save automatically in key vault? Is there any possibilities? Off course I'm spinning up vms through IAC (terraform).

    • @RahulWagh
      @RahulWagh  Рік тому

      No SSH keys does not get save automatically in vault you have to handle it manually

  • @usheeg
    @usheeg Рік тому

    Hey rahul, the apache2 was only able to work on port 80, not port 443. I tried so many ways yet It would not work and I did follow every single step of yours.

  • @pranavraj4145
    @pranavraj4145 Рік тому

    Hi @rahul
    Person having 3+ IT experience ,planning to switch domain to DevOps ,if he refers and practice all this 23 part session will it be sufficient?

    • @RahulWagh
      @RahulWagh  Рік тому

      Devops is too big to cover in 23 sessions but I promise these sessions will help you get started and put in a commanding situation to tackle new things

  • @vishnuvardhan-zr1vy
    @vishnuvardhan-zr1vy Рік тому

    Good session

    • @RahulWagh
      @RahulWagh  Рік тому +1

      Glad to know it is helpful for you

  • @shayelasharma1039
    @shayelasharma1039 Рік тому

    Hi , when I run a script it is getting executed as root user using user_data on new instance, is there any way I can execute as normal user.?

  • @akhilarora3458
    @akhilarora3458 Рік тому +1

    please add terraform functions like demostrate Terraform functions and use case as well

    • @RahulWagh
      @RahulWagh  Рік тому

      Surely i will add to my todo list

  • @madhavprajapati4313
    @madhavprajapati4313 Місяць тому

    how to use variables in AWS EC2 userdata when deploying with terraform

  • @aashishsharma5482
    @aashishsharma5482 Рік тому

    Sir these 23 videos of terraform is more than enough for fresher to crack the interview??????
    Please reply sir , as I am a fresher I want to add terraform in my resume...

  • @satyasahani5785
    @satyasahani5785 Рік тому +1

    I learn promotheus from your website's jhook

    • @RahulWagh
      @RahulWagh  Рік тому

      I am really glad to know that jhooq helped you to learn Prometheus

  • @kishorek2628
    @kishorek2628 Рік тому

    Hi Rahul Did you teach Terraform?

  • @dnayak1203
    @dnayak1203 Рік тому

    HyRahul. Is it a complete terraform playlist or more videos to come.

    • @RahulWagh
      @RahulWagh  Рік тому

      For getting yourself started with terraform this series is more then enough.
      But there will be more similar sessions in upcoming weeks

  • @satyasahani5785
    @satyasahani5785 Рік тому +1

    Please can you make video on k8s deployments cicd Gitlab on aws eks

    • @RahulWagh
      @RahulWagh  Рік тому +1

      I can add into my list of todo hopefully I will prepare something around it soon

    • @satyasahani5785
      @satyasahani5785 Рік тому

      @@RahulWagh please do , thanks

  • @vishnu-lz9pm
    @vishnu-lz9pm 6 місяців тому

    My doubt is how do i pass both the file and script. I requirement to install nginx and add some configuration for the upstream servers. How can i achieve that? @RahulWagh

    • @RahulWagh
      @RahulWagh  6 місяців тому

      You can not pass both script and file using user-data.
      Use user-data only for script part and file provisioners for file transfer

    • @vishnu-lz9pm
      @vishnu-lz9pm 6 місяців тому

      @@RahulWagh Thanks for your reply. But, fortunately I found the below config working.
      user_data = /tmp/default
      < some shell scripts >
      EOF
      Would like to know if the same works for you. Just my curiosity 😄

  • @srgrmohan
    @srgrmohan Рік тому

    Hi bro, your videos are awesome
    I have one doubt considering the scenario one client wants eks managed node and another one client wants self managed node before terraform apply user wants to decide which node you want to create , all should be in module
    Give me some examples about this

    • @RahulWagh
      @RahulWagh  Рік тому +2

      For self managed nodes you need to rely on user_data module so that you can write the script to provision the self managed nodes .
      But for eka managed nodes I guess there should terraform HCL which you can use to provision here is the reference- registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group

    • @RahulWagh
      @RahulWagh  Рік тому +1

      It is hard to explain everything in comments

    • @srgrmohan
      @srgrmohan Рік тому

      @@RahulWagh thank you for your response anyway when you got time you can make separate video for this

  • @mykolaskucinskas9473
    @mykolaskucinskas9473 Рік тому

    Thanks for showing how to insert user_data using file() function in Terraform. For some reason just writing it using 'EOF' did not work for me, some nonsense error was thrown in the logs that I did not declare Shebang symbol, even though it existed.

  • @akhilarora3458
    @akhilarora3458 Рік тому

    Please make video and use case on gitlabs or argoCD to deploy application on GCP thanks

  • @taniaduggal6459
    @taniaduggal6459 Рік тому +1

    How many concepts/videos are left to complete terraform playlist

    • @RahulWagh
      @RahulWagh  Рік тому

      All the 23 videos on terraform are sufficient enough for you to start working on terraform. But there is as such no number because still there are a lot of topics which can be documented on terraform

    • @taniaduggal6459
      @taniaduggal6459 Рік тому

      @Rahul Wagh is it sufficient to sit in an interview?