Add AWS Vault AMI, user-data, and launch template - #5
Conversation
BSick7
left a comment
There was a problem hiding this comment.
I left several comments.
In general, we should adjust this to eliminate user-data as much as possible.
The node should automatically start and connect to the vault cluster during bootup.
We should also reuse as much as we can across cloud platform VMs.
|
User-data now only writes the env file. A baked path unit runs configure, writes |
|
Let's move the packer build up to I don't think this is going to work in its current form. Here are some other issues I found:
|
|
Revision 3: Design. Packer location. Moved to
Also ran Packer bake and a live EC2 boot are still not covered. |
|
One more in |
| protocol = "tcp" | ||
| from_port = local.vault_api_port | ||
| to_port = local.vault_api_port | ||
| source_security_group_id = aws_security_group.nodes.id |
There was a problem hiding this comment.
There are several security group rules like this.
Let's switch to self = true.
| most_recent = true | ||
| owners = ["self"] | ||
|
|
||
| filter { |
There was a problem hiding this comment.
Since we're tagging it, let's use the tag instead of a name wildcard:
filter {
name = "tag:Name"
values = ["nullstone-vault"]
}
|
Looking really good, left a few smaller notes. Can we also add a github action workflow to build these AMIs against multiple regions? |
This slice bakes Vault CE and vault-utils into an AMI and boots a node without manual steps. User-data writes one env file. A baked configuration service runs after cloud-init, writes the AWS-specific Vault config, and exits. Systemd ordering then starts Vault, runs
bootstraponce, and starts health on 8210. Bootstrap failure keeps health and snapshots down. Scheduled snapshots run only on the Raft leader. A launch template attaches the AMI, instance profile, node security group, and user-data. ASG and NLB are not in this PR.PR Summary
vault-node/.vault-node/files/is cloud-neutral (basevault.hcl, systemd units).vault-node/aws/vault-node-configureis the only AWS-specific file.nullstone-vault-*), override withami. Default instance type ist3.micro./etc/vault.d/vault-utils.envand nothing else.vault-configure.serviceruns aftercloud-final.service, writes/etc/vault.d/cloud.hcland/etc/vault.d/node.env, and exits. All units are enabled during the bake.vault-clusterjoin tag.snapshot scheduleskips non-leaders.Depends on
develop.bootstrap aws, health on 8210, S3 snapshots), already ondevelop.nullstone-vault-*AMI in the account, oramiset.tofu planfails without one of those.network,snapshots_bucket, andunseal_key.How I validated
go vet,gofmt, andgo test -short ./...pass.tofu fmt -checkandtofu validatepass.shellcheckandbash -npass onprovision.shandvault-node-configure.systemd-analyze verifypasses on all five units on AL2023.vault-node-configurewas run end to end in an AL2023 container with a stubbed metadata service, and the generatedcloud.hclwas loaded by the pinned Vault 2.0 image alongside the bakedvault.hcl. Packer bake and a live EC2 boot were not run.Review Note 1
Unit tests cover the leader check and existing vault-utils paths. This branch does not change Compose. Live KMS unseal, Secrets Manager bootstrap, and NLB health on a running instance are not covered.
Review Note 2
Review feedback applied in
e584337ande170f3b. Basevault.hcland systemd units moved into Packer. User-data reduced to writing the env file. Ports 8200 and 8201 hardcoded. AMI is x86_64 with defaultt3.micro.Review Note 3
Second review round applied in
4d390d4andc50634d. Packer build moved tovault-node/. Path unit removed;vault-configure.serviceis ordered aftercloud-final.serviceand no longer callssystemctl.disable_mlock = falseadded. Operator policy grants read onsys/storage/raft/autopilot/state. Node security group allows 8200 node to node.kms:GenerateDataKeyadded for SSE-KMS snapshots. Configure script reads env values individually instead of sourcing. Nil index in the platform fallback fixed. All five units enabled at bake, withvault-snapshot.serviceonRestart=on-failureso an empty schedule leaves it stopped.Deferred with the reviewer's own scoping: multi-node init race to the ASG slice,
api_addron the NLB DNS name to the NLB slice.Next
Internal NLB with the target health check on 8210, then the ASG (surge
min_healthy_percentage = 100,max_healthy_percentage = 134). No lifecycle hooks on day one.