How to Automate Infrastructure setup using Terraform & Jenkins | Terraform Remote State Store in S3

Sdílet
Vložit
  • čas přidán 29. 08. 2024
  • www.coachdevop...
    We will be learning how to provision resources in AWS cloud using Terraform and Jenkins. We will also learn how to store terraform state info remotely in AWS S3 bucket.
    We will create S3 bucket for storing terraform state info and DynamoDB table for locking capability.
    We will try to create an EC2 instance and S3 Bucket using Terraform and Jenkins in AWS cloud. Look at the diagram that describes the whole flow.
    Pre-requistes:
    Create S3 bucket for storing TF state
    Create dynamo DB table for providing lock capability
    Jenkins is up and running
    Terraform is installed in Jenkins
    Terraform files already created in your SCM
    Make sure you have necessary IAM role created with right policy and attached to Jenkins EC2 instance.
    Step 1 - Create S3 bucket and DynamoDB table in AWS
    Step 2 - Create IAM role with three policies mentioned and attach to Jenkins EC2
    Step 3 - Create Jenkins pipeline with parameters
    Step 4- Execute pipeline

Komentáře • 19

  • @sreekanthreddyb
    @sreekanthreddyb Před 4 měsíci +1

    Hi, Can you please list down some common error we face while working with Terraform and Jenkins in real time.

    • @DevOpsCoach
      @DevOpsCoach  Před 4 měsíci +1

      We can’t generalize that. Terraform State file need to be kept in a remote place. You may have terraform state file locked error when some errors happen during terraform apply

  • @ibmuser13
    @ibmuser13 Před 6 měsíci

    Great video sir. What is the use of dynamoDB here? If you could briefly explain?

    • @DevOpsCoach
      @DevOpsCoach  Před 6 měsíci +1

      DynamoDB is used for exclusive locking to prevent concurrent executions from modifying the same state simultaneously.

  • @tippeshtg6088
    @tippeshtg6088 Před rokem +1

    Hii , i am getting error in Plan stage , (Error acquiring the state lock) , Solutions for this? , Wts wrong?

  • @raghunandanp7373
    @raghunandanp7373 Před rokem +1

    is it neccessary to have linux installed in our system to run this? because in my windows built in node , the sh is not recognising terraform init command

    • @DevOpsCoach
      @DevOpsCoach  Před rokem

      you can do it by installing Git or Cygwin.. check the below link
      stackoverflow.com/questions/30374998/run-a-command-shell-in-jenkins

  • @roopamgaikar8836
    @roopamgaikar8836 Před rokem

    Where did you do the authentication for AWS and Jenkins as in access and secret keys?

    • @DevOpsCoach
      @DevOpsCoach  Před rokem +1

      You can use IAM role that’s is more preferred as I have installed on Jenkins running on aws itself

  • @S0912S
    @S0912S Před rokem

    while checking out, I am getting error. Failed to connect to repository : Error performing git command: git ls-remote -h . Any resolution on this? my inbound and outbound traffic is set to everywhere while trying to resolve it.

    • @DevOpsCoach
      @DevOpsCoach  Před rokem

      Did you fork my repo?

    • @S0912S
      @S0912S Před rokem

      @@DevOpsCoach I did but turned out it was some issue with the plugin. post reinstallation it worked fine.

    • @S0912S
      @S0912S Před rokem +1

      @@DevOpsCoach thank you

    • @S0912S
      @S0912S Před rokem

      @@DevOpsCoach but for some reason my tf file wouldnt get update to s3 bucket, and created a lock file issue. for now, ignored it to complete the infra, but working on it to find the fix

    • @ketanmorey1953
      @ketanmorey1953 Před rokem

      @@S0912S have u fixed the lock issue

  • @MrNNAVNEET
    @MrNNAVNEET Před rokem +1

    kindly use mic . very very less audible

    • @ibmuser13
      @ibmuser13 Před 6 měsíci

      perfectly audible to me! Keep up the great work @DevOpsCoach

  • @GopalRoy-nn6ft
    @GopalRoy-nn6ft Před rokem

    repo link ?

    • @DevOpsCoach
      @DevOpsCoach  Před rokem

      github.com/akannan1087/myInfra2021Repo