You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code. What is the best method to quickly find the IP address of the resource you deployed?
A.
Run terraform output ip_address to view the result
B.
In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file
C.
Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
D.
Run terraform destroy then terraform apply and look for the IP address in stdout
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address. This option allows you to easily find the public IP address of the resource you deployed, without having to destroy and recreate it. The terraform state list command lists all of the resources that have been added to the state, while the terraform state show command displays the attributes of a specific resource, including its public IP address.
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
If you have not created any outputs in your Terraform code, you can still find the public IP address of the resource by using the terraform state commands. First, you can run terraform state list to see a list of all the resources that Terraform is managing in the state file. Look for the resource with a type that matches your webapp, such as "aws_instance" or "google_compute_instance".
Once you have found the name of the resource, you can run terraform state show <resource_name> to view all of the attributes of the resource, including the public IP address. For example, if the name of the resource is "webapp", you would run terraform state show webapp. This will display all of the attributes of the resource, including the public IP address.
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address is the best method to quickly find the IP address of the resource you deployed.
terraform state list will show you the name of all the resources currently tracked in your Terraform state. You can then use terraform state show followed by the resource name to see all the details of the resource, including any attributes like the public IP address.
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes, including the public IP address.
Explanation:
Not Option A (terraform output ip_address) assumes that there is an output variable named ip_address in your Terraform configuration, but since you mentioned that you did not create any outputs, this option may not be applicable.
A cannot be. You don't have any output declared, so there is no default output or something like that where you could find the ip address. On the other hand, terraform state list, and then show specific, contains the state and this includes the ip address
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
coco10k
Highly Voted 2 years, 8 months agofasaleAkshay
Most Recent 3 months agoSerg853377
3 months agoSilentMilli
3 months agonharaz
3 months agocamps
3 months agosamimshaikh
3 months agohrajkuma
5 months, 2 weeks agobrundabanm
6 months, 2 weeks agoPrat8
1 year, 1 month agoluke404
1 year, 1 month agogofavad926
1 year, 3 months agootakuinside
1 year, 3 months agogrogudev
1 year, 3 months agoJayanth
1 year, 5 months agoBusi57
1 year, 5 months agocdechery
1 year, 5 months ago