Skip to content

Commit

Permalink
fix: ECR public registry uses us-east-1 region
Browse files Browse the repository at this point in the history
This commit fixes a bug related to ECR public registry
which is available only in us-east-1 region.
This is the error which will be fixed:
```
   Run tradeshift/actions-docker@v1
💡 AWS Public ECR detected with eu-west-1 region
⬇️ Retrieving docker login password through AWS CLI 2.1.24 (/usr/local/bin/aws)...
Error:
Could not connect to the endpoint URL: "https://api.ecr-public.eu-west-1.amazonaws.com/"
```
Snippet from [AWS documentation](https://docs.aws.amazon.com/AmazonECR/latest/public/getting-started-cli.html).
```
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
```
  • Loading branch information
arminioa committed Jul 20, 2023
1 parent cc5178a commit e2174bf
Show file tree
Hide file tree
Showing 5 changed files with 852 additions and 5,085 deletions.
20 changes: 19 additions & 1 deletion __tests__/aws.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isECRRepository} from '../src/aws';
import {isECRRepository, getRegion} from '../src/aws';

describe(isECRRepository, () => {
it('returns true when given an ECR repository', () => {
Expand All @@ -24,3 +24,21 @@ describe(isECRRepository, () => {
expect(isECRRepository('test/test')).toEqual(false);
});
});

describe('getRegion', () => {
it('returns us-east-1 when given an ECR public repository', () => {
expect(getRegion('public.ecr.aws/tradeshift/my-image')).toEqual(
'us-east-1'
);
});
it('returns eu-west-1 when given an ECR private repository in eu-west-1', () => {
expect(
getRegion('123456789012.dkr.ecr.eu-west-1.amazonaws.com/my-image')
).toEqual('eu-west-1');
});
it('returns cn-north-1 when given an ECR private repository in cn-north-1', () => {
expect(
getRegion('123456789012.dkr.ecr.cn-north-1.amazonaws.com.cn/my-image')
).toEqual('cn-north-1');
});
});
Loading

0 comments on commit e2174bf

Please sign in to comment.