151 episodes

Software Engineering Best Practices, System Design, High Scale, Algorithms, Math, Programming Languages, Statistics, Machine Learning, Databases, Front Ends, Frameworks, Low Level Machine Structure, Papers and Computing, Computer Science Book Reviews - Everything!

Programmers Quickie Software Engineering

    • Technology
    • 4.0 • 4 Ratings

Software Engineering Best Practices, System Design, High Scale, Algorithms, Math, Programming Languages, Statistics, Machine Learning, Databases, Front Ends, Frameworks, Low Level Machine Structure, Papers and Computing, Computer Science Book Reviews - Everything!

    🧐TFIDF - Term Frequency Inverse Document Frequency

    🧐TFIDF - Term Frequency Inverse Document Frequency

    What does term frequency means and what is its relationship with inverse document frequency that we use in order to identify categories of documents and in order to find testament and many more applications of this topic

    • 5 min
    🔥Terraform | init, tags, name, EC2, Security groups, Dynamic Blocks

    🔥Terraform | init, tags, name, EC2, Security groups, Dynamic Blocks

    📚 Book - https://amzn.to/39ty0Tq - "Terraform: Up & Running: Writing Infrastructure as Code"


    Terraform init will download all the dependencies needed by the terraform project like when you have a clean maven project, and running almost any mvn command will pull down the dependencies.
    tags in terraform helps you set the additional tag properties of the resources, if you want to set the name of the resource that would appear in aws then you need to set the tag with specific key and this key is Name actual names of resources, so if you would like to create a vpc resource in aws with name "myvpc" you need to actually set its tags which is different from aws tags you would set the tags { Name = "MyVpc" } and this would set the name of the resource in aws and not the tags in aws.
    Create EC2The terraform name aws_instance
    The 2 mandatory arguments are ami and instance_type
    Example


    resource "aws_instance "MyEc2Instance" {
    ami = "ami_287428346" // some aws ami
    instance_type = "t2.micro"
    }

    Note to reference an id of a terraform instance need to specify ..id so aws_vpc.myvpc.id
    When we set an "aws_eip" which is elastic ip we have to tell it for which ec2 instance we assign it to, so the resource contains the "instance" property that we have to set.
    Aws account can give us up to 5 elastic ips.
    Security group - statefull firewall - stateful means if we allowed some traffic going in it would automatically allow traffic to go out, in stateless we have to set explicitly the input to the firewall and the output.

    resource "aws_security_group" "MySecurityGroup" {
    name = "Allow HTTPS"
    ingress {
    from_port = 443
    to_port = 443 # This is a range of ports from to to is not output.
    protocol = "TCP"
    cird_blocks = ["0.0.0.0/0"] # All traffic.
    }
    egress {

    }
    }
    Then we can reference this MySecurityGroup from various resources such as ec2 instances.


    Dynamic Blocks - iterator, for_each var.mylistvar , content = port.value This allows us to use for_each.prefix the block you want to use the list for each in dynamic example


    variable "ingressrules" { # Here you set the list variable holding the data to be dynamically included.
    type = list(number)
    default = [80, 443]
    }

    dynamic "ingress" { # Now iterate and use the above list defined above.
    iterator = port
    for_each = var.ingressrules
    content {
    from_port = port.value
    }
    }
    Terraform dynamic blocks and security groups definition in Terraform and AWS elastic IP definition in Terraform and EC2 We continue also to investigate what does terraform init means.

    • 8 min
    Aws ElasticIp

    Aws ElasticIp

    AWS elastic IP is not dynamic for itself it's actually a static public IPv4 IP so why is it called elastic because we dynamically assign it to host so if our host or easy to instance is down we can programmatically and dynamically assign such a static public IP into this new host so it's used for resiliency

    • 6 min
    Unresilient World

    Unresilient World

    Unresilient World

    • 5 min
    Terraform Variables

    Terraform Variables

    With terraform we can use variables for example an integer which is defined as a number or a string or a list of strings and then we can reference these variables further down in the code in order to reuse them you can also output variables to the screen and we could also ask the customer to input interactively variable values into the console


    In this session

    - init plan apply destroy
    - state file
    - variables


    - terraform pattern consistent
    - resource keyword
    - resource identifier "aws_vpc"
    - our name "mypc"
    - in curly braces the parametesrs like cidr_block = "10.0.0.0/16"


    - `terraform init`
    - i's like mvn install
    - Download the plugins to use aws
    - We can run this command after created main.tf
    - pull down modules

    - `terraform plan`
    - will show what's its going to do
    - checks state
    - Get developer style diff before commit
    - What already created which diff
    - don't want to loose this state file

    - `terraform apply`
    - showing the diff
    - click `yes` to continue
    - resources created in aws!

    - `terraform destroy`
    - to delete all reources
    - confirm

    - `state file` `terraform.tfstate`
    - we can see locally all that we created with terraform!
    - this file will have ALL resources created by terraform
    - visibility!
    - we want this file to get missing
    - json format
    - .bak
    - track changes we made
    - used for diff


    # Variables

    - define variables
    - folder `variables`
    - `default` is like the value
    - we have `type` and then `default` for default value
    - `main.tf` create file in that folder
    ```json
    variable "vpcname" {
    type = string (or number boolean list(string) with values ["val1", "val2"] to access 1 [0])
    default = "myvpc"
    }

    variable "mymap" {
    type = map
    default = {
    key1 = "value1"
    key2 = "value2"
    }
    }

    variable "mytuple" {
    type tuple([string, number, string])
    default = ["mystr1", 45, "mystr2"]
    }

    variable "myobject" {
    type = object({name = string, port = number})
    default {
    name = "myval1"
    default = "232"
    }
    }
    ```
    - cidr_range would get used multiple times so just put it in var

    - use variables
    - `var.myvarname` can also be done with string interpolation
    - `var.mylist[0]`
    - `var.mymap["Key1"]`

    - interactive input variables
    ```json
    variable "inputname" {
    type = string
    description = "please enter value for input name"
    }
    ```

    next use this
    - `var.inputname` as usuall
    - `terraform plan` will now ask to input the input vars values


    # Outputs

    ```json
    output "myoutput" {
    value = aws_vpc.myvpc.id
    }
    ```

    so nw we can print the dynamic id we get when we run terraform.

    run `terraform plan` will not print the id as it's created only after the apply is run and resources actually run.

    • 9 min
    Terraform Main Operations and state file

    Terraform Main Operations and state file

    Terraform main operations such as init plan apply and destroy and the state file telephone is a infrastructure as code tool a command line to help us create infrastructure with standard adjacent files and then run telephone apply in order to actually create this infrastructure either in AWS cloud or Google cloud or azure cloud or any other cloud provider even locally and it has many plugins.



    In this session


    init plan apply destroy
    state file
    variables
    terraform pattern consistentresource keyword
    resource identifier "aws_vpc"
    our name "mypc"
    in curly braces the parametesrs like cidr_block = "10.0.0.0/16"

    terraform initi's like mvn install
    Download the plugins to use aws
    We can run this command after created main.tf
    pull down modules

    terraform planwill show what's its going to do

    checks stateGet developer style diff before commit
    What already created which diff
    don't want to loose this state file

    terraform applyshowing the diff
    click yes to continue
    resources created in aws!

    terraform destroyto delete all reources
    confirm

    state file terraform.tfstatewe can see locally all that we created with terraform!
    this file will have ALL resources created by terraform
    visibility!
    we want this file to get missing
    json format
    .bak
    track changes we made
    used for diff




    Terraform main operations and components are:



    - [1] init [2] plan [3] apply [4] destroy

    - State files

    - variables





    - terraform pattern consistent

    - resource keyword

    - resource identifier "aws_vpc"

     - our name "mypc"

     - in curly braces the parametesrs like cidr_block = "10.0.0.0/16"





    - `terraform init`

     - i's like mvn install

     - Download the plugins to use aws

     - We can run this command after created main.tf

     - pull down modules



    - `terraform plan`

     - will show what's its going to do

     - checks state

       - Get developer style diff before commit

       - What already created which diff

       - don't want to loose this state file



    - `terraform apply`

     - showing the diff

     - click `yes` to continue

     - resources created in aws!



    - `terraform destroy`

     - to delete all reources

     - confirm



    - `state file` `terraform.tfstate`

     - we can see locally all that we created with terraform!

     - this file will have ALL resources created by terraform

     - visibility!

     - we want this file to get missing

     - json format

     - .bak

     - track changes we made

     - used for diff

    • 5 min

Customer Reviews

4.0 out of 5
4 Ratings

4 Ratings

Top Podcasts In Technology

Lex Fridman
Jason Calacanis
Jack Rhysider
NPR
Recode & The Verge
The Verge

You Might Also Like

CodeNewbie
Michael Kennedy and Brian Okken
Roman Mars
Bloomberg
Lex Fridman