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?

gefragt vor 2 Monaten99 Aufrufe
1 Antwort
1
Akzeptierte Antwort

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
EXPERTE
beantwortet vor 2 Monaten
profile picture
EXPERTE
überprüft vor 2 Monaten
  • 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.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen