I am writing unit tests for a module which is expecting data.aws_caller_identity.current.arn in a specific format (for example: arn:aws:iam::000000000000:root/assumed-role/some-role).
Is it possible to mock it?
Currently it returns some random string.
I have tried using override_data or mock_data (see below), but with no luck.
mock_data "aws_caller_identity" {
defaults = {
data = {
current = {
arn = "arn:aws:iam::123456789012:assume-role/test-user"
}
}
}
}
% terraform test
test.tftest.hcl... in progress
run "test"... pass
test.tftest.hcl... tearing down
test.tftest.hcl... pass
Success! 1 passed, 0 failed.
edit: I also tried this, and it also passed for me (everything else same as above):