• Stars
    star
    609
  • Rank 73,614 (Top 2 %)
  • Language
    JavaScript
  • License
    Mozilla Public Li...
  • Created about 7 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Private Terraform Module/Provider Registry

Citizen

Unit Test Status Integration Test Status FOSSA Status

A Private Terraform Module and Terraform Provider registry.

Requirements

  • HTTPS - Terraform module registry only support HTTPS.

Download

Also, you can use to launch the registry server. The docker image is in GitHub Container Registry .

$ docker run -d -p "3000:3000" ghcr.io/outsideris/citizen:latest

Server Usage

citizen server

To launch the registry server

$ ./citizen server

It will be launched at http://localhost:3000. You can check it at http://localhost:3000/health.

Because Terraform CLI works with only HTTPS server, you should set up HTTPS in front of the registry server.

If you want to test it at local, you need a tool which provides HTTPS like ngrok.

Environment variables:

  • CITIZEN_DATABASE_TYPE: Backend provider for registry metadata. Set to mysql, mongodb or sqlite.

  • CITIZEN_DATABASE_URL: The URL of the database. protocol//username:password@hosts:port/database?options

  • CITIZEN_STORAGE: Storage type to store module files. You can use file, s3 or gcs type.

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

  • CITIZEN_STORAGE_BUCKET: A S3 bucket to save module files only if CITIZEN_STORAGE is s3 or gcs.(And AWS credentials required.)

If you want to use GCS as a storage, you need to authenticate to Google Cloud services.

Database migration

To migrate the database, you can use citizen generate-migration command. The command will generate migration files which are schema.prisma and migrations/ directory. Because we use prisma to handle databases, you need to install prisma CLI.

Then, Set CITIZEN_DATABASE_TYPE and CITIZEN_DATABASE_URL envorinment variables and Run prisma migrate deploy for Sqlite. For MongoDB, migration is not required.

Client Usage

citizen module <namespace> <name> <provider> <version>

Since official Terraform Module Registry is integrated with GitHub, users can publish terraform modules if they just push it on GitHub.

Citizen provides a special command to publish a module onto citizen registry server instead integrating GitHub.

In a module directory, you can publish your terraform module via a command below:

$ ./citizen module <namespace> <name> <provider> <version>

You should set CITIZEN_ADDR as citizen registry server address which you will publish your modules to. e.g. https://registry.example.com.

Examples

If you have ALB module in ./alb directory, and your registry server is launched at https://registry.example.com, you run below command in ./alb directory to publish ALB module.

$ CITIZEN_ADDR=https://registry.example.com \
  citizen module dev-team alb aws 0.1.0

Then, you can define it in your terraform file like this:

module "alb" {
  source = "registry.example.com/dev-team/alb/aws"
  version = "0.1.0"
}

citizen provider <namespace> <type> <version> [protocols]

Citizen provides a special command to publish providers onto citizen.

  • -g, --gpg-key <gpgkey>: GPG key to sign your SHA256SUMS.

    • You need to publish your provider with your GPG public key to terraform registry. Otherwise, terraform will refuse to install providers. Terraform official resistry manage partners' public keys, but, each provider version has own public key and signature in citizen registry.

You must first build and package, citizen expects following files in the provider location:

  • <namespace>-<type>_<version>_<os>_<arch>.zip (one per os/arch combination)

Where <namespace> and <type> is a name of the provider and <version> is a provider version in the MAJOR.MINOR.PATCH version format.

Citizen will generate a SHA256SUMS file and a GPG signature file automatically for you: Following files will be generated in your directory during publising provider. So, You don’t need prepare theses files.

  • <namespace>-<type>_<version>_SHA256SUMS

  • <namespace>-<type>_<version>_SHA256SUMS.sig

Therefore, shasum and gpg commands should be available in your machine.

In a provider directory, you can publish your terraform provider via a command below:

$ ./citizen provider <namespace> <type> <version> [protocols]

[protocols] is comma separated Terraform provider API versions, with MAJOR.MINOR.

You should set CITIZEN_ADDR as citizen registry server address which you will publish your modules to. e.g. https://registry.example.com.

Examples

If you have ALB provider in ./utilities directory, and your registry server is launched at https://registry.example.com, you run below command in ./utilities directory to publish utilities provider.

$ CITIZEN_ADDR=https://registry.example.com \
  citizen provider dev-team utilities 0.1.0 4.1,5.0

Then, you can define it in your terraform file like this:

provider "utilities" {
}

terraform {
  required_providers {
    utilities = {
      source = "registry.example.com/dev-team/utilities"
      version = "0.1.0"
    }
  }
}

Development

Node.js 16+ required

Set environment variables, see above.

$ ./bin/citizen server
$ ./bin/citizen module
$ ./bin/citizen provider

Test

