-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathecr.ts
35 lines (30 loc) · 1.21 KB
/
ecr.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import ecr = require('@aws-cdk/aws-ecr');
import { Construct } from '@aws-cdk/core';
import { ContainerDefinition } from '../container-definition';
import { ContainerImage, ContainerImageConfig } from '../container-image';
/**
* An image from an Amazon ECR repository.
*/
export class EcrImage extends ContainerImage {
/**
* The image name. Images in Amazon ECR repositories can be specified by either using the full registry/repository:tag or
* registry/repository@digest.
*
* For example, 012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:latest or
* 012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>@sha256:94afd1f2e64d908bc90dbca0035a5b567EXAMPLE.
*/
public readonly imageName: string;
/**
* Constructs a new instance of the EcrImage class.
*/
constructor(private readonly repository: ecr.IRepository, private readonly tag: string) {
super();
this.imageName = this.repository.repositoryUriForTag(this.tag);
}
public bind(_scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig {
this.repository.grantPull(containerDefinition.taskDefinition.obtainExecutionRole());
return {
imageName: this.imageName
};
}
}