How to create AWS Keypair using Terraform and attach to EC2 instance | Key to SSH in EC2 server

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • Create AWS Keypair with Terraform tool through this tutorial video to SSH in your EC2 instance. In this demo you will 2 ways to create and attach your AWS keypair using Infrastructure as a code tool TERRAFORM!
    Terraform Documentation link:
    Resource: aws_key_pair: registry.terra...
    tls_private_key:
    registry.terra...
    local_file:
    registry.terra...
    -----------------------------------------------------------------------------------------------------------------------
    #terraform code
    resource "aws_instance" "web" {
    ami = "ami-00ee4df451840fa9d" #Amazon Linux AMI
    instance_type = "t2.micro"
    security_groups = [aws_security_group.TF_SG.name]
    #first method
    key_name = "TF_key"
    tags = {
    Name = "Terraform Ec2"
    }
    }
    #keypair second method for Key_pair
    resource "aws_key_pair" "TF_key" {
    key_name = "TF_key"
    public_key = tls_private_key.rsa.public_key_openssh
    }
    resource "tls_private_key" "rsa" {
    algorithm = "RSA"
    rsa_bits = 4096
    }
    resource "local_file" "TF-key" {
    content = tls_private_key.rsa.private_key_pem
    filename = "tfkey"
    }
    -----------------------------------------------------------------------------------------------------------------------
    Learn How to create EC2 instance in Terraform : • How to create Amazon E...
    Create security group usingTerraform Tool: • How to Create AWS Secu...
    Learn Ansible Tool: • Ansible 101 | Learn An...
    AWS SAA C02 Practice Test: • AWS Certified Solution...
    ------------------------------------------------------------------------------------------------------------------
    Connect with me on LinkedIn for notes : / nasiullha-chaudhari-5a...
    -----------------------------------------------------------------------------------------------------------------
    .
    infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform,key pair terraform aws,key pair terraform aws key,terraform aws key_name,resource key pair,ssh key terraform,terraform ssh key,terraform ssh key ec2,ssh ec2 terraform,aws key using terraform,aws ec2 instance using terraform,aws public key,infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform,key pair terraform aws,key pair terraform aws key,terraform aws key_name,resource key pair,ssh key terraform,terraform ssh key,terraform ssh key ec2,ssh ec2 terraform,aws key using terraform,aws ec2 instance using terraform,aws public key,infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform,key pair terraform aws,key pair terraform aws key,terraform aws key_name,resource key pair,ssh key terraform,terraform ssh key,terraform ssh key ec2,ssh ec2 terraform,aws key using terraform,aws ec2 instance using terraform,aws public key,infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform,key pair terraform aws,key pair terraform aws key,terraform aws key_name,resource key pair,ssh key terraform,terraform ssh key,terraform ssh key ec2,ssh ec2 terraform,aws key using terraform,aws ec2 instance using terraform,aws public key,infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform,key pair terraform aws,key pair terraform aws key,terraform aws key_name,resource key pair,ssh key terraform,terraform ssh key,terraform ssh key ec2,ssh ec2 terraform,aws key using terraform,aws ec2 instance using terraform,aws public key,infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform,key pair terraform aws,key pair key,infrastructure as code,keypair terraform,aws terraform,terraform key pair ec2,terraform key pair module,aws keypair cloudformation,create keypair terraform,create ec2 keypair using terraform,aws ec2 keypair with terraform #awsec2

