Skip to content

Conversation

@foglia-prometeia
Copy link

Added iamRoleRegion as attribute in:

  • AmazonWebServicesCredentialsBinding.java
    • updated constructor
    • updated assumeRoleProvider --> in buildStsClient now iamRoleRegion attribute is passed as argument
  • AWSCredentialsImpl.java
    • updated constructor and overloaded for compatibility
    • updated buildStsClient to include iamRoleRegion as parameter --> clientRegion now dynamically switches to determineClientRegion() if iamRoleRegion is null/empty
    • updated getCredentials() --> updated buildStsClient in order to match the updated method
  • credentials.jelly
    • added entry under iamRoleArn for iamRoleRegion as textbox
  • Added help-iamRoleRegion.html for help message

GUI Changes

Before
image

After
image

Testing done

We created this simple use case:

pipeline {
    agent any
    parameters {
        string(name: 'region', defaultValue: "")
        string(name: 'credential', defaultValue: "")
    }
    stages {
        stage('TEST') {
            steps {
                withCredentials([[
                    $class: 'AmazonWebServicesCredentialsBinding',
                    credentialsId: "${params.credential}",
                    accessKeyVariable: 'AWS_ACCESS_KEY_ID',
                    secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
                ]]) {
                    sh "aws sts get-caller-identity --region ${params.region}"
                }
            }
        }

    }
}

Problem found before iamRoleRegion
Using the provided test over a credential:role we encountered this error "The security token included in the request is invalid" caused by the role being assumed in a different region then the target region for the aws cli operations.
Thus to solve this problem iamRoleRegion has been added to the plugin Credential.

### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue

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

Successfully merging this pull request may close these issues.

1 participant