Terraform Operations: Difference between revisions
Jump to navigation
Jump to search
Line 25: | Line 25: | ||
Formats all .tf in the current directory. Formatting enables standardization. | Formats all .tf in the current directory. Formatting enables standardization. | ||
=Apply= | |||
terraform apply | |||
<syntaxhighlight lang='text'> | |||
provider.aws.region | |||
The region where AWS operations will take place. Examples | |||
are us-east-1, us-west-2, etc. | |||
Enter a value: us-west-2 | |||
An execution plan has been generated and is shown below. | |||
Resource actions are indicated with the following symbols: | |||
+ create | |||
Terraform will perform the following actions: | |||
# aws_instance.terraform-test-01 will be created | |||
+ resource "aws_instance" "terraform-test-01" { | |||
+ ami = "ami-a6faba49dddaecfb7" | |||
+ arn = (known after apply) | |||
+ associate_public_ip_address = (known after apply) | |||
+ availability_zone = (known after apply) | |||
+ cpu_core_count = (known after apply) | |||
+ cpu_threads_per_core = (known after apply) | |||
+ get_password_data = false | |||
+ host_id = (known after apply) | |||
+ id = (known after apply) | |||
+ instance_state = (known after apply) | |||
+ instance_type = "m5.4xlarge" | |||
+ ipv6_address_count = (known after apply) | |||
+ ipv6_addresses = (known after apply) | |||
+ key_name = (known after apply) | |||
+ network_interface_id = (known after apply) | |||
+ password_data = (known after apply) | |||
+ placement_group = (known after apply) | |||
+ primary_network_interface_id = (known after apply) | |||
+ private_dns = (known after apply) | |||
+ private_ip = (known after apply) | |||
+ public_dns = (known after apply) | |||
+ public_ip = (known after apply) | |||
+ security_groups = (known after apply) | |||
+ source_dest_check = true | |||
+ subnet_id = (known after apply) | |||
+ tenancy = (known after apply) | |||
+ volume_tags = (known after apply) | |||
+ vpc_security_group_ids = (known after apply) | |||
+ ebs_block_device { | |||
+ delete_on_termination = (known after apply) | |||
+ device_name = (known after apply) | |||
+ encrypted = (known after apply) | |||
+ iops = (known after apply) | |||
+ kms_key_id = (known after apply) | |||
+ snapshot_id = (known after apply) | |||
+ volume_id = (known after apply) | |||
+ volume_size = (known after apply) | |||
+ volume_type = (known after apply) | |||
} | |||
+ ephemeral_block_device { | |||
+ device_name = (known after apply) | |||
+ no_device = (known after apply) | |||
+ virtual_name = (known after apply) | |||
} | |||
+ network_interface { | |||
+ delete_on_termination = (known after apply) | |||
+ device_index = (known after apply) | |||
+ network_interface_id = (known after apply) | |||
} | |||
+ root_block_device { | |||
+ delete_on_termination = (known after apply) | |||
+ encrypted = (known after apply) | |||
+ iops = (known after apply) | |||
+ kms_key_id = (known after apply) | |||
+ volume_id = (known after apply) | |||
+ volume_size = (known after apply) | |||
+ volume_type = (known after apply) | |||
} | |||
} | |||
Plan: 1 to add, 0 to change, 0 to destroy. | |||
Do you want to perform these actions? | |||
Terraform will perform the actions described above. | |||
Only 'yes' will be accepted to approve. | |||
Enter a value: yes | |||
aws_instance.terraform-test-01: Creating... | |||
aws_instance.terraform-test-01: Still creating... [10s elapsed] | |||
aws_instance.terraform-test-01: Still creating... [20s elapsed] | |||
aws_instance.terraform-test-01: Creation complete after 24s [id=i-afbbc2c4a789ab871] | |||
</syntaxhighlight> |
Revision as of 20:54, 13 November 2019
Internal
Version
terraform version
Help
terraform --help terraform <command> --help
Initialization
The initialization operation initializes various local settings that will be used by subsequent commands. The command also downloads provider binaries. The command needs to be re-run if new modules are set or changed, or backend configuration changes.
terraform init
The command creates a .terraform directory, which contains a "plugins" sub-directory.
Configuration File Formatting
terraform fmt
Formats all .tf in the current directory. Formatting enables standardization.
Apply
terraform apply
provider.aws.region
The region where AWS operations will take place. Examples
are us-east-1, us-west-2, etc.
Enter a value: us-west-2
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_instance.terraform-test-01 will be created
+ resource "aws_instance" "terraform-test-01" {
+ ami = "ami-a6faba49dddaecfb7"
+ arn = (known after apply)
+ associate_public_ip_address = (known after apply)
+ availability_zone = (known after apply)
+ cpu_core_count = (known after apply)
+ cpu_threads_per_core = (known after apply)
+ get_password_data = false
+ host_id = (known after apply)
+ id = (known after apply)
+ instance_state = (known after apply)
+ instance_type = "m5.4xlarge"
+ ipv6_address_count = (known after apply)
+ ipv6_addresses = (known after apply)
+ key_name = (known after apply)
+ network_interface_id = (known after apply)
+ password_data = (known after apply)
+ placement_group = (known after apply)
+ primary_network_interface_id = (known after apply)
+ private_dns = (known after apply)
+ private_ip = (known after apply)
+ public_dns = (known after apply)
+ public_ip = (known after apply)
+ security_groups = (known after apply)
+ source_dest_check = true
+ subnet_id = (known after apply)
+ tenancy = (known after apply)
+ volume_tags = (known after apply)
+ vpc_security_group_ids = (known after apply)
+ ebs_block_device {
+ delete_on_termination = (known after apply)
+ device_name = (known after apply)
+ encrypted = (known after apply)
+ iops = (known after apply)
+ kms_key_id = (known after apply)
+ snapshot_id = (known after apply)
+ volume_id = (known after apply)
+ volume_size = (known after apply)
+ volume_type = (known after apply)
}
+ ephemeral_block_device {
+ device_name = (known after apply)
+ no_device = (known after apply)
+ virtual_name = (known after apply)
}
+ network_interface {
+ delete_on_termination = (known after apply)
+ device_index = (known after apply)
+ network_interface_id = (known after apply)
}
+ root_block_device {
+ delete_on_termination = (known after apply)
+ encrypted = (known after apply)
+ iops = (known after apply)
+ kms_key_id = (known after apply)
+ volume_id = (known after apply)
+ volume_size = (known after apply)
+ volume_type = (known after apply)
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_instance.terraform-test-01: Creating...
aws_instance.terraform-test-01: Still creating... [10s elapsed]
aws_instance.terraform-test-01: Still creating... [20s elapsed]
aws_instance.terraform-test-01: Creation complete after 24s [id=i-afbbc2c4a789ab871]