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

JENKINS-63982 Support EC2/S3 Endpoints for AWS-CN Partition #531

Merged
merged 3 commits into from
Dec 4, 2020

Conversation

els-grazziotinf
Copy link
Contributor

AWS operates different Partitions such as US-GovCloud and AWS-CN.
This patch improves support for Jenkins instances operating
ec2-plugin in the AWS-CN partition as it has a different DNS Suffix
than those in US-based Amazon Web Services.

Copy link
Contributor

@MRamonLeon MRamonLeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I test it? I tried to set an alternate ec2 endpoint using https://ec2.cn-north-1.amazonaws.com.cn but the regions didn't get populated.

Do I have to be in China or china vpn or maybe some restriction I have?

I would like to take another approach to avoid the hack for comparing the region with cn-. For example by changing the connect method to pass to it the region instead of the endpoint, so the SDK is the one which calculate the final endpoint, not us. The only problem is how to pass the proxy configured in Jenkins.

@els-grazziotinf
Copy link
Contributor Author

How can I test it? I tried to set an alternate ec2 endpoint using https://ec2.cn-north-1.amazonaws.com.cn but the regions didn't get populated.

AWS-CN is a different partition, you need to be operating in it (e.g. EC2 Instance locally, or AWS-CN IAM Credentials). If you have AWS "global" credentials and try to access the AWS-CN region it won't do. If you check the logs, you probably received the following response from AWS API:

{code}
An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid
{code}

Do I have to be in China or china vpn or maybe some restriction I have?

You would need an AWS Account in AWS-CN. Due Chinese regulations you need identity verification, more information https://www.amazonaws.cn/en/about-aws/china/faqs/#beijing-account-cn

I would like to take another approach to avoid the hack for comparing the region with cn-. For example by changing the connect method to pass to it the region instead of the endpoint, so the SDK is the one which calculate the final endpoint, not us. The only problem is how to pass the proxy configured in Jenkins.

I wish the SDK had a better way of determining the partition, unfortunately I could not find a better way.
I'm not that versed in AWS Java SDK to refactor in the way you suggested, sorry.

AWS operates different Partitions such as US-GovCloud and AWS-CN.
This patch improves support for Jenkins instances operating
ec2-plugin in the AWS-CN partition as it has a different DNS Suffix
than those in US-based Amazon Web Services.
Copy link
Contributor

@MRamonLeon MRamonLeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM although I believe the S3 endpoint is never used, so we could remove the method. I approve anyway if you don't want to review this.

Copy link

@imuqtadir imuqtadir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

CHANGELOG.md Outdated Show resolved Hide resolved
@res0nance res0nance added the enhancement Feature additions or enhancements label Dec 3, 2020
@els-grazziotinf
Copy link
Contributor Author

LGTM although I believe the S3 endpoint is never used, so we could remove the method. I approve anyway if you don't want to review this.

I was going to remove it but saw Eucalyptus.java also has references to it, decided to play safe.

@MRamonLeon MRamonLeon merged commit a625a57 into jenkinsci:master Dec 4, 2020
@MRamonLeon
Copy link
Contributor

Thank you for your contribution @els-grazziotinf 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature additions or enhancements
Projects
None yet
4 participants