1. Code example:
resource "aws_instance" "example" {
ami = "ami-123456"
instance_type = "t2.micro"
}
resource "aws_instance" "example" {
ami = "ami-654321"
instance_type = "t2.micro"
}
2. terraform validate
3. Terraform will report an error indicating that a resource with the same name is declared more than once.
The terraform validate command checks the syntax and validates the configuration files in a Terraform module. It does not check for configuration consistency errors like differences between local and remote state or outdated module versions.
Therefore, option D, declaring a resource identifier more than once, is not a valid configuration consistency error that terraform validate would report.
PS C:\****\etl\tf> terraform validate
│ Error: Duplicate resource "aws_s3_bucket" configuration
│
│ on etl.tf line 14:
│ 14: resource "aws_s3_bucket" "s3_etl" {
│
│ A aws_s3_bucket resource named "s3_etl" was already declared at etl.tf:9,1-34. Resource names must be unique per type in each module.
=> Just tested it - si it is D
D. Declaring a resource identifier more than once.
Terraform validate is a command that checks the syntax and structure of the Terraform configuration files. It reports any configuration consistency errors it finds before attempting to create or modify any resources. The command checks for a variety of errors, including syntax errors, type errors, and missing required arguments. However, it does not check for differences between local and remote state, or whether a Terraform module is the latest version.
The only option that describes an error that Terraform validate checks for is D. Declaring a resource identifier more than once. This error occurs when the same resource identifier is declared multiple times in the same configuration file, which can lead to conflicts and unexpected behavior. Terraform validate checks for this error and reports it if it is found in the configuration files.
validate will look for syntax errors "Declaring a resource identifier more than once" is a syntax error - so Answer D
upvoted 4 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.
Bere
10 months agokiran15789
1 year, 6 months agoDevoteamAnalytix
1 year, 6 months agocamps
1 year, 7 months agodepal_dhir
2 years, 2 months agokeiffo2
2 years, 2 months ago