Terraform Tests effect on existing resources.

0

Hi. I want to utilize terraform test to do a pre-validation before deployments. However, I would like to know if using terraform test will affect my existing resources.

If using terraform test creates ephemeral resources, will it be created on my account and what name would it be using once it's created?

Gab
asked 2 months ago77 views
1 Answer
1
Accepted Answer

Hello.

When you set "command" to "apply" in the "run" block, AWS resources are actually created.
https://developer.hashicorp.com/terraform/language/tests

If using terraform test creates ephemeral resources, will it be created on my account and what name would it be using once it's created?

I tried it with an S3 bucket and it uses the resource name defined in Terraform code.
It looks like the resource is created within my AWS account.

profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • Thanks for trying that out. What would happen then if the resource is already existing when you run the test. Would it "run" and update the existing resource and then revert once test is done?

  • When I tested an S3 bucket, when there was a resource with the same name, an error occurred like when creating a normal S3 bucket. I think an error will probably occur for AWS resources that cannot be created if the resource name is duplicated. Therefore, if you do not want to affect existing AWS resources, I think it is better to set "command" to "plan" in the "run" block.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions