[JIRA] (JENKINS-38220) Support for EC2 instance profile credentials

16 views
Skip to first unread message

bwalding@cloudbees.com (JIRA)

unread,
Sep 14, 2016, 7:17:01 PM9/14/16
to jenkinsc...@googlegroups.com
Ben Walding created an issue
 
Jenkins / Improvement JENKINS-38220
Support for EC2 instance profile credentials
Issue Type: Improvement Improvement
Assignee: Nicolas De Loof
Components: aws-credentials-plugin
Created: 2016/Sep/14 11:16 PM
Priority: Minor Minor
Reporter: Ben Walding

In our AWS environment we avoid using static AWS credentials (i.e. AWS Access Key ID and AWS Secret Access Key) - instead we use ephemeral credentials that are supplied using the Amazon IAM/STS system.

i.e. The use of static AWS credentials is not possible in our environment - we need to dynamically acquire credentials on the master / slave to. These credentials are then used to switch roles per our IAM configuration.

Once the credentials are acquired, we use those credentials (Access Key ID, Secret Access Key, Session Token) to perform AWS actions as normal.

An example

As a brief example (from a pipeline script)

  env.AWS_ACCESS_KEY_ID = ""
  env.AWS_SECRET_ACCESS_KEY = ""
  env.AWS_SESSION_TOKEN = ""

  roleArn = "arn:aws:iam::<13 character AWS ID>:role/my-custom-role"
  externalParam = "--external-id ABCDEFG" // security parameter - optional

  json = sh(returnStdout: true, 
            script: "aws sts assume-role --duration-seconds 3600 --role-arn ${roleARN} --role-session-name rsn ${externalParam}"

  def jsonSlurper = new groovy.json.JsonSlurperClassic()
  def object = jsonSlurper.parseText(json)

  return object.Credentials

Important points

  • external-id support required
  • credentials must be acquired on the correct instance (you can't always acquire on master as the security configuration is locked down per instance type)
  • credentials expire after an hour (maximum)
  • Access Key ID can be logged, but the other parameters should not be
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

kmadel@cloudbees.com (JIRA)

unread,
Oct 9, 2018, 9:56:02 AM10/9/18
to jenkinsc...@googlegroups.com
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

nicolas.deloof@gmail.com (JIRA)

unread,
Apr 24, 2019, 10:35:09 AM4/24/19
to jenkinsc...@googlegroups.com
Nicolas De Loof assigned an issue to Unassigned
 
Change By: Nicolas De Loof
Assignee: Nicolas De Loof

orion-ua@ukr.net (JIRA)

unread,
Jan 27, 2020, 7:15:02 AM1/27/20
to jenkinsc...@googlegroups.com
Oleksandr Shmyrko commented on Improvement JENKINS-38220
 
Re: Support for EC2 instance profile credentials

Kurt Madel, that solution still requires IAM role to be specified in Jenkins AWS credentials. EC2 instance profile policy should allow to assume IAM role (Action: sts:AssumeRole). So the idea is to use temporary IAM instance profile credentials directly without assuming IAM role.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

johnlabarge@gmail.com (JIRA)

unread,
Apr 17, 2020, 10:49:03 PM4/17/20
to jenkinsc...@googlegroups.com

Need this as well. 

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

orion-ua@ukr.net (JIRA)

unread,
Apr 18, 2020, 9:08:02 AM4/18/20
to jenkinsc...@googlegroups.com

johnlabarge@gmail.com (JIRA)

unread,
Apr 20, 2020, 1:59:03 PM4/20/20
to jenkinsc...@googlegroups.com
 
Re: Support for EC2 instance profile credentials

I'v noticed that there is a checkbox that is labeled as "Use EC2 instance profile to obtain credentials" but even if it's checked, if no private key is supplied it throws a NPE.  This seems incorrect or at least confusing to me.  Instead I'd propose that if that box is checked, no private key is required.  

If this is required to connect to the agent, that can be internalized instead with a temporary ssh key.  So in that case I would remove the logic that seeks to use the supplied private key and instead generate a key and use it silently. 

 

Thoughts? 

johnlabarge@gmail.com (JIRA)

unread,
Apr 20, 2020, 2:00:09 PM4/20/20
to jenkinsc...@googlegroups.com
John La Barge edited a comment on Improvement JENKINS-38220
I'v noticed that there is a checkbox that is labeled as "Use EC2 instance profile to obtain credentials" but even if it's checked, if no private key is supplied it throws a NPE.  This seems incorrect or at least confusing to me.  Instead I'd propose that if that box is checked, no private key is required.  

If this is required to connect to the agent, that can be internalized instead with a temporary ssh key.  So in that case I would remove the logic that seeks to use the supplied private key and instead generate a key and use it silently. 

 

Thoughts (before I start implementing the PR)

johnlabarge@gmail.com (JIRA)

unread,
Apr 20, 2020, 2:05:03 PM4/20/20
to jenkinsc...@googlegroups.com
John La Barge edited a comment on Improvement JENKINS-38220
I'v noticed that there is a checkbox that is labeled as "Use EC2 instance profile to obtain credentials" but even if it's checked, if no private key is supplied it throws a NPE.  This seems incorrect or at least confusing to me.  Instead I'd propose that if that box is checked, no private key is required.  

There are essentially two steps to getting the agent: 1) provisioning the ec2 instance - for which the instance credentials can be used and 2) connecting to the agent.  

If this is required to connect to the agent, that can be internalized instead with a temporary ssh key.  So in that case I would remove the logic that seeks to use the supplied private key and instead generate a key and use it silently. 

 


Thoughts (before I start implementing the PR) ? 
Reply all
Reply to author
Forward
0 new messages