philanderson888 / scripts

MIT License
0 stars 0 forks source link

Terraform Basics #1

Open philanderson888 opened 2 months ago

philanderson888 commented 2 months ago

Just getting to grip with terraform

from what I can see it enables us to set infrastructure as code so we can define an environment according to a given plan and let terraform ensure the infrastructure meets the plan requirements ...

philanderson888 commented 2 months ago

latest commits on the matter

1) upgrades to docker 2) upgrades to terraform - removing errors 3) ansible removing ssh requirements for trivial commands eg ping another machine

commit here

https://github.com/philanderson888/scripts/commit/eea17738ac62c214d2188c18e4877e94822d1e6b

philanderson888 commented 2 months ago

Master Script is here (running in Azure)

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/scriptMasterWindows.sh

install docker

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/scriptMasterWindows.sh#L743

running docker - seems OK

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-out-put-2024-04-28.txt#L2032

install terraform

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/scriptMasterWindows.sh#L762

terraform script is here

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-52-terraform.zsh

terraform yaml 1

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-52-terraform.tf

just running some trivial commands

resource "null_resource" "default" {
  provisioner "local-exec" {
    command = "echo 'Hello World' && pwd && whoami && ping -c 4 127.0.0.1"
  }
}

getting OK output though

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-out-put-2024-04-28.txt#L2219

terraform initialise

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-out-put-2024-04-28.txt#L2219

terraform apply

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-out-put-2024-04-28.txt#L2219

terraform yaml 2

installs a docker container running nginx then runs it

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-52-terraform-main.tf

verify the container is working by doing a curl command against localhost:8000 and getting the nginx default web page as a response, so we know this is working

output

create docker container

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-out-put-2024-04-28.txt#L3239

nginx output

https://github.com/philanderson888/scripts/blob/master/aws/awsWindows/script-out-put-2024-04-28.txt#L3245

spent 5 to 6 hours on this work this week, super happy the way it's going :)

philanderson888 commented 2 months ago

over to you for comments

philanderson888 commented 2 months ago

thanks