1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+
14import "source-map-support/register" ;
2- import * as cdk from 'aws-cdk-lib' ;
3- import {
4- Stack ,
5- StackProps ,
6- aws_ecr as ecr ,
7- aws_iam as iam ,
8- RemovalPolicy
9- } from "aws-cdk-lib" ;
5+ import * as cdk from "aws-cdk-lib" ;
6+ import { Stack , StackProps , aws_ecr as ecr , RemovalPolicy } from "aws-cdk-lib" ;
107import { type Construct } from "constructs" ;
11- import { readAccountConfig } from ".. /../config/targets " ;
8+ import { readAccountConfig } from "./.. /../config/types " ;
129
1310class ImageStack extends Stack {
1411 constructor ( scope : Construct , id : string , props ?: StackProps ) {
@@ -18,28 +15,11 @@ class ImageStack extends Stack {
1815
1916 for ( const language of Object . keys ( acctConfig ) ) {
2017 if ( acctConfig [ language ] . status === "enabled" ) {
21- const repository = new ecr . Repository ( this , `${ language } -examples` , {
18+ new ecr . Repository ( this , `${ language } -examples` , {
2219 repositoryName : `${ language } ` ,
2320 imageScanOnPush : true ,
2421 removalPolicy : RemovalPolicy . RETAIN ,
2522 } ) ;
26-
27- // Add repository policy to allow access from the specified account
28- repository . addToResourcePolicy ( new iam . PolicyStatement ( {
29- effect : iam . Effect . ALLOW ,
30- principals : [
31- new iam . AccountPrincipal ( acctConfig [ language ] . account_id )
32- ] ,
33- actions : [
34- "ecr:GetDownloadUrlForLayer" ,
35- "ecr:BatchGetImage" ,
36- "ecr:BatchCheckLayerAvailability" ,
37- "ecr:PutImage" ,
38- "ecr:InitiateLayerUpload" ,
39- "ecr:UploadLayerPart" ,
40- "ecr:CompleteLayerUpload"
41- ]
42- } ) ) ;
4323 }
4424 }
4525 }
@@ -52,7 +32,6 @@ new ImageStack(app, "ImageStack", {
5232 account : process . env . CDK_DEFAULT_ACCOUNT ! ,
5333 region : process . env . CDK_DEFAULT_REGION ! ,
5434 } ,
55- terminationProtection : true
5635} ) ;
5736
58- app . synth ( ) ;
37+ app . synth ( ) ;
0 commit comments