테라폼엔 기본적으로 삭제 불가능한 default
워크스페이스가 있다.
>> terraform workspace list
* default
하나의 테라폼 설정은 하나의 backend(테라폼이 어떻게 작동해야 하는지, 데이터는 어디에 저장할지를 관리)와 일대일 관계다.
그리고 이 backend는 workspace에 포함된다.
즉, 깃헙 브랜치와 같이 독립된 환경에서 인프라 환경을 구축할 수 있게 된다. workspace를 변경할 때마다 backend가 바뀌며 설정값도 변경된다.
dev
, staging
, test
등의 workspace 다변화로 IaC를 구축할 수 있게 된다.
staging workspace를 생성한다.
>> terraform workspace new staging
Created and switched to workspace "staging"!
You're now on a new, empty workspace. Workspaces isolate their state,
so if you run "terraform plan" Terraform will not see any existing state
for this configuration.
workspace 리스트를 확인한다.
>> terraform workspace list
default
* staging