Terraform

 Provider Plugins :- A provider is a plugin that lets Terraform manage an external API.


When we run terraform init, plugins required for the provider are automatically downloaded and saved locally to a .terraform directory 


Resource :- Resource block describe one or more infrastructure objects 


Resource Blocks :- A resource block declares a resource of a given type(“aws_instance”) with a given local name (“myec2”). 


Resource type and Name together serve as an identifier for a given  resource and so must be unique. 



Provider Maintainers


There are 3 primary type of provider tiers in Terraform. 

 Namespaces are used to help users identify the organization or publisher responsible for the integration. 

Provider Tiers Description Namespaces

Official 

Owned and maintained by Hashicorp.


Ex. Azure, AWS, GCP, Kubernetes

Hashicorp

Partner Owned and maintained by Technology company that maintains direct partnership with hashicorp. Third party organization eg.


Mongodb/mongodbatlas

Community Owned and Maintained by Individual Contributors Maintainers individual or organization account, eg. DeviaVir/gsuite



Terraform requires explicit source information for any providers that are not hashicorp-maintained, using a new syntax in the required_providers nested block inside the terraform configuration block 

   


Azure maintained by hashicorp 



 


Ali cloud maintained by official partner 


Terraform destroy :   allow us to destroy all the resource that are created within the folder. 

Approach 2 – Destroy Some 

Terraform destroy with -target flag allows us to destroy specific resource. 

Terraform destroy – target aws_instance.myec2 


Combination of : Resource type + Local Resource Name 


  Resource Type Local Resource Name

Aws_instance Myec2

Github_repository example



  AWS Github example 

resource "aws_instance" "myec2" {

    ami = "ami-00c39f71452c08778"

    instance_type = "t2.micro"

} resource "github_repository" "example" {

  name        = "example"

  description = "My awesome codebase"

  visibility = "public"


}



Comments

Popular posts from this blog

Script

Landing Zone

Migration