Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Citizen 개발기

Citizen 개발기

Terraform private module/provider registry를 개인 프로젝트로 만든 citizen의 개발기

Outsider

June 29, 2022
Tweet

More Decks by Outsider

Other Decks in Technology

Transcript

  1. Citizen 개발기
    (A Private Terraform Module/Provider Registry)
    Outsider@당근마켓
    2022. 6. 22
    HashiCorp User Group

    View full-size slide

  2. HashiCorp Brand Gudie: https://www.hashicorp.com/brand

    View full-size slide

  3. https://www.hashicorp.com/blog/hashicorp-terraform-module-registry

    View full-size slide

  4. https://registry.terraform.io/

    View full-size slide

  5. Public registry는 오픈소스 private 레지스트리가 있다
    verdaccio

    View full-size slide

  6. Public registry는 오픈소스 private 레지스트리가 있다
    verdaccio

    View full-size slide

  7. Public registry는 오픈소스 private 레지스트리가 있다
    verdaccio

    View full-size slide

  8. Public Registry

    View full-size slide

  9. Public Registry
    과금
    Private Registry

    View full-size slide

  10. Public Registry
    과금
    Private Registry
    오픈소스 Private Registry

    View full-size slide

  11. | Registry
    https://unsplash.com/photos/oZuBNC-6E2s

    View full-size slide

  12. https://www.terraform.io/registry/api-docs

    View full-size slide

  13. API Spec
    구현체(Terraform Registry)
    클라이언트(Terraform CLI)
    +
    +

    View full-size slide

  14. https://github.com/apparentlymart/terraform-simple-registry

    View full-size slide

  15. 타동사
    (행성을 사람들이 살 수 있도록) 지구처럼 만들다
    terra·form

    View full-size slide

  16. 타동사
    (행성을 사람들이 살 수 있도록) 지구처럼 만들다
    명사
    (특정 지역의) 주민, 시민
    terra·form
    citi·zen

    View full-size slide

  17. 파일 데이터베이스 지원
    파일/S3 스토리지 지원

    View full-size slide

  18. Usage: citizen [command] [options]

    Options:

    -V,
    --
    version output the version number

    -h,
    --
    help output usage information

    Commands:

    publish [options]

    publish the terraform module

    Environment variables below need to set

    * CITIZEN_ADDR : citizen registry server address to pubilsh a module

    server [options]

    run a terraform registry

    Environment variables below need to set

    * CITIZEN_STORAGE : storage type, file or s3

    * CITIZEN_STORAGE_PATH : directory to save module files if CITIZEN_STORAGE is file (absolute/relative path can be used).

    * CITIZEN_AWS_S3_BUCKET : s3 bucket to save module files if CITIZEN_STORAGE is s3

    * AWS_ACCESS_KEY_ID : your AWS access key if CITIZEN_STORAGE is s3

    * AWS_SECRET_ACCESS_KEY : your AWS secret access key if CITIZEN_STORAGE is s3

    Citizen CLI

    View full-size slide

  19. it('cli should connect the registry server with terraform-cli', (done)
    =
    >
    {

    const cwd = join(
    __
    dirname, 'fixture');

    execFile(terraform, ['get'], { cwd }, (err, stdout, stderr)
    =>
    {

    expect(stdout).to.include('- module.vpc');

    expect(stderr).to.include('no versions found');

    done();

    });

    });

    Terraform CLI를 통한 E2E 테스트

    View full-size slide

  20. https://blog.outsider.ne.kr/1384

    View full-size slide

  21. https://mobile.twitter.com/Outsideris/status/1004813169577975808

    View full-size slide

  22. 0.2
    0.3
    블로그 포스팅

    View full-size slide

  23. 나조차도 고객이 아니었다.

    View full-size slide

  24. 7 months later

    View full-size slide

  25. 0.2
    0.3
    블로그 포스팅
    0.3.2

    View full-size slide

  26. 0.2
    0.3
    블로그 포스팅
    0.3.2 0.3.3

    View full-size slide

  27. 1년 4개월

    View full-size slide

  28. https://www.hashicorp.com/blog/providers-in-the-hashicorp-terraform-registry-now-live

    View full-size slide

  29. https://www.hashicorp.com/blog/announcing-terraform-0-12

    View full-size slide

  30. //
    terraform 0.11

    resource "google_compute_subnetwork" "example" {

    count = 4

    name = "test-subnetwork"

    ip_cidr_range = "${cidrsubnet(var.base_network_cidr, 4, count.index)}"

    region = "us-central1"

    network = "${google_compute_network.custom-test.self_link}"

    }

    //
    terraform 0.12+

    resource "google_compute_subnetwork" "example" {

    count = 4

    name = "test-subnetwork"

    ip_cidr_range = cidrsubnet(var.base_network_cidr, 4, count.index)

    region = "us-central1"

    network = google_compute_network.custom-test.self_link

    }

    View full-size slide

  31. https://github.com/outsideris/citizen/pull/50

    View full-size slide

  32. https://github.com/outsideris/citizen/pull/51

    View full-size slide

  33. https://github.com/outsideris/citizen/pull/39

    View full-size slide

  34. https://github.com/outsideris/citizen/issues/48

    View full-size slide

  35. 0.2
    0.3
    블로그 포스팅
    0.3.2 0.3.3 0.4.0

    View full-size slide

  36. Usage: citizen [command] [options]

    Options:

    -V,
    --
    version output the version number

    -h,
    --
    help display help for command

    Commands:

    module [options] Publish the terraform module

    provider [options] [protocols] Publish the terraform provider

    server [options] Run a terraform registry
    Citizen CLI

    View full-size slide

  37. https://discuss.hashicorp.com/t/citizen-a-private-terraform-registry/21897

    View full-size slide

  38. 4개월
    다시 찾아온 공백

    View full-size slide

  39. https://cloudseclist.com/issues/issue-121/

    View full-size slide

  40. https://mobile.twitter.com/Outsideris/status/1492007882589564929

    View full-size slide

  41. https://project-awesome.org/shuaibiyy/awesome-terraform

    View full-size slide

  42. https://star-history.com/#outsideris/citizen&Date

    View full-size slide

  43. 0.2
    0.3
    블로그 포스팅
    0.3.2 0.3.3 0.4.0
    0.5.0

    View full-size slide

  44. 0.2
    0.3
    블로그 포스팅
    0.3.2 0.3.3 0.4.0
    0.5.0
    0.5.1
    0.5.2

    View full-size slide

  45. https://www.cloud4engineers.com/posts/2022/02/using-citizen-as-a-private-registry-to-store-and-retrieve-terraform-modules/

    View full-size slide

  46. https://www.cloud4engineers.com/posts/2022/02/using-citizen-as-a-private-registry-to-store-and-retrieve-terraform-modules/
    With Citizen,
    I just had the feeling that
    it was a bit more mature than Anthology
    due to better documentation
    - although Citizen is far from mature either.

    View full-size slide

  47. https://burger.devops.vectra-svc.ai/

    View full-size slide

  48. https://burger.devops.vectra-svc.ai/

    View full-size slide

  49. EOL
    t
    Outsideris
    g
    outsideris
    envelope
    [email protected]

    View full-size slide