Zero A.E.'s 12-Factor codebase of the Terraform Registry API implemented using Chalice and PynamoDB.
- apparentlymart/terraform-aws-tf-registry
- apparentlymart/terraform-simple-registry
- dflook/terraform-registry
- outsideris/citizen
- rmb938/tf-registry
-
Requirements:
- conda
- docker-compose
- keybase (for secrets)
-
Clone the repository and secrets
git clone https://github.com/zeroae/terraform-registry.git cd terraform-registry # Submodules did not work git clone keybase://team/zeroae/terraform-registry-secrets secrets # Fix the acme.json file permissions. 600 is not able to be committed to Git find . -type f -name acme.json -exec chmod 600 {} \;
-
Create conda environment
conda env create conda activate terraform-registry
-
Additional Requirements:
- docker-compose
-
Start the app on local mode
docker-compose up -d
-
Wait until the
app
,backend
andmanage
services are healthywatch docker-compose ps
-
Attach to the Management container
docker attach terraform-registry_manage_1 ./manage.py --help
- Initialize the Database
./manage.py db init ./manage.py db restore tests/integration/local.ddb
- Verify Terraform CLI can reach the local server
cd tests/integration/tf.local.zeroae.net rm -rf .terraform terraform init
- Detach from the container
Ctrl-P + Ctrl-Q
- Initialize the Database
-
Verify Terraform CLI can reach the local registry (outside management)
cd tests/integration/tf.local.zeroae.net rm -rf .terraform terraform init
-
Use Chalice to (re)deploy the
dev
stage to AWSexport AWS_CONFIG_FILE="./secrets/aws/config" chalice deploy --stage=dev
You may also set the
AWS_DEFAULT_PROFILE
environment variable to control where the API is deployed -
Initialize the Database
./manage.py --stage=dev db init # Optionally load content into the DynamoDB backend ./manage.py --stage=dev db restore tests/integration/local.ddb
-
Configure a custom domain name(
tf.zeroae.net
) to point to the dev stage- Use the AWS Certificate Manager to register a certificate for
tf.zeroae.net
- Create a custom domain name in API Gateway
tf.zeroae.net
- Edge Optimized
- TLS 1.2
- The ACM certificate from the previous step
- Create an ALIAS DNS record for
tf.zeroae.net
pointing to the API Gateway Name and ZONE ID from previous step. - Add API Mapping for the dev Stage
- Use the AWS Certificate Manager to register a certificate for
-
Verify Terraform CLI can reach the remote server
cd tests/integration/tf.zeroae.net rm -rf .terraform terraform init
When utilizing the manage.py
remember that if a --stage
is not specified then all of the actions will be taken on
the local environment that can be established by the docker-compose
configuration described above.
The backend for the API can be controlled through the manage.py
command line interface (CLI).
Initialize
./manage.py db init
Backup
./manage.py db backup <out filename>
Restore
./manage.py db restore <in file>
Destroy
./manage.py db destroy
Placing modules in the registry can be done through the manage.py
command line interface (CLI).
Each module record is a combination of the name, the provider, the version and then the location in which that module can be found.
Create a Record
./manage.py record create <module>/<name>/<provider>/<version> <go-getter-url>
Additional Options: --verified
, --owner
, --description
, --source
Delete a Record
./manage.py record delete <module>/<name>/<provider>/<version>
Import a Record from registry.terraform.io
./manage.py record import [--registry registry.terraform.io] <module>/<name>/<provider>/<version>