Terraspace Rspec State File Incorrect

I’m testing a stack that deploys a role, policy and policy attachment, this specific test is to check whether the correct policy is assigned to the role, and therefore I am checking the “aws_iam_role” resource and the “managed_policy_arns” in that object. When deploying to any environment outside of testing and rspec, the state file is as expected and the “aws_iam_role” has an entry under “managed_policy_arns” for the policy that is also created.

When running this via rspec, it “managed_policy_arns” is an empty list/array in the state file created in the /tmp directory. I can see the policy attachment resource is created with the correct values, is there any reason why the state file is not populating as expected?

The resources are deployed as expected with the managed policy attached

Reply

thanks

The test harness does not configure a backend.tf by default. So it uses local storage as the backend. Got some mixed feelings about which backend the test harness project should use. You can configure the test harness to use an s3 backend though. Just create a config folder and configure it with build_test_harness per docs

https://terraspace.cloud/docs/testing/test-harness/