Hashicorp Vault
And Jenkins
Leveraging AWS IAM to empower a hybrid scenario.
There was a time where…
InfoSec team requesting more visibility on secrets usage
in pipelines
Credentials were stored in Jenkins on-premise
Vault in AWS to be integrated
Secret-Zero challenges over approles
Personal Tokens for running our automation
What we are going to cover
What we are going to cover
Trust
between
Jenkins
and vault
What we are going to cover
Trust
between
Jenkins
and vault
Vault
encapsulation
in shared
library
What we are going to cover
Trust
between
Jenkins
and vault
Vault
encapsulation
in shared
library
Provision Vault’s
resources in
automated
fashion
Senior DevOps Engineer
YNAP
he/him
Piermarco
Zerbini
DevOps Engineer
YNAP
he/him
Kevin
De Notariis
q YNAP Ecosystem
q AWS Serverless Solution to Inject Approle Creds in Jenkins
q Governance as Code via Shared Library
q Vault & Cloud Governance
q InfoSec Benefits
Agenda
Ø YNAP Ecosystem
q AWS Serverless Solution to Inject Approle Creds in Jenkins
q Governance as Code via Shared Library
q Vault & Cloud Governance
q InfoSec Benefits
01 YNAP Ecosystem
Jenkins & Bitbucket
01 YNAP Ecosystem
Jenkins & Bitbucket
Multi Tenant – Multi branch pipelines
01 YNAP Ecosystem
Jenkins & Bitbucket
Multi Tenant – Multi branch pipelines
Worker Nodes – General purpose
01 YNAP Ecosystem
Jenkins & Bitbucket
Multi Tenant – Multi branch pipelines
Worker Nodes – General purpose
Minimisation of Jenkins’ Configuration Management
01 YNAP Ecosystem
Jenkins & Bitbucket
01 YNAP Ecosystem
Vault Implementation
01 YNAP Ecosystem
Namespace Segregation
Vault Implementation
01 YNAP Ecosystem
Namespace Segregation
Vault’s Administrator à access to Root Namespace
Vault Implementation
01 YNAP Ecosystem
Namespace Segregation
Vault’s Administrator à access to Root Namespace
Organization’s Central teams à access to Next Layer
Vault Implementation
01 YNAP Ecosystem
Namespace Segregation
Vault’s Administrator à access to Root Namespace
Organization’s Central teams à access to Next Layer
Application’s teams à access to Third Layer
Vault Implementation
01 YNAP Ecosystem
Vault Implementation
01 YNAP Ecosystem
Jenkins’ approle
Where should I set the trust between Jenkins and Vault?
01 YNAP Ecosystem
Jenkins’ approle
Where should I set the trust between Jenkins and Vault?
Jenkins Controller à NO à Multi-tenancy
01 YNAP Ecosystem
Jenkins’ approle
Where should I set the trust between Jenkins and Vault?
Jenkins Controller à NO à Multi-tenancy
Jenkins Agents à NO à No dedicated Agents
01 YNAP Ecosystem
Jenkins’ approle
Where should I set the trust between Jenkins and Vault?
Jenkins Controller à NO à Multi-tenancy
Jenkins Agents à NO à No dedicated Agents
Jenkins Project à YES à Need to create a proper mapping
01 YNAP Ecosystem
Jenkins’ approle
Where should I set the trust between Jenkins and Vault?
Jenkins Controller à NO à Multi-tenancy
Jenkins Agents à NO à No dedicated Agents
Jenkins Project à YES à Need to create a proper mapping
Jenkins Pipelines à NO à Cost-efforts/Benefits-balance not worth
ü YNAP Ecosystem
Ø AWS Serverless Solution to Inject Approle Creds in Jenkins
q Governance as Code via Shared Library
q Vault & Cloud Governance
q InfoSec Benefits
Vault Namespace Deploy
-- The beginning --
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Vault Namespace Deploy
-- The beginning --
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Namespace deploy via Jenkins using
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Namespace deploy via Jenkins using
S3 Bucket for Terraform .tfstate on AWS
Vault Namespace Deploy
-- The beginning --
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Namespace deploy via Jenkins using
S3 Bucket for Terraform .tfstate on AWS
Personal Token manually placed at pipeline runtime
Vault Namespace Deploy
-- The beginning --
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Namespace deploy via Jenkins using
S3 Bucket for Terraform .tfstate on AWS
Personal Token manually placed at pipeline runtime
Leveraging Jenkins’ Creds Storage
Vault Namespace Deploy
-- The beginning --
Trust Manager – Fargate
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Trust Manager – Fargate
Project/Namespace Mapping nsible Inventory
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Trust Manager – Fargate
Project/Namespace Mapping nsible Inventory
Image Created with
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Trust Manager – Fargate
Project/Namespace Mapping nsible Inventory
Image Created with
Defined via IAC
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Trust Manager – Fargate
Project/Namespace Mapping nsible Inventory
Image Created with
Defined via IAC
Vault Agent On-Board
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Set up / Pre-requisites
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
Set up / Pre-requisites
Define Trust Manager IAM Role
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
IAM Role
logs: createLogStream, putLogEvents
cloudwatch: putMetricData
s3Get*
s3:List*
Set up / Pre-requisites
Define Trust Manager IAM Role
Create AWS Auth method in Vault
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
TERMINAL
Creating AWS Auth method role
> vault write –namespace=ynap auth/aws/role/trust-manager 
auth_type=iam 
policies=trust-manager 
token_max_ttl=10m 
token_ttl=5m 
bound_iam_principal_arn=arn:aws:<region>:<account_id>:trustManagerRole
Set up / Pre-requisites
Define Trust Manager IAM Role
Create AWS Auth method in Vault
Request the Jenkins’ API Keys
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
/(Root)
/ynap
/vault-admin
Jenkins admins
Namespaces
Place API Keys
Set up / Pre-requisites
Define Trust Manager IAM Role
Create AWS Auth method in Vault
Request the Jenkins’ API Keys
Team’s Namespaces provisioned
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
NAMESPACE=new-namespace 
make namespace/add
Update inventory 1
NAMESPACE=new-namespace 
make namespace/add
Update inventory 1
NAMESPACE=new-namespace 
make namespace/add
2
Grab template
Update inventory 1
NAMESPACE=new-namespace 
make namespace/add
2
Grab template 3
Generate
terraform
code
Update inventory 1
NAMESPACE=new-namespace 
make namespace/add
2
Grab template 3
Generate
terraform
code
4
1. Leverage AWS Auth
Method against /(Root)
2. Deploy Namespace
Trust Manager
02 AWS Serverless Solution to Inject Approle Creds in Jenkins
1 Hr
Trust Manager
1 Hr
Trust Manager
1
Login via
AWS Auth Method
1 Hr
Trust Manager
1
Login via
AWS Auth Method
2
Generate
Approle Creds
1 Hr
Trust Manager
1
Login via
AWS Auth Method
2
Generate
Approle Creds
3
Fetch Jenkins’
API Keys
1 Hr
Trust Manager
1
Login via
AWS Auth Method
2
Generate
Approle Creds
3
4
Fetch Jenkins’
API Keys
Inject
Approles
1 Hr
Trust Manager
1
Login via
AWS Auth Method
2
Generate
Approle Creds
3
4
Fetch Jenkins’
API Keys
Inject
Approles
1 Hr
Trust Manager
1
Login via
AWS Auth Method
2
Generate
Approle Creds
3
4
Fetch Jenkins’
API Keys
Inject
Approles
1 Hr
Trust Manager
1
Login via
AWS Auth Method
2
Generate
Approle Creds
3
4
Fetch Jenkins’
API Keys
Inject
Approles
1 Hr
Trust Manager
Uploads
Cloudwatch Custom Metrics
5
1
Login via
AWS Auth Method
2
Generate
Approle Creds
3
4
Fetch Jenkins’
API Keys
Inject
Approles
ü YNAP Ecosystem
ü AWS Serverless Solution to Inject Approle Creds in Jenkins
Ø Governance as Code via Shared Library
q Vault & Cloud Governance
q InfoSec Benefits
03 Governance as Code via Shared Library
Governance
03 Governance as Code via Shared Library
Governance
Specific path where AWS creds can be stored in Vault
kv
Defined by Vault’s
Administrators & InfoSec
Defined by the InfoSec
and Team giving creds
kv
Defined by Vault’s
Administrators & InfoSec
Defined by the InfoSec
and Team giving creds
kv / the-team-giving-creds / aws-creds / aws-account-name
E.g.
kv
Defined by Vault’s
Administrators & InfoSec
Defined by the InfoSec
and Team giving creds
kv / the-team-giving-creds / aws-creds / aws-account-name
> Thanks to policy templating with metadata associated to entities
E.g.
Capabilities
Admin
List
Capabilities
Admin Central Team
List Write
Capabilities
Admin Central Team User
List List
Write
Capabilities
Admin Central Team User Pipelines
List List
Write Read
03 Governance as Code via Shared Library
Governance
Specific path where AWS creds can be stored in Vault
Specific form of AWS creds secret’s keys
03 Governance as Code via Shared Library
Governance
Specific path where AWS creds can be stored in Vault
Specific form of AWS creds secret’s keys
Specific structure of AWS Account names
03 Governance as Code via Shared Library
Governance
Specific path where AWS creds can be stored in Vault
Specific form of AWS creds secret’s keys
Specific structure of AWS Account names
Namespace <–> Project association
03 Governance as Code via Shared Library
Jenkins Shared Library
03 Governance as Code via Shared Library
Jenkins Shared Library
Seamless integration of AWS Auth using creds stored in vault
Easy to use
Simply import the library and leverage
the auth method function.
03 Governance as Code via Shared Library
Jenkins Shared Library
Seamless integration of AWS Auth using creds stored in vault
Encapsulated authentication
kv / the-team-giving-creds / aws-creds / aws-account-name
kv / the-team-giving-creds / aws-creds / aws-account-name
kv / the-team-giving-creds / aws-creds / aws-account-name
kv / the-team-giving-creds / aws-creds / aws-account-name
03 Governance as Code via Shared Library
Jenkins Shared Library
Seamless integration of AWS Auth using creds stored in vault
Encapsulated authentication
Centralised way of handling AWS auth via pipelines
03 Governance as Code via Shared Library
Jenkins Shared Library
Seamless integration of AWS Auth using creds stored in vault
Encapsulated authentication
Centralised way of handling AWS auth via pipelines
High maintainability and no refactor needed for stakeholders in
case of authentication changes
ü YNAP Ecosystem
ü AWS Serverless Solution to Inject Approle Creds in Jenkins
ü Governance as Code via Shared Library
Ø Vault & Cloud Governance
q InfoSec Benefits
Vault & Cloud Governance
04
IAM Provisioning Role
Vault & Cloud Governance
04
IAM Provisioning Role
Pipelines interact with AWS via an IAM Provisioning Role (even before Vault)
Jenkins Pipelines
Credentials Storage
1
Extract
AWS creds
Jenkins Pipelines
Credentials Storage
1
Extract
AWS creds 2
Login
Jenkins Pipelines
Credentials Storage
1
Extract
AWS creds 2
Login
Get
Valid
session
3
Jenkins Pipelines
Credentials Storage
1
Extract
AWS creds 2
Login
Get
3
Extract
Approle creds
+
Get AWS creds
from vault
Valid
session
Vault & Cloud Governance
04
IAM Provisioning Role
Pipelines interact with AWS via an IAM Provisioning Role (even before Vault)
Leverage AWS Auth Method
Login via
Approle
Read
Capabilities
1
Login via
Approle
Read AWS
Creds
Read
Capabilities
1 2
Login via
Approle
Read AWS
Creds
3 Login
Account hosting
Vault’s
infrastructure
Read
Capabilities
1 2
Login via
Approle
Read AWS
Creds
3 Login
Account hosting
Vault’s
infrastructure
Read
Capabilities
1 2
Login via
Approle
Read AWS
Creds
3 Login
Login via
AWS Auth
method
Account hosting
Vault’s
infrastructure
Read
Capabilities
1
Write
Capabilities
2 4
Login via
Approle
Read AWS
Creds
3 Login
Login via
AWS Auth
method
Account hosting
Vault’s
infrastructure
Provision
Read
Capabilities
5
1
Write
Capabilities
2 4
Vault & Cloud Governance
04
IAM Provisioning Role
Pipelines interact with AWS via an IAM Provisioning Role (even before Vault)
Leverage AWS Auth Method
Creating Policies, entities, aliases for IAM Provisioning Roles
Vault & Cloud Governance
04
IAM Provisioning Role
Pipelines interact with AWS via an IAM Provisioning Role (even before Vault)
Leverage AWS Auth Method
Creating Policies, entities, aliases for IAM Provisioning Roles
Provisioning Vault Namespaces without inserting personal Token…
…Finally
ü YNAP Ecosystem
ü AWS Serverless Solution to Inject Approle Creds in Jenkins
ü Governance as Code via Shared Library
ü Vault & Cloud Governance
Ø InfoSec Benefits
InfoSec Benefits
05
Splunk Auditing
InfoSec Benefits
05
Splunk Auditing
Which namespaces are using AWS Auth method
Requests to Login via AWS auth method for each namespace
Query
Pie Chart
InfoSec Benefits
05
Which namespaces are using AWS Auth method
See which Bitbucket Projects are using Jenkins Approles
Splunk Auditing
Bitbucket Projects Using Jenkins Approles
Query
Pie Chart
InfoSec Benefits
05
Which namespaces are using AWS Auth method
See which Bitbucket Projects are using Jenkins Approles
Which namespaces our Trust Manager processed
Splunk Auditing
Namespaces Processed by our Trust Manager
Query
Pie Chart
InfoSec Benefits
05
Which namespaces are using AWS Auth method
See which Bitbucket Projects are using Jenkins Approles
Which namespaces our Trust Manager processed
AWS credentials read from Vault
Splunk Auditing
Namespaces Processed by our Trust Manager
Pie Chart
Query
Recap
Recap
AWS auth Method + AWS Fargate = Trust Jenkins-Vault
Recap
AWS auth Method + AWS Fargate = Trust Jenkins-Vault
Company process enhancement thanks to Vault’s
adoption and governance
Recap
AWS auth Method + AWS Fargate = Trust Jenkins-Vault
Company process enhancement thanks to Vault’s
adoption and governance
Company processes encapsulated in shared library
Recap
AWS auth Method + AWS Fargate = Trust Jenkins-Vault
Company process enhancement thanks to Vault’s
adoption and governance
Company processes encapsulated in shared library
Provision Vault’s resources in automated fashion
Recap
AWS auth Method + AWS Fargate = Trust Jenkins-Vault
Company process enhancement thanks to Vault’s
adoption and governance
Company processes encapsulated in shared library
Provision Vault’s resources in automated fashion
InfoSec visibility
Thank You
piermarco.zerbini@ynap.com | kevin.denotariis@ynap.com

HashiTalk