这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.terraform
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# hashitalks-demo
# hashitalks-demo

This repo contains an example on how to use [Vault reponse wrapping](https://www.vaultproject.io/docs/concepts/response-wrapping/) feature to fetch Vault secrets from a Jenkins pipeline.

The example has been used during the [HashiTalks2020](https://events.hashicorp.com/hashitalks2020) "Vault Response Wrapping Makes Secret Zero Challenge A Piece Of Cake" presentation demo.

## terraform folder

Terraform configuration files to configure both the Jenkins pipeline AppRole and the wrapping policy.

## Jenkinsfile

Stages simplify the following workflow:

![Vault Response Wrapping Jenkins Workflow](/images/vault-jenkins-response-wrapping.png)

Binary file added images/vault-jenkins-response-wrapping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
resource "vault_mount" "hashitalks_kv" {
path = "kv"
type = "generic"
}

resource "vault_generic_secret" "demo_secrets" {
path = "kv/pipeline-secrets"

data_json = <<EOT
{
"secret-1": "i_am_a_secret",
"secret-2": "give_me_the_piece_of_cake"
}
EOT
depends_on = [vault_mount.hashitalks_kv]
}

resource "vault_policy" "pipeline_policy" {
name = "pipeline-policy"

policy = <<EOT
path "kv/data/pipeline-secrets" {
policy = "read"
}

path "kv/pipeline-secrets" {
policy = "read"
}
EOT
}

resource "vault_policy" "trusted_entity_policy" {
name = "trusted-entity"

policy = <<EOT
path "auth/pipeline/role/pipeline-approle/secret-id" {
policy = "write"
min_wrapping_ttl = "100s"
max_wrapping_ttl = "300s"
}
EOT
}

resource "vault_auth_backend" "pipeline_access" {
type = "approle"
path = "pipeline"
}

resource "vault_approle_auth_backend_role" "pipeline_approle" {
backend = vault_auth_backend.pipeline_access.path
role_name = "pipeline-approle"
secret_id_num_uses = "1"
secret_id_ttl = "300"
token_ttl = "1800"
token_policies = ["default", "pipeline-policy"]
}
11 changes: 11 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "pipeline_approle_roleid" {
value = vault_approle_auth_backend_role.pipeline_approle.role_id
}

output "pipeline_approle_path" {
value = vault_auth_backend.pipeline_access.path
}

output "pipeline_approle_rolename" {
value = vault_approle_auth_backend_role.pipeline_approle.role_name
}
5 changes: 5 additions & 0 deletions terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
provider "vault" {
address = var.vault_endpoint
namespace = var.namespace
max_retries = 5
}
7 changes: 7 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "vault_endpoint" {
type = string
}

variable "namespace" {
type = string
}