Giter Club home page Giter Club logo

iac-azure-vault-cluster's Introduction

iac-azure-vault-cluster

Manages a HashiCorp Vault cluster in Azure.

Features

  • Creates a cluster with X nodes
  • Auto unseal with Azure Key Vault
  • Load balanced with an Azure Application Gateway
  • Lets Encrypt certificate for the cluster
  • Linux VM as a Bastion host
  • All initial secrets stored in Azure Key Vault

Modules

Module Name Description
nat_gateway Creates a NAT gateway for the Vault subnet
netsec Creates NSG and rules for Vault subnet
userdata Creates Azure "userdata" for auto config of VMSS instances
vm Creates VM scale set to host the Vault cluster

TLS Certificates

These are generated by Terraform and stored in Azure Key Vault by repo iac-azure-vault-components

Vault install and config

Vault initialization

  • Vault must be initialized after intallation, and unsealed. Vault will use Azure key vault to auto unseal in the future
# vault cli doesn't recoginize the ca cert?
export VAULT_SKIP_VERIFY=true

# copy the unseal keys and root token - one time operation per cluster after provisioning
# these should be stored securely, like in an azure keyvault
azureuser@hcv-Tbngw-vmss-nonprod-eastus000000:~$ vault operator init
Recovery Key 1: 5Dq66YoWKqYhU0EnKj4d2OJqHD34Z4gsExqtol83XYnV
Recovery Key 2: /Kgchx1ozP4HzSpqBHggr8tR8kU2clpg/yXLVhurKqhB
Recovery Key 3: ecbDB4ZDeZPy+Yoqz3ZYm/kHDixlm8FVBgoxKdnWOMuZ
Recovery Key 4: MWNaAkFVdPJ6WWUl/UN0m7kqVUXV5thNyg3UIxxG5sFo
Recovery Key 5: 56yNsfDzLaTU1UsA5FzsEZxRvgQ5zghRlR0G5QeSGhiH

Initial Root Token: export VAULT_TOKEN=hvs.o9npdWL24GjRzsxVYlVDEMwn

Success! Vault is initialized

Recovery key initialized with 5 key shares and a key threshold of 3. Please
securely distribute the key shares printed above.

# exec unseal 3 times, using 3 of the 5 unseal keys from above
# on the 3rd one the "sealed" status should change to false
vault operator unseal


curl --insecure https://localhost:8200
curl --insecure https://vault.dev.diehlabsplatform.com

Backup of Vault raft data

  • Idea:
    • Use a GRS storage account
    • VMSS instances will have permission to connect via NFS or other means?
    • The VM MSI will have permissions in Vault to read raft data
    • The "init script" for the VMs will configure a cron job that will perform a raft snapshot and copy the data to the storage container

TODO

CHANGE APP GW FRONTEND CONFIG FROM PRIVATE TO PUBLIC (LISTENERS) REMOVE HCV-VAULT-LB NSG RULE "DENYALLINBOUND_INTERNET?

Requirements

Name Version
terraform >= 1.3.0
azurerm ~> 3.31

Providers

Name Version
azurerm 3.32.0

Modules

Name Source Version
nat_gateway ./modules/nat_gateway n/a
netsec ./modules/netsec n/a
user_data ./modules/user_data n/a
vm ./modules/vm n/a

Resources

Name Type
azurerm_linux_virtual_machine.bastion resource
azurerm_network_interface.bastion_nic resource
azurerm_network_interface_application_security_group_association.bastion resource
azurerm_public_ip.bastion_pip resource
azurerm_client_config.current data source
azurerm_key_vault.vault data source
azurerm_key_vault_secret.akv_secret_id_vault_vm_tls data source
azurerm_key_vault_secret.bastion_private_key data source
azurerm_key_vault_secret.bastion_public_key data source
azurerm_key_vault_secret.vault_private_key data source
azurerm_key_vault_secret.vault_public_key data source
azurerm_resource_group.vault data source
azurerm_subnet.agw data source
azurerm_subnet.bastion data source
azurerm_subnet.vault data source

Inputs

Name Description Type Default Required
agw_backend_address_pool_id The ID of the backend address pool form the AGW to assign the vm scale set instances to string n/a yes
az_sub_id n/a any n/a yes
dns_zone_name n/a any n/a yes
environment n/a any n/a yes
instance_count n/a any n/a yes
instance_type n/a any n/a yes
key_vault_name Name of the Keyvault to use. Could be sourced from remote state. string n/a yes
location n/a any n/a yes
subnet_name_bastion n/a any n/a yes
subnet_name_vault n/a any n/a yes
subnet_name_vault_agw n/a any n/a yes
vault_identity_client_id The Client ID of the MSI used by the Vault cluster nodes. Could be sourced from remote state. string n/a yes
vault_identity_id The resource ID of the MSI used by the Vault cluster nodes. Could be sourced from remote state. string n/a yes
vault_version n/a any n/a yes
vm_image_id n/a any n/a yes
vnet_name n/a any n/a yes
vnet_rg_name n/a any n/a yes

Outputs

No outputs.

iac-azure-vault-cluster's People

Contributors

cultclassik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.