TheKoguryo's 기술 블로그

 Version 2024-11-29

https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformUsingObjectStore.htm#http

  1. Bucket 생성

tf-example-tfstate

  1. PAR(Pre-Authenticated Request) 생성 => 근데 PAR URL로 접근해야 하면, 이건 인터넷에서 인증 없이 접근됨. Object Storage가 Private Bucket이라 하더라도 해당 PAR URL로는 인증없이 접근됨

par-bucket-tf-example-tfstate Permit object reads and writes

URL https://objectstorage.ap-seoul-1.oraclecloud.com/p/k5TQIRpJrotyyCVwzQLDw3CqWrI1feMzvPtz7YEwm9I5IdvZwBxDUhGGmAxboJvf/n/cn8wdnkejjgq/b/tf-example-tfstate/o/

  1. Terraform Backend로 HTTP 구성

terraform { backend “http” { address = “https://objectstorage.ap-seoul-1.oraclecloud.com/p/k5TQIRpJrotyyCVwzQLDw3CqWrI1feMzvPtz7YEwm9I5IdvZwBxDUhGGmAxboJvf/n/cn8wdnkejjgq/b/tf-example-tfstate/o/terraform.tfstate" update_method = “PUT” } }

  1. terraform init

  2. terraform apply

  3. Object Storage 가 보면 tfstate 파일 생성되어 있음.

  4. lock 설정

terraform { backend “http” { address = “https://objectstorage.ap-seoul-1.oraclecloud.com/p/k5TQIRpJrotyyCVwzQLDw3CqWrI1feMzvPtz7YEwm9I5IdvZwBxDUhGGmAxboJvf/n/cn8wdnkejjgq/b/tf-example-tfstate/o/terraform.tfstate" update_method = “PUT” lock_address = “https://objectstorage.ap-seoul-1.oraclecloud.com/p/k5TQIRpJrotyyCVwzQLDw3CqWrI1feMzvPtz7YEwm9I5IdvZwBxDUhGGmAxboJvf/n/cn8wdnkejjgq/b/tf-example-tfstate/o/lock" unlock_address = “https://objectstorage.ap-seoul-1.oraclecloud.com/p/k5TQIRpJrotyyCVwzQLDw3CqWrI1feMzvPtz7YEwm9I5IdvZwBxDUhGGmAxboJvf/n/cn8wdnkejjgq/b/tf-example-tfstate/o/lock" } }

  1. terraform init
  2. terraform apply 응답 오류 발생 Object Storage의 HTTP API가 terraform state locking 지원 안하는 것으로 판단됨.
$ terraform apply
╷
│ Error: Error acquiring the state lock
│ 
│ Error message: Unexpected HTTP response code 404
│ 
│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended.


이 글은 개인으로서, 개인의 시간을 할애하여 작성된 글입니다. 글의 내용에 오류가 있을 수 있으며, 글 속의 의견은 개인적인 의견입니다.

Last updated on 1 Jan 0001