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

Created on 26 Jul 2018  路  12Comments  路  Source: jenkins-x/jx

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

All 12 comments

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.

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.

Yes, that worked. thanks @rodrigodelmonte

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

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=

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=

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.

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.

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.

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.

OK, @StephenWangasg suggestion is right. The issue is here - https://github.com/jenkins-x/jx/blob/7fb4656e37f16743d9ab18e07ea7de97d870d99e/pkg/cloud/amazon/ecr.go#L68 as AWS profiles support is relatively new thing. I will fix it.

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 https://github.com/jenkins-x/jx/issues/1376#issuecomment-453445506 input to help you :) .

Was this page helpful?
0 / 5 - 0 ratings