Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate with AWS dynamic secrets? #184

Open
Subhasis180689 opened this issue Jun 9, 2021 · 4 comments
Open

How to integrate with AWS dynamic secrets? #184

Subhasis180689 opened this issue Jun 9, 2021 · 4 comments
Labels

Comments

@Subhasis180689
Copy link

Hello,

We are trying to configure Jenkins vault URL and credentials with AWS dynamic secrets.
This seems to be working with approle but we are not sure how to configure with AWS. Need to understand how we actually generate the aws secret dynamically with jenkins vault plugin. Any code reference would be helpful

Version report
Jenkins and plugins versions report:

@copoka5
Copy link

copoka5 commented Jun 10, 2021

Hello. AWS dynamically secrets are an important part of CI/CD. Please help me to understand how can I use it?

@Subhasis180689
Copy link
Author

@muroj
Copy link

muroj commented Apr 12, 2022

I was struggling with the same: accessing aws backend to dynamically generate IAM credentials. I was able to get it working in my pipeline using the following:

stage('Vault-Test') {
steps {
    withVault(
      configuration: [
          timeout: 60, 
          engineVersion: 1, 
          vaultCredentialId: 'my-approle', vaultUrl: 'https://my-vault.net'], 
          vaultSecrets: [
          [
              path: 'aws/creds/my-iam-role', 
              secretValues: [
                  [envVar: 'AWS_SECRET_ACCESS_KEY', vaultKey: 'secret_key'], 
                  [envVar: 'AWS_ACCESS_KEY_ID', vaultKey: 'access_key'],
                  [envVar: 'AWS_SESSION_TOKEN', vaultKey: 'security_token']
              ]
          ]
      ]) {
              script {
                  sh '''
                    aws sts get-caller-identity
                  '''
              }
          }
      } // end steps
} // end stage

In my case, the key was setting engineVersion: 1. The plugin was assuming the secret was a KV, and was prefixing the secret path with data, i.e. aws/data/creds/my-role. See the vault doc for the differences between v1 and v2.

@kino505
Copy link

kino505 commented Apr 13, 2022

@muroj Excellent! Good job! Thank You so much! It is work. You are genius!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants