Monday, August 13, 2018

AWS - Terraform Short Notes


1. Authenticating & Authorising AWS User for using terraform 

 AWS User - > Give Policy -> Credentials download -> Pass credentials in terraform

* You can do it in two ways
    a) As a provider
    b) Directly export AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY

2. Creating EC2 instance: -
     terraform init - Should run when created a new terraform file / cloning one from git. Safe to run multiple times. Will make the current terraform WD up-todate.
     terraform plan  - will create the AWS instance plan
     terraform apply - will create the AWS instance ( if you make a change once you execute plan & apply commands now you want to change an existing iname of the EC2 instance do it and just use "terraform apply ")

3. Removing the EC2 instance:-
     terraform destroy

4. Printing Output Variable

      output "my_public_id"{
      value="${aws_instance.dimuthu.public_ip}"
     }

5. Creating security groups
    * When creating security groups point to ponder is to you need to :
            1. Create the security group
            2. Add a policy to security group

So lets create a Bastion Host Security Group - The only host expose to outside world which filters malicious attacks. Places probably between one / two firewalls.

Ingress traffic - Data from outside is transferred to local network.
Egress traffic - Data inside the local network is transferred  to outside world.

     resource "aws_security_group" "default" {
     name= "My_Security_Group1"
     }

No comments:

Post a Comment