Terraform: Difference between revisions

From Halfface
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 18: Line 18:
Show more info about individual entity.
Show more info about individual entity.
  terraform state show openstack_networking_network_v2.net3
  terraform state show openstack_networking_network_v2.net3
Import state
terraform import module.kafka_eks.kubernetes_manifest.configmap_kafka_akhq "apiVersion=v1,kind=ConfigMap,namespace=kafka,name=akhq"
terraform import module.kafka_eks.helm_release.akhq kafka/akhq
Name of statefile
terraform.tfstate
=plan=
=plan=
Creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.
Creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.
Line 27: Line 33:
  TF_LOG=trace terraform init
  TF_LOG=trace terraform init
  TRACE DEBUG INFO WARN ERROR
  TRACE DEBUG INFO WARN ERROR
=terraform output=
Reads and output variable from a Terraform state file
=cloud-init=
==set password on user==
ssh_pwauth: false
chpasswd:
  expire: false
  users:
    - name: root
      password: password
      type: text
=tofu=
Apply without asking.
tofu apply -auto-approve
destroy without asking
tofu destroy -auto-approve

Latest revision as of 13:10, 16 May 2024

install terraform

sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
sudo dnf install terraform

Hardcoded install

cd /tmp/ ; curl -sk -L https://releases.hashicorp.com/terraform/1.5.5/terraform_1.5.5_linux_amd64.zip -O ; cd /usr/bin/ ; sudo unzip /tmp/terraform_1.5.5_linux_amd64.zip

file completion

complete -C /usr/bin/terraform terraform

Remove terraform infrastructure

terraform destroy

show

Show what has been done.

terraform show

state

list resources within a Terraform state.

terraform state list

Show more info about individual entity.

terraform state show openstack_networking_network_v2.net3

Import state

terraform import module.kafka_eks.kubernetes_manifest.configmap_kafka_akhq "apiVersion=v1,kind=ConfigMap,namespace=kafka,name=akhq"
terraform import module.kafka_eks.helm_release.akhq kafka/akhq

Name of statefile

terraform.tfstate

plan

Creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.

terraform plan

apply

Performs a plan just like terraform plan does, but then actually carries out the planned changes to each resource using the relevant infrastructure provider's API.

terraform apply

debug

TF_LOG=trace terraform init
TRACE DEBUG INFO WARN ERROR

terraform output

Reads and output variable from a Terraform state file

cloud-init

set password on user

ssh_pwauth: false
chpasswd:
  expire: false
  users:
    - name: root
      password: password
      type: text

tofu

Apply without asking.

tofu apply -auto-approve

destroy without asking

tofu destroy -auto-approve