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

jx is creating my ECRs on region us-west-2, but nowhere have I set that. The cluster is in us-east-1 #1376

Closed
darthcabs opened this issue Jul 26, 2018 · 12 comments · Fixed by #1786 or #1999

Comments

@darthcabs
Copy link

darthcabs commented Jul 26, 2018

Summary

Even though I've installed Jenkins-X in a cluster on AWS Region us-east-1, all of the ECRs it creates for my apps are in us-west-2.

jx get aws correctly returns my AWS Account ID, but I can't tell where it's getting the region from.
~/.aws/config file is set to us-east-1 and I don't have a environment variable AWS_DEFAULT_REGION set.

Steps to reproduce the behavior

Deploy any app using jx import, wait until the ECR is created, then go to your AWS Console, move to Oregon region, then open Elastic Container Service -> ECR, and notice that the ECR repo for your app was created there.

Jx version

The output of jx version is:

jx                 1.3.118
jenkins x platform 0.0.1881
kubernetes cluster v1.9.8
kubectl            v1.11.0
helm client        v2.10.0-rc.1+gaa98e7e
helm server        v2.10.0-rc.1+gaa98e7e
git                git version 2.13.3

Kubernetes cluster

What kind of Kubernetes cluster are you using & how did you create it?

Cluster deployed using Kops, Jenkins-X installed later on.

Operating system / Environment

linux-amd

Expected behavior

jx should detect my AWS Region using file ~/.aws/config or Environment Variable AWS_DEFAULT_REGION

Actual behavior

Apparently it is assuming my region to be us-west-2

@titogeorge
Copy link

I am facing the same issue, not sure how to set the region to us-east-1.

$ jx --version
1.3.128
$ jx create cluster aws --verbose --zones us-east-1a,us-east-1b,us-east-1c
? nodes 3

Creating S3 bucket kops-state-129800309922-a16d149f-928c-11e8-b3bb-1c1b0d3f42ba to store kops state
error: IllegalLocationConstraintException: The us-west-1 location constraint is incompatible for the region specific endpoint this request was sent to.
	status code: 400, request id: A1766445084F3E50, host id: Sgcw23BqadpLiaworOd84iO6qupYyPxJH2OnW6K7XxrXdEJABHtvwldqyF+egGPLMpNwhoq/uuo=

Running on Ubuntu 18.04.

@rodrigodelmonte
Copy link

I was facing the same problem, after some research in the code I've realized that it expects AWS_REGION instead of AWS_DEFAULT_REGION.

https://github.com/jenkins-x/jx/blob/718d314f3d144f7d53a282f08874fe564e7ef879/pkg/cloud/amazon/ecr.go#L37:L46

After I've set AWS_REGION worked for me.

@titogeorge
Copy link

titogeorge commented Aug 3, 2018

Yes, that worked. thanks @rodrigodelmonte

I was hoping it to get from the .aws/credentials

@ankushganatra
Copy link

ankushganatra commented Aug 23, 2018

It doesn't seem to be taking region as ap-southeast-1

export AWS_REGION=ap-southeast-1

still fails

jx create cluster aws --zones ap-southeast-1a
? nodes 3
Creating S3 bucket kops-state-701700970941-8bae5b1a-a6ce-11e8-af98-acbc32b16de3 to store kops state
error: IllegalLocationConstraintException: The us-west-1 location constraint is incompatible for the region specific endpoint this request was sent to.
status code: 400, request id: 54DEB32A6868F92E, host id: Bpn+BW3BvXqkoSADjYT6BBdtgBS4qfv8JoGpB5DCgg2Q+/4NJSeVCkXA=

@shierro
Copy link

shierro commented Aug 27, 2018

also doesn't work on my end

AWS_DEFAULT_REGION=ap-southeast-2 AWS_REGION=ap-southeast-2 jx create cluster aws --zones ap-southeast-2

error: IllegalLocationConstraintException: The us-west-1 location constraint is incompatible for the region specific endpoint this request was sent to.
	status code: 400, request id: 3AB2D76DC5AC6792, host id: AJ4pPIngEHktTBvHnr1XIecAi/Fr0H9dH24bwtZQV0WXRygIABrZuY2t5kzpnUJhPZb6vsMxgsk=

@ijcd
Copy link

ijcd commented Aug 29, 2018

Maybe this is the problem?

location, err := amazon.CreateS3Bucket(bucketName, "us-west-1")

jvz added a commit to jvz/jx that referenced this issue Sep 25, 2018
This fixes jenkins-x#1376 and jenkins-x#1453 by using the AWS region resolved by either
the AWS_REGION or AWS_DEFAULT_REGION environment variables instead of
hardcoding us-west-1.
jvz added a commit to jvz/jx that referenced this issue Sep 25, 2018
This fixes jenkins-x#1376 by using the AWS region resolved by either the
AWS_REGION or AWS_DEFAULT_REGION environment variables instead of
hardcoding us-west-1.
@hekonsek
Copy link

hekonsek commented Sep 26, 2018

Please try to use the latest version of jx. I've fixed a couple of AWS region related issues there. I had the same issue with ECR push and those changes did the job for me.

@msvticket
Copy link
Contributor

This is not solved. jx still doesn't create the ECR repository in in the region used by the cluster. What would make sense to me is using the registry stored in configmap jenkins-x-docker-registry.

@StephenWangasg
Copy link

This is because you have multiple AWSCLI profiles, and you create the cluster using a non-default profile with 'jx create cluster eks --profile xxx', but jx will always create ECR using the default profile.

@hekonsek
Copy link

hekonsek commented Jan 11, 2019

If you send me...

  • commands you execute for creating cluster
  • list of your profiles (including regions they use)
  • your AWS config file
  • your AWS_* env variables (WITHOUT your credentials of course until you want me to start mining Bitcoin on your AWS infrastructure ;) )

...I could try to tell your what is the issue and/or create PR with fix for this.

@hekonsek
Copy link

OK, @StephenWangasg suggestion is right. The issue is here -

sess, err := NewAwsSession("", GetRegionFromContainerRegistryHost(dockerRegistry))
as AWS profiles support is relatively new thing. I will fix it.

@hekonsek
Copy link

hekonsek commented Jan 14, 2019

Actually just figured out that even if profile is not passed, there is information about ECR region saved in ConfigMap. So still this value should be read from it.

So again, I need this #1376 (comment) input to help you :) .

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 a pull request may close this issue.

9 participants