КОМЕНТАРІ • 115

  • @temitopealuko4848
    @temitopealuko4848 2 роки тому

    I really Learn a lot from your video on Terraform, you really solved my problem. i would really appreciate if you can make a video on "how to create a VPC using Terraform"

    • @cloudchamp
      @cloudchamp  2 роки тому

      Next Video!! Subscribe and Share :)

    • @cloudchamp
      @cloudchamp  2 роки тому

      Checkout the new video!

    • @smartengineer4484
      @smartengineer4484 2 роки тому

      He has made an amazing video on creating vpc using terraform 👍

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

    Just wanted to jump in, I was looking for a quick tutorial on this topic, I rarely use ssh keys any longer just ssm and man did this ever hit the spot. Nice simple to the point. Bravo, great tutorial. Good job.

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

      Glad to hear that it helped. Do share and subscribe ☺️

  • @inthecloud1043
    @inthecloud1043 2 роки тому

    You explain stuff in such an easy manner!!

  • @Pratip.
    @Pratip. Рік тому

    This video has been immensely helpful in creating my terraform file. Thank you.

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

      Glad to know this helped you! Please consider sharing and subscribing 🙏☺️

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

    You are perfect bro and the way to teach everyone is awesome . Great !! go ahead.

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

    Straight to the point! Thank you very much for your videos.

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

      Your welcome 🤗 please subscribe

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

    Hey man! Thanks for your video series.. Amazing.. Short and to the point. Keep up the good work.

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

      Thanks man! Glad you liked it.
      Please share and subscribe if you think it was helpful 🙏

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    Best video on this topic

  • @deepakranjanmishra5641
    @deepakranjanmishra5641 4 місяці тому

    Excellent Explanation

    • @cloudchamp
      @cloudchamp  4 місяці тому

      Glad it was helpful!

    • @deepakranjanmishra5641
      @deepakranjanmishra5641 4 місяці тому

      I have a question below kindly can you give me a solution

    • @deepakranjanmishra5641
      @deepakranjanmishra5641 4 місяці тому

      @@cloudchamp I want to copy the public ssh key of the master machine to the ec2 instance created using terraform.
      Purpose : - To install jenkins on the ec2 using Ansible. ?
      How can i do the same , kindly explain.

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

    You are rocking bro straight to point

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

    Thanks for sharing. need more like this tutorials

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    Very clear explanation

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    Easiest explanation 👍

  • @yashodhanpatil5303
    @yashodhanpatil5303 2 роки тому

    Thanks you sir for the details you covered in this topic

    • @cloudchamp
      @cloudchamp  2 роки тому

      Happy to help. Share and subscribe for more cloud or devops videos :)

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

    You are genius bro!❤ I was following TechWithNana but i had some doubts in that.. then i saw yours.. you are really good at TF

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

      Thank you avant 🤝

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

      @@cloudchamp one doubt I was doing this project on my windows OS. Out tfkey file got created in the Terraform folder, while accessing the server the error: "key is too open" but I didn't get to change the access of that file. I Googled the equivalent of chmod 400, I got the command "icacls /grant: r" but it didn't work at all. Can u please help?

  • @inthecloud1043
    @inthecloud1043 2 роки тому

    Hello champ! Thank you for uploading this video!!

    • @cloudchamp
      @cloudchamp  2 роки тому

      Your welcome 🙏 happy to help

  • @nabichaudhari7536
    @nabichaudhari7536 2 роки тому

    Best Video on this topic 🔥🔥

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

    Thank you for sharing this champ!!

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

    Perfect !! This is exactly what I wanted

  • @ravikirannannaware8421
    @ravikirannannaware8421 2 роки тому

    Very Nice buddy short and precise

    • @cloudchamp
      @cloudchamp  2 роки тому

      Thank You. Happy to help !

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    Best explanation 👍👍👍

  • @azatkhan4714
    @azatkhan4714 2 роки тому

    This helped me today : THANK YOU for you video

    • @cloudchamp
      @cloudchamp  2 роки тому

      You are welcom Azar :) Please subscribe

  • @ayyappaswamy6144
    @ayyappaswamy6144 2 роки тому

    Very clear explanation brother tq so much for this video done

    • @cloudchamp
      @cloudchamp  2 роки тому +1

      Thanks 😊 Happy to help👍

  • @terezabisharyan
    @terezabisharyan 4 місяці тому

    Thank you very much.

  • @TshepoMakhubela-f6z
    @TshepoMakhubela-f6z 7 місяців тому

    Amazing bro!! You're a life saver :)

    • @cloudchamp
      @cloudchamp  7 місяців тому

      Thanks 😊
      Happy to help

  • @singhbrozz1996
    @singhbrozz1996 2 місяці тому

    awesome explanation ! kindly help me where we can use nullresources or what's the use of nullresources?

  • @stas1117
    @stas1117 2 роки тому

    Thanks. Very useful infomation.

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

    Short and perfect!!

  • @madhaiyanm4036
    @madhaiyanm4036 2 роки тому

    Very Good and really useful

    • @cloudchamp
      @cloudchamp  2 роки тому

      Glad to help Madhaiyan :) Do share and subsribe

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

    Thank your for sharing!

  • @Leofmoura87
    @Leofmoura87 2 роки тому

    Thanks, clear explanation!

    • @cloudchamp
      @cloudchamp  2 роки тому

      www.fiverr.com/awscertified/provide-online-training-on-terraform-tool?context_referrer=gig_page&source=other_gigs_by&ref_ctx_id=019524c23995be7949ce87046de7eab5&pckg_id=1&pos=2&seller_online=true&imp_id=525bdb97-34f1-4280-96ee-e987b70d983a

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

    Thank you for sharing this

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    Thank you for sharing this 👍👍

  • @jairoperez6162
    @jairoperez6162 2 роки тому

    Very helpful!!! thanks, my advise for you is to try to speak a liitle slower, since you speak too fast, however everything looks good.

    • @cloudchamp
      @cloudchamp  2 роки тому

      Thanks for the feedback I will try to improve 👍

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

    awesome bro i subscribed

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

      Thank you Chandra 😁 Means a lot! Happy to help

  • @kumarchennaiahboyapati6081
    @kumarchennaiahboyapati6081 2 роки тому +1

    Hello champion, I used the same command that you have used to connect EC2 instance using SSH , however it says connection refused.... could you please explain me why?

    • @cloudchamp
      @cloudchamp  2 роки тому +3

      Check if you have the right key and also check if you have port 22 open in your instance security group :)

  • @deepakranjanmishra5641
    @deepakranjanmishra5641 4 місяці тому

    I want to copy the public ssh key of the master machine to the ec2 instance created using terraform.
    Purpose : - To install jenkins on the ec2 using Ansible. ?
    How can i do the same , kindly explain.

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    Wow 😳

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    👍👍👍👍

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

    When I try to ssh using the 2nd method I get a permission denied (publickey,gssapi-keyex,gssapi-with-mic). Any solutions?

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

      I was able to fix it. I just forgot to generate the public key in the ec2 instance

  • @AeroTechRevolve
    @AeroTechRevolve 10 місяців тому

    the ssh key created isnt linked to the instance created or me..

  • @1423swathi
    @1423swathi Рік тому

    Hi , Is it possible to create the key pair without using private ip and with NAT gateway enabled?

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

      🧐 Keypair has nothing to do with private Ip or NAT gateway.
      Please provide me more information so that I can help you 👍🏻

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

    Hi , in 1.37 minute you opened one console right.. i dont know how to open that specific console. Kindly help me with this.

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

      That’s my Terminal if you are on windows you can use Git bash or vs code for same

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

    Hey can you please provide the git repo of this project I am havind doubts in provider section

  • @Ola-jb1rp
    @Ola-jb1rp Рік тому

    Hi, I tried replicating this, it is requesting for a paraphrase for the key. Could you please explain to me why that happened? Thanks.

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

      You can continue without passphrase, when creating key you get this option?

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

    Your second method is incorrect - it cannot be accessed from outside - locally

  • @nsaneeta
    @nsaneeta 2 роки тому

    Hi, what is the purpose of second method? Is it a security measure?

    • @cloudchamp
      @cloudchamp  2 роки тому

      Both have same security level, the only difference is creating the key pair in the code in the second method whereas in first method we are creating the keypair in the console but attaching it in the code.

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

    can we use YAML instead of JSON in terraform

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

      Terraform neither uses YAML nor JSON but uses similar language called HCL which is Hashicorp configuration Language 👍🏻
      I created a video to teach hcl do check out

  • @nityadeepika1967
    @nityadeepika1967 2 роки тому

    I tried to implement the second method. and I got a few errors. Is it possible to connect one-on-one?

    • @cloudchamp
      @cloudchamp  2 роки тому

      What error are you getting??

    • @nityadeepika1967
      @nityadeepika1967 2 роки тому

      @@cloudchamp I'm unable to login to the EC2.

    • @cloudchamp
      @cloudchamp  2 роки тому

      @@nityadeepika1967 Make sure you have ssh port enabled in security group and keys have right permissions.

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

    I got error while creating keypair

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

      What error did you got ? Send it here , let’s resolve it

  • @bhengee5172
    @bhengee5172 2 роки тому

    Hi
    I'm getting the permission denied error. Please can you help?

    • @cloudchamp
      @cloudchamp  2 роки тому

      Make sure your key has 400 permission. You can change the permission with “chmod 400 keyname”

    • @bhengee5172
      @bhengee5172 2 роки тому

      @@cloudchamp please how do I do that with terraform? My protocol is set to -1 to allow both udp tcp connections. I’m also using a MacBook Pro

    • @cloudchamp
      @cloudchamp  2 роки тому

      @@bhengee5172 it’s the key permission issue make sure you add a null resource to change the permission of the key 400 by running above command.

    • @cloudchamp
      @cloudchamp  2 роки тому

      @@bhengee5172 or just open the terminal go to the folder where your key is and run “chmod 400 👍🏻

  • @syedfahim6652
    @syedfahim6652 8 місяців тому

    Not working

  • @shaikhsupdu-z9g
    @shaikhsupdu-z9g Місяць тому

    after chmod keyname permission denied

  • @nandalgmovie
    @nandalgmovie 2 роки тому

    Very Crispy Short Video

    • @cloudchamp
      @cloudchamp  2 роки тому

      Yeah 😁 but did you understood?

  • @shivasaiprasadbayya8188
    @shivasaiprasadbayya8188 17 днів тому

    ur not champ ur champion

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

    It helps

  • @amaankhan7442
    @amaankhan7442 2 місяці тому

    i wanted to know whats happening here (tls_private_key.rsa.public_key_openssh) what does public_key_openssh means

  • @smartengineer4484
    @smartengineer4484 2 роки тому

    👍👍👍👍