This is a minimal Wye setup intended for demonstration purposes. It consists of two Docker containers running on dedicated EC2 instances: a Wiki.js web server and a PostgreSQL database.
🎥 Video walkthrough: https://youtu.be/mt0Fm0gpwsE
The project root contains the following:
- docker/ — Docker host and container resources.
- ec2/ — Resources for EC2 security groups, network interfaces, and instances.
- provider/ — Provider configuration files.
- script/ — Bootstrap and teardown scripts.
- vault/ — Secrets vault containing an SSH key for EC2 instances (not part of the repo).
- .gitignore — Git ignore rules.
- .wyeignore — Wye ignore rules.
- README.md — This file.
- env.json — EC2 environment configuration (not part of the repo).
- wye.ncl — Main Wye configuration file.
-
Ensure you have the AWS CLI installed and configured with valid access to AWS.
-
Ensure that jq is installed.
-
Bootstrap the demo environment with the following command:
script/bootstrap.sh
This script will:
- create a new AWS VPC;
- create a subnet with
CIDR = 10.0.0.0/24associated with this VPC; - create an Internet Gateway associated with this VPC;
- create a Route Table associated with this VPC;
- add a rule to the route table for Internet access (0.0.0.0/0);
- create a Key Pair, download the generated key, and move it to
vault/ssh-key.pem; - create an
env.jsonfile that will be used by the configuration files;
-
Remove all resources from the Git index. In Wye, the index always reflects the current system state:
git rm --cached ec2/* docker/*
-
Reconcile the worktree resources with the system (deploy all resources):
wye stage $(git ls-files --others --exclude-standard)Note: When a resource is reconciled, it is immediately reflected in the index. This is helpful if the
stagecommand fails mid-process, as the index clearly shows which resource changes were applied.Note 2: Each resource includes an associated
.obs.jsonfile containing the observed state (e.g., IDs, IP addresses). These are imported by dependent configuration files. They are ephemeral, excluded from the repository, and regenerated during resource updates or manual scans.Note 3: Ensure resources are added to the index so the live system corresponds to
HEAD. Extract theprimary_public_ipv4fromec2/web.ec2-inst.obs.jsonand openhttp://<this-ip>in your browser to view the Wiki.js setup page. -
Scan for real changes by comparing the live system against your configuration:
wye scan-sync -d
Note: If any unknown resources are detected during the scan, an
untracked/directory will be created containing.obs.jsonand.cfgdiff.jsonfiles. The latter detail the differences between your configuration and the actual state. Since no such resources were yet introduced, theuntracked/directory is not present. -
Simulate an issue by stopping the
dbcontainer. Extract theprimary_public_ipv4fromec2/db.ec2-inst.obs.json, connect to the instance, and stop thewiki-storagecontainer:ssh -i vault/ssh-key.pem ubuntu@<ip-address> sudo docker stop wiki-storage
-
Launch a live scan to diagnose the issue:
wye scan-sync -d
Note: The command output will contain:
WARN base::registry::synchronize] detected non-empty config diff for docker/db.dkr-ctrYou will also find a new
docker/db.dkr-ctr.cfgdiff.jsonfile containing:{"stopped":true} -
Heal the system by enforcing the
dbcontainer configuration:wye stage docker/db.dkr-ctr.cfg.ncl
Note: This command triggers a resource update. Wye detects that the
is_stoppedattribute differs from the expected state and issues adocker startcommand. After this, a subsequent scan should no longer show the warning. -
Add an untracked security group into the current VPC:
aws ec2 create-security-group \ --group-name external \ --description "Untracked security group" \ --region <your-region> \ --vpc-id <your-vpc-id>
-
Run the scan again:
wye scan-sync -d
Note: Now you can find corresponding
.cfgdiff.jsonand.obs.jsonfiles in theuntracked/directory. -
Remove the untracked security group:
aws ec2 delete-security-group \ --group-id <untracked-group-id> \ --region <your-region>
-
Destroy the setup to conclude the demo:
rm ec2/*.cfg.ncl docker/*.cfg.ncl wye stage $(git diff --name-only --diff-filter=D)
-
Teardown the demo environment with the following command:
script/teardown.sh