I have created below config file
resource “local_file” “my-pet” {
filename = “/root/pet-name”
content = “My pet is called finnegan!!”
}
resource “random_pet” “other-pet” {
length = 1
prefix = “Mr”
separator = “.”
}
Error logs:
test_one.py F [100%]
=================================== FAILURES ===================================
__________________________________ test_init ___________________________________
def test_init():
host = testinfra.get_host("docker://iac-server")
cmd1 = host.run("cd /root/terraform-projects/MPL/ && cat pet-name.tf | cut -d'=' -f2 | grep -w 'My pet is called finnegan!!' && cat pet-name.tf | cut -d'=' -f2 | grep -w '/root/pet-name' && cat pet-name.tf | grep -w 'my-pet' && cat pet-name.tf | cut -d'=' -f2 | grep -w '1' && cat pet-name.tf | cut -d'=' -f2 | grep -w 'Mr' && cat pet-name.tf | cut -d'=' -f2 | grep '\.' && cat pet-name.tf | grep -w 'other-pet' ")
assert cmd1.rc == 0, 'Resources not configured correctly.'
E AssertionError: Resources not configured correctly.
E assert 1 == 0
E + where 1 = CommandResult(command="cd /root/terraform-projects/MPL/ && cat pet-name.tf | …_status=1, stdout=None, stderr=‘cat: pet-name.tf: No such file or directory\n’).rc
test_one.py:6: AssertionError
=========================== 1 failed in 0.13 seconds ===========================
output of command:
iac-server $ terraform init
Initializing the backend…
Initializing provider plugins…
- Using previously-installed hashicorp/random v3.1.0
- Using previously-installed hashicorp/local v2.1.0
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.
- hashicorp/local: version = “~> 2.1.0”
- hashicorp/random: version = “~> 3.1.0”
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.
iac-server $ terraform plan
Refreshing Terraform state in-memory prior to plan…
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
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:
local_file.my-pet will be created
- resource “local_file” “my-pet” {
- content = “My pet is called finnegan!!”
- directory_permission = “0777”
- file_permission = “0777”
- filename = “/root/pet-name”
- id = (known after apply)
}
random_pet.other-pet will be created
- resource “random_pet” “other-pet” {
- id = (known after apply)
- length = 1
- prefix = “Mr”
- separator = “.”
}
Plan: 2 to add, 0 to change, 0 to destroy.
Note: You didn’t specify an “-out” parameter to save this plan, so Terraform
can’t guarantee that exactly these actions will be performed if
“terraform apply” is subsequently run.
iac-server $ terraform apply
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:
local_file.my-pet will be created
- resource “local_file” “my-pet” {
- content = “My pet is called finnegan!!”
- directory_permission = “0777”
- file_permission = “0777”
- filename = “/root/pet-name”
- id = (known after apply)
}
random_pet.other-pet will be created
- resource “random_pet” “other-pet” {
- id = (known after apply)
- length = 1
- prefix = “Mr”
- separator = “.”
}
Plan: 2 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
local_file.my-pet: Creating…
local_file.my-pet: Creation complete after 0s [id=9874dce72f896b8152fd9d41d11d44fae6c4127f]
random_pet.other-pet: Creating…
random_pet.other-pet: Creation complete after 0s [id=Mr.flea]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
Can some one please let me know what I have missed here?