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

Configurable AWS_SESSION_TOKEN env variable #90

Open
TWood67 opened this issue Jul 20, 2021 · 3 comments
Open

Configurable AWS_SESSION_TOKEN env variable #90

TWood67 opened this issue Jul 20, 2021 · 3 comments

Comments

@TWood67
Copy link

TWood67 commented Jul 20, 2021

Dependencies

None

Feature Request

Our cloud strategy is setup so that each deploy environment is its own AWS account. To provide feedback quickly to our users, we run cloud formation diffs in parallel for each AWS account. This normally works as expected, however we sometimes run into a race condition where the session token is overriden by another task in parallel execution. This results in a security token error from AWS.

I'd like to propose a feature that allows the AWS_SESSION_TOKEN environment variable to be configurable. Using this plugin in conjunction with withEnv, we can ensure that each task in parallel execution is using the correct AWS session.

Example:

node('build') {
    def tasks = [:]
    tasks['1'] = {
       withCredentials([[
         $class: 'AmazonWebServicesCredentialsBinding', 
         accessKeyVariable: 'AWS_ACCESS_KEY_ID_DEV', 
         credentialsId: 'dev-account', 
         secretKeyVariable: 'AWS_SECRET_ACCESS_KEY_DEV',
         sessionTokenVaribale: 'AWS_SESSION_TOKEN_DEV']]
       ) {
           withEnv([
             'AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_DEV',
             'AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_DEV',
             'AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN_DEV'
           ]) {
            //code
          }
        }
    }
    tasks['2'] = {
       withCredentials([[
         $class: 'AmazonWebServicesCredentialsBinding', 
         accessKeyVariable: 'AWS_ACCESS_KEY_ID_TEST', 
         credentialsId: 'test-account', 
         secretKeyVariable: 'AWS_SECRET_ACCESS_KEY_TEST',
         sessionTokenVaribale: 'AWS_SESSION_TOKEN_TEST']]
       ) {
           withEnv([
             'AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_TEST',
             'AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_TEST',
             'AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN_TEST'
           ]) {
            //code
          }
        }
    }
    parallel tasks
}
@TWood67
Copy link
Author

TWood67 commented Jul 20, 2021

I see there is an existing PR for this, but it has not been touched in a year. Is there someone who can take a look?
#74

@littlejo
Copy link

littlejo commented Jan 5, 2022

I also need this fix :)

@SushanSuresh
Copy link

I am also waiting for this.

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

No branches or pull requests

3 participants