Set at least a storage path and the s3 bucket name variables for the tests to succeed. You need to be able to access the bucket, so you probably want to have an active aws or aws-vault profile.

Run mongodb as replica set first like:

$ docker-compose -f test/docker-compose-mongodb-cluster.yaml up

Run MySQL with docker

docker run --rm -p 3306:3306 --name mysql-citizen -e MYSQL_ROOT_PASSWORD=citizen -e MYSQL_DATABASE=citizen mysql

Run the tests:

$ npm test

Run the tests with the environment variables prefixed:

$ CITIZEN_STORAGE_PATH=storage CITIZEN_STORAGE_BUCKET=terraform-registry-modules npm test

Build distributions

$ npm run client
$ npm run build

It will generate prisma clients for databases.

Under dist/, citizen binaries for linux, darwin(amd64/arm64) and windows made.

License

FOSSA Status

More Repositories

1

slack-invite-automation

A tiny web application to invite a user into your slack team.
JavaScript
1,496
star
2

popularconvention

analyzing code convention from github commits for Github data challenge II
CoffeeScript
740
star
3

learning-spring

Learning Spring framework
XSLT
59
star
4

node.js-programming

"Node.js 프로그래밍 : 클라우드 컴퓨팅 시대의 고성능 자바스크립트 플랫폼"의 예제소스
JavaScript
45
star
5

issue-translator-extension

Chrome extension - Translates issues, pull requests and comments on GitHub for non-English-based programmers
JavaScript
43
star
6

headless-chrome-for-lambda

a docker container to compile chrome headless shell for AWS Lambda
Python
19
star
7

request-blog-post

https://blog.outsider.ne.kr 에서 설명해줬으면 하는 주제를 받습니다.
17
star
8

Socket.IO-Slide

Socket.Io Slide for FRENDS, Korea FRont ENd DeveloperS
JavaScript
13
star
9

socket.io-examples

HTML
11
star
10

infrastructure

HCL
11
star
11

potential-conflicts-checker-action

Check if this Pull Request can be conflict after other Pull Requests merged
JavaScript
10
star
12

side-effect-studio

JavaScript
10
star
13

page-back-example

JavaScript
8
star
14

curlybrace

Stackoverflow Homage
Scala
8
star
15

github-page-switcher

chrome extension to show one-touch icon to change github repository and github page.
JavaScript
8
star
16

outsider-gollum

my private wiki
7
star
17

summernote-markdown

experimental markdown editor based on summernote
JavaScript
7
star
18

.vim

my vim setting & dotfiles
Shell
6
star
19

outsideris

5
star
20

presentations

JavaScript
5
star
21

nodejs-ko-bot

tweet nodejs-ko blog posts
JavaScript
5
star
22

terraform-recipes

Terraform recipes by scenarios
HCL
4
star
23

blog-comments

3
star
24

twicussion

Twicussion
JavaScript
3
star
25

involved

App to encourage to contribute to open source project on github
JavaScript
3
star
26

scala-static-server

scala-static-server
Scala
3
star
27

lambdas

my own lambdas
JavaScript
2
star
28

terrace

Web Management UI for terraform
Python
2
star
29

TeslaCamViewer

JavaScript
2
star
30

frodo

wiki based scala and mecurial influenced by gollum
Scala
2
star
31

atom-angularjs

angular.js support in atom editor
CoffeeScript
2
star
32

gittip-links

show gittip link on github and bitbucket
JavaScript
2
star
33

refactoring-2e

1
star
34

cc-assignment

JavaScript
1
star
35

actions-demo-2112

Shell
1
star
36

programming-kubernetes

Go
1
star
37

githug

I juse leave this for back-up (webapp like native app for github)
JavaScript
1
star
38

learn-x

TypeScript
1
star
39

meta-tags-generator

JavaScript
1
star
40

Outsider

1
star
41

review-reminder

JavaScript
1
star
42

cli-example

1
star
43

nodeconf

play.node() - Node.js Korea Conference
JavaScript
1
star
44

retrotech

MDX
1
star
45

blocks-test

TypeScript
1
star
46

codespaces-dotfiles-test

Shell
1
star
47

gh-actions-test-2020

JavaScript
1
star
48

pc2

1
star
49

learn-mocha

JavaScript
1
star
50

actions-test

JavaScript
1
star
51

deploy-test

JavaScript
1
star
52

f8-hackathon

JavaScript
1
star
53

jten

JavaScript
1
star
54

ibm-developer-connect-example

JavaScript
1
star
55

gatsby-starter-netlify-cms

JavaScript
1
star
56

cla-checker

JavaScript
1
star
57

dotfiles

dotfiles for Codespaces
Shell
1
star
58

learn-react

JavaScript
1
star
59

primer-nextjs-navlist

CSS
1
star