terraform에서 apply 후에 tfstate 삭제하고 다시 한번 apply하면 어떻게 될지 시도해 보았습니다.
2794 단어 Terraform
전제
검증
한 번 apply 실행 후, tfstate를 삭제하지 않고 plan 해 본다
$ 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.
aws_instance.example: Refreshing state... [id=i-034f0504ef1224dd5]
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
물론 차이없이 표시됩니다.
그런 다음 tfstate를 삭제하고 plan을 시도합니다.
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:
# aws_instance.example will be created
+ resource "aws_instance" "example" {
+ ami = "ami-0c3fd0f5d33134a76"
+ arn = (known after apply)
+ associate_public_ip_address = (known after apply)
+ availability_zone = (known afte
<省略>
Plan: 1 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
차이가 나왔다.
라는 것은 새롭게 작성될까? apply 실시
$ terraform apply
<省略>
Plan: 1 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
aws_instance.example: Creating...
aws_instance.example: Still creating... [10s elapsed]
aws_instance.example: Creation complete after 13s [id=i-03f96833d40e268eb]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
만들어진 것 같은
AWS 콘솔 화면에서 확인해도 다른 EC2가 생성되었습니다.
상단이 1회째에 작성한 것으로, 아래에 있는 것이, 이번 apply 실행시에 작성된 것
결론
한번 실행했을 때의 tfstate를 삭제하면, terraform의 관리로부터 벗어난다. 다시 실행하면 별도로 EC2를 시작합니다.
Reference
이 문제에 관하여(terraform에서 apply 후에 tfstate 삭제하고 다시 한번 apply하면 어떻게 될지 시도해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/atsushi586/items/07015a91e992dd7cdfa9
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
$ 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.
aws_instance.example: Refreshing state... [id=i-034f0504ef1224dd5]
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
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:
# aws_instance.example will be created
+ resource "aws_instance" "example" {
+ ami = "ami-0c3fd0f5d33134a76"
+ arn = (known after apply)
+ associate_public_ip_address = (known after apply)
+ availability_zone = (known afte
<省略>
Plan: 1 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
$ terraform apply
<省略>
Plan: 1 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
aws_instance.example: Creating...
aws_instance.example: Still creating... [10s elapsed]
aws_instance.example: Creation complete after 13s [id=i-03f96833d40e268eb]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
한번 실행했을 때의 tfstate를 삭제하면, terraform의 관리로부터 벗어난다. 다시 실행하면 별도로 EC2를 시작합니다.
Reference
이 문제에 관하여(terraform에서 apply 후에 tfstate 삭제하고 다시 한번 apply하면 어떻게 될지 시도해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/atsushi586/items/07015a91e992dd7cdfa9텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)