1 | ;
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.RepositoryImage = void 0;
|
5 | const jsiiDeprecationWarnings = require("../../.warnings.jsii.js");
|
6 | const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
7 | const core_1 = require("@aws-cdk/core");
|
8 | const container_image_1 = require("../container-image");
|
9 | /**
|
10 | * Regex pattern to check if it is an ECR image URL.
|
11 | *
|
12 | */
|
13 | const ECR_IMAGE_REGEX = /(^[a-zA-Z0-9][a-zA-Z0-9-_]*).dkr.ecr.([a-zA-Z0-9][a-zA-Z0-9-_]*).amazonaws.com(.cn)?\/.*/;
|
14 | /**
|
15 | * An image hosted in a public or private repository. For images hosted in Amazon ECR, see
|
16 | * [EcrImage](https://docs.aws.amazon.com/AmazonECR/latest/userguide/images.html).
|
17 | */
|
18 | class RepositoryImage extends container_image_1.ContainerImage {
|
19 | /**
|
20 | * Constructs a new instance of the RepositoryImage class.
|
21 | */
|
22 | constructor(imageName, props = {}) {
|
23 | super();
|
24 | this.imageName = imageName;
|
25 | this.props = props;
|
26 | try {
|
27 | jsiiDeprecationWarnings._aws_cdk_aws_ecs_RepositoryImageProps(props);
|
28 | }
|
29 | catch (error) {
|
30 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
31 | Error.captureStackTrace(error, RepositoryImage);
|
32 | }
|
33 | throw error;
|
34 | }
|
35 | }
|
36 | bind(scope, containerDefinition) {
|
37 | try {
|
38 | jsiiDeprecationWarnings._aws_cdk_aws_ecs_ContainerDefinition(containerDefinition);
|
39 | }
|
40 | catch (error) {
|
41 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
42 | Error.captureStackTrace(error, this.bind);
|
43 | }
|
44 | throw error;
|
45 | }
|
46 | // name could be a Token - in that case, skip validation altogether
|
47 | if (!core_1.Token.isUnresolved(this.imageName) && ECR_IMAGE_REGEX.test(this.imageName)) {
|
48 | core_1.Annotations.of(scope).addWarning("Proper policies need to be attached before pulling from ECR repository, or use 'fromEcrRepository'.");
|
49 | }
|
50 | if (this.props.credentials) {
|
51 | this.props.credentials.grantRead(containerDefinition.taskDefinition.obtainExecutionRole());
|
52 | }
|
53 | return {
|
54 | imageName: this.imageName,
|
55 | repositoryCredentials: this.props.credentials && {
|
56 | credentialsParameter: this.props.credentials.secretArn,
|
57 | },
|
58 | };
|
59 | }
|
60 | }
|
61 | exports.RepositoryImage = RepositoryImage;
|
62 | _a = JSII_RTTI_SYMBOL_1;
|
63 | RepositoryImage[_a] = { fqn: "@aws-cdk/aws-ecs.RepositoryImage", version: "1.204.0" };
|
64 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3NpdG9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlcG9zaXRvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQ0Esd0NBQW1EO0FBRW5ELHdEQUEwRTtBQU0xRTs7O0dBR0c7QUFDSCxNQUFNLGVBQWUsR0FBRywwRkFBMEYsQ0FBQztBQWFuSDs7O0dBR0c7QUFDSCxNQUFhLGVBQWdCLFNBQVEsZ0NBQWM7SUFFakQ7O09BRUc7SUFDSCxZQUE2QixTQUFpQixFQUFtQixRQUE4QixFQUFFO1FBQy9GLEtBQUssRUFBRSxDQUFDO1FBRG1CLGNBQVMsR0FBVCxTQUFTLENBQVE7UUFBbUIsVUFBSyxHQUFMLEtBQUssQ0FBMkI7Ozs7OzsrQ0FMdEYsZUFBZTs7OztLQU96QjtJQUVNLElBQUksQ0FBQyxLQUFvQixFQUFFLG1CQUF3Qzs7Ozs7Ozs7OztRQUN4RSxtRUFBbUU7UUFDbkUsSUFBSSxDQUFDLFlBQUssQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLGVBQWUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQ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