DevOps Classroom notes 17/Dec/2023

Dealing with Declarative Languages

  • Any Declartive Language is all about expressing the desired state.
  • Most of the tools in Azure, AWS and DevOps use the following languages primarily for desired state
    • HCL (Hashicorp Configuration Language)
    • Json (ARM Templates, Cloud Formation)
    • Bicep
    • YAML (Ansible, K8s)
  • Our focus is around Infra Provisioning

Datatypes

  • text
  • number
  • boolean
  • list/array
  • map/object
  • Terraform data types: Refer Here
  • map in json
{
    "networkrange": "10.10.0.0/16",
    "subnetcount": 4
}
  • map in terraform
{
    networkrange = "10.10.0.0/16"
    subnetcount = 4
}

Resources

  • The infra we want to create for the application to be deployed
  • ARM Template (json)
{
    "type": "<type>",
    "apiVersion": "2019-06-01",
    "properties": {
         "accessTier": "Hot"
    }

}
  • Cloud formation (json)
"Logical ID" : {
        "Type" : "Resource type",
        "Properties" : {
            Set of properties
        }
    }
  • Example:
"mys3":  {
    "Type": "AWS::S3::Bucket",
    "Properties" : {
        "BucketName" : "idontwants3bucket"
    }

}
  • Cloud formation (yaml)
Logical ID:
  Type: Resource type
  Properties:
    Set of properties
  • Example in yaml
mys3:
  Type: "AWS::S3::Bucket"
  Properties:
    BucketName: "idontwants3bucket"
  • HCL (Terraform)
resource "aws_s3" "mys3" {
    bucket = "idontwants3bucket"
}

Parameters

  • these are the values which can be passed by user during execution. In terraform we refer the same as variable.
  • JSON in ARM Refer Here
"parameters" : {
    "location": {
        "type": "string" //,
        //"allowedValues": ["eastus", "westus"]
        //"defaultValue": "eastus"
    }
}
  • Using this parameter reference in azure "[parameters('location')]"
  • JSON in CF
"Parameters" : {
  "InstanceTypeParameter" : {
    "Type" : "String",
    "Default" : "t2.micro",
    "AllowedValues" : ["t2.micro", "m1.small", "m1.large"],
    "Description" : "Enter t2.micro, m1.small, or m1.large. Default is t2.micro."
  }
}
  • Using this parameter reference in cf {"Ref": "InstanceTypeParameter" }
  • Variable in Terraform
variable "instancetype" {
    type = "string"
    default = "t2.micro"
}
  • Using this varaible reference in terraform var.instancetype

Functions

conditions and loops

Reusability

  • In terraform we create modules
  • Both ARM Templates and Cloud formation supports calling other templates.

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube