feat(terraform/vault): support for tokens generation
We create the first machine-level token for bagel-box which has the policy CI. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
1a5e5a6adb
commit
b267cffc0e
3 changed files with 36 additions and 0 deletions
|
@ -17,6 +17,22 @@
|
||||||
|
|
||||||
infra.vault = {
|
infra.vault = {
|
||||||
provider = "vault.floral";
|
provider = "vault.floral";
|
||||||
|
tokens = {
|
||||||
|
bagel_box = {
|
||||||
|
policies = [ "ci" ];
|
||||||
|
renewable = true;
|
||||||
|
ttl = "7d";
|
||||||
|
# As long as the token is renewed every 14 days, its TTL can be extended of 7 more days.
|
||||||
|
period = "14d";
|
||||||
|
# A machine-wide token cannot live longer than 365 days, all of this is temporary anyway until we get proper machine identity.
|
||||||
|
explicit_max_ttl = "365d";
|
||||||
|
display_name = "bagel-box@infra.forkos.org machine-wide token";
|
||||||
|
|
||||||
|
metadata = {
|
||||||
|
purpose = "machine-account";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
infra.pki = {
|
infra.pki = {
|
||||||
|
|
|
@ -13,5 +13,6 @@ in
|
||||||
imports = [
|
imports = [
|
||||||
./policy.nix
|
./policy.nix
|
||||||
./sub-ca.nix
|
./sub-ca.nix
|
||||||
|
./tokens.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
19
terraform/vault/tokens.nix
Normal file
19
terraform/vault/tokens.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.infra.vault.tokens;
|
||||||
|
inherit (lib) mkOption types mapAttrs;
|
||||||
|
mkToken = name: value: value // {
|
||||||
|
provider = config.infra.vault.provider;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.infra.vault.tokens = mkOption {
|
||||||
|
# TODO: harden with freeformType json.
|
||||||
|
type = types.attrsOf types.unspecified;
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
resource.vault_token = mapAttrs mkToken cfg;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue