InfoGrab Docs

Terraform을 통해 로그인 규칙 배포

요약

이 가이드에서는 다음 방법을 설명합니다: 로그인 규칙(Login Rules)은 Auth Service 백엔드에 저장된 리소스로 Teleport Auth Service에 등록됩니다. A running Teleport Enterprise cluster.

이 가이드에서는 다음 방법을 설명합니다:

  • Teleport의 Terraform Provider를 사용하여 Teleport 클러스터에 로그인 규칙(Login Rules) 배포
  • Terraform을 통해 배포된 로그인 규칙 편집

작동 방식#

로그인 규칙(Login Rules)은 Auth Service 백엔드에 저장된 리소스로 Teleport Auth Service에 등록됩니다. Teleport Auth Service는 로그인 규칙을 포함한 백엔드 리소스를 생성, 삭제 또는 수정할 수 있는 gRPC API를 노출합니다. Teleport Terraform Provider는 Teleport Auth Service에 인증하고 gRPC API와 상호작용하여 에이전트 없는 SSH 서비스를 관리할 수 있습니다.

사전 요구사항#

  • A running Teleport Enterprise cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.

  • The tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:

      $ TELEPORT_DOMAIN=
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

To check that you can connect to your Teleport cluster, sign in with tsh login, then verify that you can run tctl commands using your current credentials.

For example, run the following command, assigning to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:

$ tsh login --proxy= --user=
$ tctl status
# Cluster  (=teleport.url=)
# Version  (=teleport.version=)
# CA pin   (=presets.ca_pin=)

If you can connect to the cluster and run the tctl status command, you can use your current credentials to run subsequent tctl commands from your workstation. If you host your own Teleport cluster, you can also run tctl commands on the computer that hosts the Teleport Auth Service for full permissions.

1단계/4단계: Terraform용 Teleport 자격 증명 설정#

간단히 하기 위해, 이 가이드에서는 tsh login을 통해 얻은 현재 로그인된 사용자의 Teleport 자격 증명을 사용하도록 Terraform 공급자를 구성합니다.

참고: Terraform 공급자 가이드에는 전용 terraform 사용자 및 역할 구성에 관한 지침이 포함되어 있으며, 이는 비대화형 환경에서 Terraform을 실행할 때 더 좋은 옵션입니다.

이미 Teleport 클러스터에서 다른 리소스를 관리하기 위해 Terraform을 사용하고 있다면 terraform 사용자 및 역할을 이미 설정하고 관련 자격 증명을 구성했을 것입니다. 최신 버전의 가이드에서 login_rule 리소스에 대해 list, read, create, update, delete 동사가 있는 terraform 역할을 사용하고 있는지 확인하세요.

먼저 login_rule 리소스를 읽고 수정할 권한이 있는 사용자로 Teleport에 로그인되어 있는지 확인합니다. 사전 설정된 editor 역할은 이미 이 권한을 가지고 있지만, 더 맞춤화된 구성을 사용하는 경우에는 다음 내용으로 loginrule-manager.yaml이라는 역할을 생성합니다:

kind: role
metadata:
  name: loginrule-manager
spec:
  allow:
    rules:
      - resources: [login_rule]
        verbs: [list, read, create, update, delete]
version: v7

tctl로 역할을 생성합니다:

$ tctl create loginrule-manager.yaml
role 'loginrule-manager' has been created

Assign the loginrule-manager role to your Teleport user by running the appropriate commands for your authentication provider:

2단계/4단계: Terraform 구성 생성#

다음 내용을 main.tf라는 파일에 붙여넣어 Terraform 공급자를 구성하고 두 개의 예시 로그인 규칙을 생성합니다. addr = "teleport.example.com:443" 필드를 Teleport Proxy의 공개 주소로 업데이트해야 합니다.

<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>terraform-login-rules.tf</code>)</p></div>

3단계/4단계: 구성 적용#

Terraform을 초기화하고 구성을 적용합니다:

$ terraform init
$ terraform apply

4단계/4단계: 정상 작동 확인#

클러스터에서 새 로그인 규칙을 사용할 수 있는지 다시 확인합니다:

$ tctl get login_rules
kind: login_rule
metadata:
  description: Terraform test rule using traits_expression
  id: 1680190764978381000
  labels:
    example: "yes"
  name: terraform-test-expression-rule
spec:
  priority: 1
  traits_expression: |
    external.put("groups",
      choose(
        option(external.groups.contains("admins"),
external.groups.add("app-admins", "db-admins")),
        option(external.groups.contains("ops"),
external.groups.add("k8s-admins")),
        option(true, external.groups)))
version: v1
---
kind: login_rule
metadata:
  description: Terraform test rule using traits_map
  id: 1680193055097268000
  labels:
    example: "yes"
  name: terraform-test-map-rule
spec:
  priority: 0
  traits_map:
    groups:
    - external.groups
    logins:
    - strings.lower(external.username)
    - external.logins
version: v1

방금 설치한 로그인 규칙을 tctl login_rule test 명령으로 테스트합니다. --load-from-cluster 플래그는 클러스터에 현재 설치된 모든 로그인 규칙을 로드하도록 명령에 지시합니다. 명령의 표준 입력에 예시 트레잇을 보내면 로그인 규칙에 의해 변환된 최종 트레잇을 출력합니다.

$ echo '{"groups": ["admins", "ops"], "username": ["Alice"], "logins": ["user", "root"]}' | \
  tctl login_rule test --load-from-cluster
groups:
- admins
- ops
- app-admins
- db-admins
logins:
- alice
- user
- root

다음 단계#

