Open mnguyen92646 opened 1 year ago
MNMBP:one-server minguyen$ terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
resource "aws_instance" "example" {
ami = "ami-0fb653ca2d3203ac1"
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)
disable_api_termination = (known after apply)
ebs_optimized = (known after apply)
get_password_data = false
host_id = (known after apply)
id = (known after apply)
instance_initiated_shutdown_behavior = (known after apply)
instance_state = (known after apply)
instance_type = "t2.micro"
ipv6_address_count = (known after apply)
ipv6_addresses = (known after apply)
key_name = (known after apply)
monitoring = (known after apply)
outpost_arn = (known after apply)
password_data = (known after apply)
placement_group = (known after apply)
placement_partition_number = (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)
secondary_private_ips = (known after apply)
security_groups = (known after apply)
source_dest_check = true
subnet_id = (known after apply)
tags = {
tags_all = {
tenancy = (known after apply)
user_data = (known after apply)
user_data_base64 = (known after apply)
user_data_replace_on_change = false
vpc_security_group_ids = (known after apply)
capacity_reservation_specification {
capacity_reservation_preference = (known after apply)
capacity_reservation_target {
ebs_block_device {
enclave_options {
ephemeral_block_device {
maintenance_options {
metadata_options {
network_interface {
root_block_device {
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.example: Creating... aws_instance.example: Still creating... [10s elapsed] aws_instance.example: Still creating... [20s elapsed] aws_instance.example: Creation complete after 22s [id=i-0bb3c2191c397dff2]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed. MNMBP:one-server minguyen$ terraform apply aws_instance.example: Refreshing state... [id=i-0bb3c2191c397dff2]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed. MNMBP:one-server minguyen$ terraform apply aws_instance.example: Refreshing state... [id=i-0bb3c2191c397dff2]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed. MNMBP:one-server minguyen$ terraform plan
^CStopping operation...
Interrupt received. Please wait for Terraform to exit or data loss may occur. Gracefully shutting down...
╷ │ Error: error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: operation error STS: GetCallerIdentity, request canceled, context canceled │ │ with provider["registry.terraform.io/hashicorp/aws"], │ on main.tf line 12, in provider "aws": │ 12: provider "aws" { │ ╵ MNMBP:one-server minguyen$ terraform plan ^C Interrupt received. Please wait for Terraform to exit or data loss may occur. Gracefully shutting down...
Stopping operation... ╷ │ Error: error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: operation error STS: GetCallerIdentity, request canceled, context canceled │ │ with provider["registry.terraform.io/hashicorp/aws"], │ on main.tf line 12, in provider "aws": │ 12: provider "aws" { │ ╵ MNMBP:one-server minguyen$ terraform plan aws_instance.example: Refreshing state... [id=i-0bb3c2191c397dff2]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place
Terraform will perform the following actions:
~ resource "aws_instance" "example" { id = "i-0bb3c2191c397dff2" ~ tags = {
}
~ tags_all = {
"CustomTag" = "Michael'sTag"
}
# (28 unchanged attributes hidden)
# (6 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. MNMBP:one-server minguyen$ terraform apply aws_instance.example: Refreshing state... [id=i-0bb3c2191c397dff2]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place
Terraform will perform the following actions:
~ resource "aws_instance" "example" { id = "i-0bb3c2191c397dff2" ~ tags = {
}
~ tags_all = {
"CustomTag" = "Michael'sTag"
}
# (28 unchanged attributes hidden)
# (6 unchanged blocks hidden)
}
Plan: 0 to add, 1 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.example: Modifying... [id=i-0bb3c2191c397dff2] aws_instance.example: Modifications complete after 2s [id=i-0bb3c2191c397dff2]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed. MNMBP:one-server minguyen$ git init Initialized empty Git repository in /Users/minguyen/Documents/Personal/tf-up-and-running/terraform-up-and-running-code-master/code/terraform/02-intro-to-terraform-syntax/one-server/.git/ MNMBP:one-server minguyen$ git add main.tf .terraform.lock.hcl MNMBP:one-server minguyen$ git commit -m "Initial commit
" [main (root-commit) 8c5559d] Initial commit 2 files changed, 50 insertions(+) create mode 100644 .terraform.lock.hcl create mode 100644 main.tf MNMBP:one-server minguyen$ #!/bin/bash MNMBP:one-server minguyen$ cd .. MNMBP:02-intro-to-terraform-syntax minguyen$ ls one-server one-webserver one-webserver-with-vars webserver-cluster MNMBP:02-intro-to-terraform-syntax minguyen$ cd one-webserver MNMBP:one-webserver minguyen$ ls README.md main.tf MNMBP:one-webserver minguyen$ terraform plan ╷ │ Error: Required plugins are not installed │ │ The installed provider plugins are not consistent with the packages selected in the dependency lock file: │ - registry.terraform.io/hashicorp/aws: there is no package for registry.terraform.io/hashicorp/aws 4.19.0 cached in .terraform/providers │ │ Terraform uses external plugins to integrate with a variety of different infrastructure services. To download the │ plugins required for this configuration, run: │ terraform init ╵ MNMBP:one-webserver minguyen$ terraform init
Initializing the backend...
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.
If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. MNMBP:one-webserver minguyen$ terraform graph digraph { compound = "true" newrank = "true" subgraph "root" { "[root] aws_instance.example (expand)" [label = "aws_instance.example", shape = "box"] "[root] aws_security_group.instance (expand)" [label = "aws_security_group.instance", shape = "box"] "[root] provider[\"registry.terraform.io/hashicorp/aws\"]" [label = "provider[\"registry.terraform.io/hashicorp/aws\"]", shape = "diamond"] "[root] var.security_group_name" [label = "var.security_group_name", shape = "note"] "[root] aws_instance.example (expand)" -> "[root] aws_security_group.instance (expand)" "[root] aws_security_group.instance (expand)" -> "[root] provider[\"registry.terraform.io/hashicorp/aws\"]" "[root] aws_security_group.instance (expand)" -> "[root] var.security_group_name" "[root] output.public_ip (expand)" -> "[root] aws_instance.example (expand)" "[root] provider[\"registry.terraform.io/hashicorp/aws\"] (close)" -> "[root] aws_instance.example (expand)" "[root] root" -> "[root] output.public_ip (expand)" "[root] root" -> "[root] provider[\"registry.terraform.io/hashicorp/aws\"] (close)" } }
MNMBP:one-webserver minguyen$ terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
resource "aws_instance" "example" {
ami = "ami-0fb653ca2d3203ac1"
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)
disable_api_termination = (known after apply)
ebs_optimized = (known after apply)
get_password_data = false
host_id = (known after apply)
id = (known after apply)
instance_initiated_shutdown_behavior = (known after apply)
instance_state = (known after apply)
instance_type = "t2.micro"
ipv6_address_count = (known after apply)
ipv6_addresses = (known after apply)
key_name = (known after apply)
monitoring = (known after apply)
outpost_arn = (known after apply)
password_data = (known after apply)
placement_group = (known after apply)
placement_partition_number = (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)
secondary_private_ips = (known after apply)
security_groups = (known after apply)
source_dest_check = true
subnet_id = (known after apply)
tags = {
tags_all = {
tenancy = (known after apply)
user_data = "c765373c563b260626d113c4a56a46e8a8c5ca33"
user_data_base64 = (known after apply)
user_data_replace_on_change = true
vpc_security_group_ids = (known after apply)
capacity_reservation_specification {
capacity_reservation_preference = (known after apply)
capacity_reservation_target {
ebs_block_device {
enclave_options {
ephemeral_block_device {
maintenance_options {
metadata_options {
network_interface {
root_block_device {
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. MNMBP:one-webserver minguyen$ terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
resource "aws_instance" "example" {
ami = "ami-0fb653ca2d3203ac1"
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)
disable_api_termination = (known after apply)
ebs_optimized = (known after apply)
get_password_data = false
host_id = (known after apply)
id = (known after apply)
instance_initiated_shutdown_behavior = (known after apply)
instance_state = (known after apply)
instance_type = "t2.micro"
ipv6_address_count = (known after apply)
ipv6_addresses = (known after apply)
key_name = (known after apply)
monitoring = (known after apply)
outpost_arn = (known after apply)
password_data = (known after apply)
placement_group = (known after apply)
placement_partition_number = (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)
secondary_private_ips = (known after apply)
security_groups = (known after apply)
source_dest_check = true
subnet_id = (known after apply)
tags = {
tags_all = {
tenancy = (known after apply)
user_data = "c765373c563b260626d113c4a56a46e8a8c5ca33"
user_data_base64 = (known after apply)
user_data_replace_on_change = true
vpc_security_group_ids = (known after apply)
capacity_reservation_specification {
capacity_reservation_preference = (known after apply)
capacity_reservation_target {
ebs_block_device {
enclave_options {
ephemeral_block_device {
maintenance_options {
metadata_options {
network_interface {
root_block_device {
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. MNMBP:one-webserver minguyen$ terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
resource "aws_instance" "example" {
ami = "ami-0fb653ca2d3203ac1"
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)
disable_api_termination = (known after apply)
ebs_optimized = (known after apply)
get_password_data = false
host_id = (known after apply)
id = (known after apply)
instance_initiated_shutdown_behavior = (known after apply)
instance_state = (known after apply)
instance_type = "t2.micro"
ipv6_address_count = (known after apply)
ipv6_addresses = (known after apply)
key_name = (known after apply)
monitoring = (known after apply)
outpost_arn = (known after apply)
password_data = (known after apply)
placement_group = (known after apply)
placement_partition_number = (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)
secondary_private_ips = (known after apply)
security_groups = (known after apply)
source_dest_check = true
subnet_id = (known after apply)
tags = {
tags_all = {
tenancy = (known after apply)
user_data = "c765373c563b260626d113c4a56a46e8a8c5ca33"
user_data_base64 = (known after apply)
user_data_replace_on_change = true
vpc_security_group_ids = (known after apply)
capacity_reservation_specification {
capacity_reservation_preference = (known after apply)
capacity_reservation_target {
ebs_block_device {
enclave_options {
ephemeral_block_device {
maintenance_options {
metadata_options {
network_interface {
root_block_device {
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
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_security_group.instance: Creating... aws_security_group.instance: Creation complete after 3s [id=sg-0046861b446d2e744] aws_instance.example: Creating... aws_instance.example: Still creating... [10s elapsed] aws_instance.example: Still creating... [20s elapsed] aws_instance.example: Creation complete after 22s [id=i-0a6bcc0919b133d57]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
Outputs:
public_ip = "redacted" MNMBP:one-webserver minguyen$ terraform plan aws_security_group.instance: Refreshing state... [id=sg-0046861b446d2e744] aws_instance.example: Refreshing state... [id=i-0a6bcc0919b133d57]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed. MNMBP:one-webserver minguyen$
Could you put the log output into several code fences, one for each thing you ran? It's very hard to read it otherwise, as a lot of the syntax is being interpreted as Markdown, the content is wrapping, etc.
Chapter 2, 3rd Edition: Finished one-server, added a custom tag, tf applied okay
In the next section, one-webserver, the book examples show that it should destroy the old instance so that it can build a new one and run the EOF userdata section, but tf plan and apply ended up creating a 2nd instance instead of doing anything with the existing instance.
Not sure if it is user error (certainly not ruling that out as i'm just starting to learn), but I don't think I strayed from the book.
Console output in next comment