Vault/Install
Vault是一套由HashiCorp開發的密碼管理軟體。
概要
Vault可以拿來存放各類credential資料,像是Key或是Password。
安裝
Vault是單執行檔,建議安裝的路徑是/usr/local/bin/vault
,這點沒有在官方的文件裡提到,但官方的範例常使用這個路徑[1]。
以Linux版的例子來說:
cd /tmp; wget -c https://releases.hashicorp.com/vault/1.4.3/vault_1.4.3_linux_amd64.zip; unzip vault_1.4.3_linux_amd64.zip; sudo cp vault /usr/local/bin/vault; sudo chmod 755 /usr/local/bin/vault
設定
這邊是設定成:
- 使用AWS KMS加解密。
- 使用Amazon DynamoDB當作儲存空間。
AWS
DynamoDB
建立一個表格(這邊叫vault
),依照官方的設計:
- Primary partition key設為
Path
(string)。 - Primary sort key設為
Key
(string)。
量很少時可以考慮使用on-demand模式按照讀寫的量計費,而非以保證讀寫的容量計費。
KMS
使用SYMMETRIC_DEFAULT
建立即可。
IAM
建立使用者並且產生對應的AWS key(access_key
與secret_key
)。
接著掛入對應的Inline Policy Policy-Vault-DynamoDB
,需要修改帳戶編號(這邊是123456789012
)與DynamoDB的表格名稱部份(這邊是vault
):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:DescribeTable",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:ListTagsOfResource",
"dynamodb:Query",
"dynamodb:UpdateItem",
"dynamodb:DescribeTimeToLive",
"dynamodb:GetRecords"
],
"Resource": [
"arn:aws:dynamodb:ap-southeast-1:123456789012:table/vault/stream/*",
"arn:aws:dynamodb:ap-southeast-1:123456789012:table/vault/index/*",
"arn:aws:dynamodb:ap-southeast-1:123456789012:table/vault"
]
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"dynamodb:DescribeReservedCapacityOfferings",
"dynamodb:ListTables",
"dynamodb:DescribeReservedCapacity",
"dynamodb:DescribeLimits"
],
"Resource": "*"
}
]
}
以及Policy-Vault-KMS
,需要修改帳戶編號(這邊是123456789012
)與KMS的Key ID部份(UUID格式,這邊是01234567-89ab-cdef-0123-456789abcdef
):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:ap-southeast-1:123456789012:key/01234567-89ab-cdef-0123-456789abcdef"
}
]
}
/etc/vault.d/vault.hcl
Vault的設定檔建議的路徑是/etc/vault.d/vault.hcl
,這點沒有在官方的文件裡提到,但官方的範例常使用這個路徑[1]。需要修改自己的網路位置(這邊使用10.10.10.10
)。
api_addr = "http://10.10.10.10:8200"
cluster_addr = "http://10.10.10.10:8201"
log_level = "Info"
listener "tcp" {
address = "0.0.0.0:8200"
cluster_address = "10.10.10.10:8201"
tls_disable = "true"
}
seal "awskms" {
region = "ap-southeast-1"
access_key = "x"
secret_key = "x"
kms_key_id = "x"
}
storage "dynamodb" {
ha_enabled = "true"
region = "ap-southeast-1"
table = "vault"
access_key = "x"
secret_key = "x"
}
初始化
第一次執行時需要初始化:
vault operator init -recovery-shares=1 -recovery-threshold=1 -address=http://10.10.10.10:8200
參考文獻
- ↑ 1.0 1.1 Vault Deployment Guide. [2020-07-15] (English).
外部連結
- 官方網站 (英文)