stanleyuan / terrafrom_practice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terrafrom Practice

Practice terraform with aws

Syntax

resource "aws_vpc" "main" {
  cidr_block = var.base_cidr_block
}

<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" {
  # Block body
  <IDENTIFIER> = <EXPRESSION> # Argument
}

depends_on

depends_on argument is accepted by any resource and accepts a list of resources to create explicit dependencies for.

Commands

terraform init

It initializes various local settings and data that will be used by subsequent commands and automatically downloads and installs any Provider binary for the providers in use within the configuration

terraform apply

It shows the execution plan, describing which actions Terraform will take in order to change real infrastructure to match the configuration.

If the plan was created successfully, Terraform will now pause and wait for approval before proceeding. If anything in the plan seems incorrect or dangerous, it is safe to abort here with no changes made to your infrastructure. In this case the plan looks acceptable, so type yes at the confirmation prompt to proceed.

terraform apply \
  -var 'access_key=foo' \
  -var 'secret_key=bar'
terraform show

It inspects the current state

terraform destroy

It behaves as if all of the resources have been removed from the configuration.

terraform output

Outputs are a way to tell Terraform what data is important. This data is outputted when apply is called, and can be queried using the terraform output command.

Resource

About


Languages

Language:HCL 100.0%