Terraform을 통해 로그인 규칙 배포

원문 보기
요약

이 가이드에서는 다음 방법을 설명합니다: 로그인 규칙(Login Rules)은 Auth Service 백엔드에 저장된 리소스로 Teleport Auth Service에 등록됩니다. A running Teleport Enterprise cluster.

이 가이드에서는 다음 방법을 설명합니다:

  • Teleport의 Terraform Provider를 사용하여 Teleport 클러스터에 로그인 규칙(Login Rules) 배포
  • Terraform을 통해 배포된 로그인 규칙 편집

작동 방식#

로그인 규칙(Login Rules)은 Auth Service 백엔드에 저장된 리소스로 Teleport Auth Service에 등록됩니다. Teleport Auth Service는 로그인 규칙을 포함한 백엔드 리소스를 생성, 삭제 또는 수정할 수 있는 gRPC API를 노출합니다. Teleport Terraform Provider는 Teleport Auth Service에 인증하고 gRPC API와 상호작용하여 에이전트 없는 SSH 서비스를 관리할 수 있습니다.

사전 요구사항#

  • A running Teleport Enterprise cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.

  • The tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:

      $ TELEPORT_DOMAIN=
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

To check that you can connect to your Teleport cluster, sign in with tsh login, then verify that you can run tctl commands using your current credentials.

For example, run the following command, assigning to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:

$ tsh login --proxy= --user=
$ tctl status
# Cluster  (=teleport.url=)
# Version  (=teleport.version=)
# CA pin   (=presets.ca_pin=)

If you can connect to the cluster and run the tctl status command, you can use your current credentials to run subsequent tctl commands from your workstation. If you host your own Teleport cluster, you can also run tctl commands on the computer that hosts the Teleport Auth Service for full permissions.

1단계/4단계: Terraform용 Teleport 자격 증명 설정#

간단히 하기 위해, 이 가이드에서는 tsh login을 통해 얻은 현재 로그인된 사용자의 Teleport 자격 증명을 사용하도록 Terraform 공급자를 구성합니다.

참고: Terraform 공급자 가이드에는 전용 terraform 사용자 및 역할 구성에 관한 지침이 포함되어 있으며, 이는 비대화형 환경에서 Terraform을 실행할 때 더 좋은 옵션입니다.

이미 Teleport 클러스터에서 다른 리소스를 관리하기 위해 Terraform을 사용하고 있다면 terraform 사용자 및 역할을 이미 설정하고 관련 자격 증명을 구성했을 것입니다. 최신 버전의 가이드에서 login_rule 리소스에 대해 list, read, create, update, delete 동사가 있는 terraform 역할을 사용하고 있는지 확인하세요.

먼저 login_rule 리소스를 읽고 수정할 권한이 있는 사용자로 Teleport에 로그인되어 있는지 확인합니다. 사전 설정된 editor 역할은 이미 이 권한을 가지고 있지만, 더 맞춤화된 구성을 사용하는 경우에는 다음 내용으로 loginrule-manager.yaml이라는 역할을 생성합니다:

kind: role
metadata:
  name: loginrule-manager
spec:
  allow:
    rules:
      - resources: [login_rule]
        verbs: [list, read, create, update, delete]
version: v7

tctl로 역할을 생성합니다:

$ tctl create loginrule-manager.yaml
role 'loginrule-manager' has been created

Assign the loginrule-manager role to your Teleport user by running the appropriate commands for your authentication provider:

2단계/4단계: Terraform 구성 생성#

다음 내용을 main.tf라는 파일에 붙여넣어 Terraform 공급자를 구성하고 두 개의 예시 로그인 규칙을 생성합니다. addr = "teleport.example.com:443" 필드를 Teleport Proxy의 공개 주소로 업데이트해야 합니다.

<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>terraform-login-rules.tf</code>)</p></div>

3단계/4단계: 구성 적용#

Terraform을 초기화하고 구성을 적용합니다:

$ terraform init
$ terraform apply

4단계/4단계: 정상 작동 확인#

클러스터에서 새 로그인 규칙을 사용할 수 있는지 다시 확인합니다:

$ tctl get login_rules
kind: login_rule
metadata:
  description: Terraform test rule using traits_expression
  id: 1680190764978381000
  labels:
    example: "yes"
  name: terraform-test-expression-rule
spec:
  priority: 1
  traits_expression: |
    external.put("groups",
      choose(
        option(external.groups.contains("admins"),
external.groups.add("app-admins", "db-admins")),
        option(external.groups.contains("ops"),
external.groups.add("k8s-admins")),
        option(true, external.groups)))
version: v1
---
kind: login_rule
metadata:
  description: Terraform test rule using traits_map
  id: 1680193055097268000
  labels:
    example: "yes"
  name: terraform-test-map-rule
spec:
  priority: 0
  traits_map:
    groups:
    - external.groups
    logins:
    - strings.lower(external.username)
    - external.logins
version: v1

방금 설치한 로그인 규칙을 tctl login_rule test 명령으로 테스트합니다. --load-from-cluster 플래그는 클러스터에 현재 설치된 모든 로그인 규칙을 로드하도록 명령에 지시합니다. 명령의 표준 입력에 예시 트레잇을 보내면 로그인 규칙에 의해 변환된 최종 트레잇을 출력합니다.

$ echo '{"groups": ["admins", "ops"], "username": ["Alice"], "logins": ["user", "root"]}' | \
  tctl login_rule test --load-from-cluster
groups:
- admins
- ops
- app-admins
- db-admins
logins:
- alice
- user
- root

다음 단계#