Sign inSign up

evops/citizen

By evops

Updated over 5 years ago

Image
0

1.1K

evops/citizen repository overview

= Citizen

image:https://github.com/outsideris/citizen/workflows/CI/badge.svg?branch=master["Build Status", link="https://github.com/outsideris/citizen/actions?query=workflow%3ACI+branch%3Amaster"] image:https://app.fossa.io/api/projects/git%2Bgithub.com%2Foutsideris%2Fcitizen.svg?type=shield["FOSSA Status", link="https://app.fossa.io/projects/git%2Bgithub.com%2Foutsideris%2Fcitizen?ref=badge_shield"] image:https://david-dm.org/outsideris/citizen/status.svg["Dependency Status", link="https://david-dm.org/outsideris/citizen"] image:https://david-dm.org/outsideris/citizen/dev-status.svg["devDependency Status", link="https://david-dm.org/outsideris/citizen?type=dev"]

A Private link:https://registry.terraform.io/[Terraform Module] and link:https://www.terraform.io/docs/internals/provider-registry-protocol.html[Terraform Provider] registry in the early stages of development.

== Requirements

  • Node.js 8+
  • HTTPS - Terraform module registry only support HTTPS.

== Usage link:https://github.com/outsideris/citizen//releases/latest[Download the latest release!]

=== citizen server To launch the registry server [source, sh] .... $ ./citizen server ....

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

Because link:https://www.terraform.io/[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 link:https://ngrok.com/[ngrok].

Environment variables:

  • CITIZEN_DATABASE: Backend provider for registry metadata. Set to mongodb to use MongoDB. Leaving unset will use local nedb file.
  • CITIZEN_MONGO_DB_URI: MongoDB database URI if using MongoDB backend. URI format is mongodb://username:password@host:port/database?options.... Default is mongodb://localhost:27017/citizen
  • CITIZEN_DB_DIR: A directory to save database file if using local backend storage. The default is data directory in a current working directory (absolute/relative path can be used).
  • CITIZEN_STORAGE : Storage type to store module files. You can use file or s3 type.
  • CITIZEN_STORAGE_PATH: A directory to save module files only if CITIZEN_STORAGE is file (absolute/relative path can be used).
  • CITIZEN_AWS_S3_BUCKET``: A S3 bucket to save module files only if CITIZEN_STORAGEiss3`.
  • AWS_ACCESS_KEY_ID: Your AWS access key only if CITIZEN_STORAGE is s3.
  • AWS_SECRET_ACCESS_KEY: Your AWS secret access key only if CITIZEN_STORAGE is s3.

=== citizen publish module Since link:https://registry.terraform.io/[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: [source, sh] .... $ ./citizen publish module ....

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. [source, sh] .... $ CITIZEN_ADDR=https://registry.example.com
citizen publish 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 publish provider

Citizen provides a special command to publish providers onto citizen.

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

  • terraform-provider-_.zip (one per os/arch combination)
  • terraform-provider-__SHA256SUMS
  • terraform-provider-__SHA256SUMS.sig

Where is a name of the provider and version is a provider version in the MAJOR.MINOR.PATCH version format.

SHA256 sums file can be generated using following shell command (linux/macos):

shasum -a *.zip > terraform-provider-<type>_<version>_SHA256SUMS

SHA256.sig file is a GPG signature of the SHA256SUMS file, generate using following command:

gpg --detach-sign terraform-provider-<type>_<version>_SHA256SUMS
  • You need to publish your GPG public key to terraform registry otherwise terraform will refuse to install providers. You can publish the key using citizen publish publisher command documented below.

In a provider directory, you can publish your terraform provider via a command below: [source, sh] .... $ ./citizen publish provider ....

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. [source, sh] .... $ CITIZEN_ADDR=https://registry.example.com
citizen publish provider dev-team utilities 0.1.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" } } } ....

=== citizen publish publisher

Citizen provider registry requires to have at least one trusted provider publisher. citizen publisher publisher command uploads a public GPG key from local GPG store using gpg command.

Find GPG key id you want to publisy using gpg --list-keys command and extract public key (long text in hex format e.g. CE1E75EC86B9F2). Then run citizen command to publish the key:

[source, sh] .... $ ./citizen publish publisher CE1E75EC86B9F2 ....

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

== Docker You can use docker to launch the registry server. The docker image is in link:https://hub.docker.com/r/outsideris/citizen/[outsideris/citizen].

[source, sh] .... $ docker run -d -p "3000:3000" outsideris/citizen:latest ....

== Development Set environment variables, see above.

[source, sh] .... $ ./bin/citizen server $ ./bin/citizen publish ....

=== 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 first like: [source, sh] .... $ docker run -p 27017:27017 --name mongo mongo ....

Run the tests: [source, sh] .... $ npm test ....

Run the tests with the environment variables prefixed: [source, sh] .... $ CITIZEN_STORAGE_PATH=storage CITIZEN_AWS_S3_BUCKET=terraform-registry-modules npm test ....

=== Build distributions

[source, sh] .... $ npm run build ....

Under dist/, citizen binaries for linux, darwin and windows made.

== License image:https://app.fossa.io/api/projects/git%2Bgithub.com%2Foutsideris%2Fcitizen.svg?type=large["FOSSA Status", link="https://app.fossa.io/projects/git%2Bgithub.com%2Foutsideris%2Fcitizen?ref=badge_large"]

Tag summary

Content type

Image

Digest

Size

51.2 MB

Last updated

over 5 years ago

docker pull evops/citizen