끄적끄적 아무기록

OpenTofu란? OpenTofu 개념과 MacOS에 설치하기

by 현생사는갓생지망생
반응형

Terraform의 라이선스가 변경되며 (MPL to Business Source License)

이에 대응하여 오픈소스로 유지 예정인 IaC 프레임웍인 OpenTofu에 대해 알아보고자 한다

 

OpenTofu란?
OpenTofu is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle. OpenTofu can manage low-level components like compute, storage, and networking resources, as well as high-level components like DNS entries and SaaS features.

    📍 출처 : https://opentofu.org/docs/intro/

 

MacOS에서 OpenTofu를 설치하는 방법은 간단하다

    📍 참고 : MAC에 Homebrew 설치

hyeonsaeng@MacBookPro ~ % brew install opentofu
==> Downloading https://ghcr.io/v2/homebrew/core/opentofu/manifests/1.6.0
######################################################################################################################################################################### 100.0%
==> Fetching opentofu
==> Downloading https://ghcr.io/v2/homebrew/core/opentofu/blobs/sha256:7a63de38a2cc1cf705a3f271a6d79821dda7be01fb56e028af5acc27486349f6
######################################################################################################################################################################### 100.0%
==> Pouring opentofu--1.6.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/opentofu/1.6.0: 6 files, 82.8MB
==> Running `brew cleanup opentofu`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
hyeonsaeng@MacBookPro ~ % tofu --version
OpenTofu v1.6.0
on darwin_arm64

 

설치 후 아래와 같이 OpenTofu 이용하여 사용 가능한 Command 목록 확인이 가능하다

hyeonsaeng@MacBookPro ~ % tofu
Usage: tofu [global options] <subcommand> [args]

The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.

Main commands:
  init          Prepare your working directory for other commands
  validate      Check whether the configuration is valid
  plan          Show changes required by the current configuration
  apply         Create or update infrastructure
  destroy       Destroy previously-created infrastructure

All other commands:
  console       Try OpenTofu expressions at an interactive command prompt
  fmt           Reformat your configuration in the standard style
  force-unlock  Release a stuck lock on the current workspace
  get           Install or upgrade remote OpenTofu modules
  graph         Generate a Graphviz graph of the steps in an operation
  import        Associate existing infrastructure with a OpenTofu resource
  login         Obtain and save credentials for a remote host
  logout        Remove locally-stored credentials for a remote host
  metadata      Metadata related commands
  output        Show output values from your root module
  providers     Show the providers required for this configuration
  refresh       Update the state to match remote systems
  show          Show the current state or a saved plan
  state         Advanced state management
  taint         Mark a resource instance as not fully functional
  test          Execute integration tests for OpenTofu modules
  untaint       Remove the 'tainted' state from a resource instance
  version       Show the current OpenTofu version
  workspace     Workspace management

Global options (use these before the subcommand, if any):
  -chdir=DIR    Switch to a different working directory before executing the
                given subcommand.
  -help         Show this help output, or the help for a specified subcommand.
  -version      An alias for the "version" subcommand.

 

👉🏻 Shell Tab-completion

bash 혹은 zsh 쉘을 사용할 경우 탭 자동 완성 기능를 사용할 수 있다

tofu -install-autocomplete

 

.zshrc profile에 아래와 같이 설정이 추가되고, re-read 후 자동 완성이 활성화된다

hyeonsaeng@MacBookPro ~ % cat ~/.zshrc | grep tofu
complete -o nospace -C /opt/homebrew/bin/tofu tofu
hyeonsaeng@MacBookPro ~ % tofu
apply         env           get           init          metadata      providers     show          test          version       
console       fmt           graph         login         output        push          state         untaint       workspace     
destroy       force-unlock  import        logout        plan          refresh       taint         validate

 

 

✍🏻 참고

OpenTofu 공식 문서 https://opentofu.org/docs/intro/

Hashicorp License 관련 https://github.com/hashicorp/terraform/commit/b145fbcaadf0fa7d0e7040eac641d9aef2a26433

반응형

블로그의 정보

현생이네

현생사는갓생지망생

활동하기