Skip to content

Commit 590dbf1

Browse files
author
Yuriy Bezsonov
committed
Add Ecr
1 parent b8a62d8 commit 590dbf1

8 files changed

Lines changed: 126 additions & 92 deletions

File tree

apps/unicorn-store-spring/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN yum install -y shadow-utils
55
COPY ./pom.xml ./pom.xml
66
COPY src ./src/
77

8-
RUN mvn clean package && mv target/store-spring-1.0.0-exec.jar store-spring.jar
8+
RUN mvn clean package -DskipTests -ntp && mv target/store-spring-1.0.0-exec.jar store-spring.jar
99
RUN rm -rf ~/.m2/repository
1010

1111
RUN groupadd --system spring -g 1000

infra/cdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212
<maven.compiler.source>25</maven.compiler.source>
1313
<maven.compiler.target>25</maven.compiler.target>
14-
<cdk.version>2.224.0</cdk.version>
14+
<cdk.version>2.233.0</cdk.version>
1515
<constructs.version>10.4.2</constructs.version>
1616
<cdknag.version>2.36.2</cdknag.version>
1717
<junit.version>5.11.3</junit.version>

infra/cdk/src/main/java/sample/com/constructs/Unicorn.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import software.amazon.awscdk.CustomResource;
44
import software.amazon.awscdk.Duration;
5+
import software.amazon.awscdk.RemovalPolicy;
6+
import software.amazon.awscdk.services.ecr.Repository;
7+
import software.amazon.awscdk.services.ecr.TagMutability;
58
import software.amazon.awscdk.services.iam.*;
69
import software.amazon.awscdk.services.lambda.Code;
710
import software.amazon.awscdk.services.lambda.Function;
@@ -20,15 +23,16 @@
2023
* Uses "unicorn*" naming convention for compatibility with workshop content.
2124
*
2225
* Contains:
26+
* - ECR repository (unicorn-store-spring)
2327
* - EKS Pod Identity role (unicornstore-eks-pod-role)
2428
* - ECS task roles (unicornstore-ecs-task-role, unicornstore-ecs-task-execution-role)
2529
* - Database schema setup (unicorns table)
26-
*
27-
* Note: ECR repository (unicorn-store-spring) is now created automatically via
28-
* ECR Repository Creation Template (create-on-push) instead of explicit definition.
2930
*/
3031
public class Unicorn extends Construct {
3132

33+
// ECR Repository
34+
private Repository ecrRepository;
35+
3236
// EKS Roles
3337
private Role eksPodRole;
3438

@@ -42,8 +46,14 @@ public class Unicorn extends Construct {
4246
public Unicorn(final Construct scope, final String id, final UnicornProps props) {
4347
super(scope, id);
4448

45-
// Note: ECR repository (unicorn-store-spring) is created automatically via
46-
// ECR Repository Creation Template when images are pushed
49+
// === ECR REPOSITORY ===
50+
this.ecrRepository = Repository.Builder.create(this, "UnicornStoreRepository")
51+
.repositoryName("unicorn-store-spring")
52+
.imageScanOnPush(true)
53+
.imageTagMutability(TagMutability.MUTABLE)
54+
.removalPolicy(RemovalPolicy.DESTROY)
55+
.emptyOnDelete(true)
56+
.build();
4757

4858
// === EKS ROLES ===
4959
if (props.isEksRolesEnabled()) {
@@ -236,6 +246,10 @@ private void createEcsRoles(UnicornProps props) {
236246
}
237247

238248
// Getters
249+
public Repository getEcrRepository() {
250+
return ecrRepository;
251+
}
252+
239253
public Role getEksPodRole() {
240254
return eksPodRole;
241255
}

infra/cfn/base-stack.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,13 @@ Resources:
676676
Fn::GetAtt:
677677
- IdeInstanceLauncherFunction803C5A2A
678678
- Arn
679+
VolumeSize: "50"
680+
IamInstanceProfileArn:
681+
Fn::GetAtt:
682+
- IdeInstanceProfile61B92038
683+
- Arn
684+
InstanceName: ide
685+
InstanceTypes: m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
679686
UserData:
680687
Fn::Base64:
681688
Fn::Join:
@@ -812,19 +819,8 @@ Resources:
812819
"
813820
exit 1
814821
fi
815-
InstanceTypes: m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
816-
InstanceName: ide
817-
IamInstanceProfileArn:
818-
Fn::GetAtt:
819-
- IdeInstanceProfile61B92038
820-
- Arn
821-
VolumeSize: "50"
822-
SubnetIds:
823-
Fn::Join:
824-
- ""
825-
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
826-
- ","
827-
- Ref: VpcPublicSubnet2SubnetA811849C
822+
ImageId:
823+
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61arm64C96584B6F00A464EAD1953AFF4B05118Parameter
828824
SecurityGroupIds:
829825
Fn::Join:
830826
- ""
@@ -835,8 +831,12 @@ Resources:
835831
- Fn::GetAtt:
836832
- IdeInternalSecurityGroupB0A5D76B
837833
- GroupId
838-
ImageId:
839-
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61arm64C96584B6F00A464EAD1953AFF4B05118Parameter
834+
SubnetIds:
835+
Fn::Join:
836+
- ""
837+
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
838+
- ","
839+
- Ref: VpcPublicSubnet2SubnetA811849C
840840
UpdateReplacePolicy: Delete
841841
DeletionPolicy: Delete
842842
IdeEipAssociationDFF81215:

infra/cfn/java-ai-agents-stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ Resources:
757757
Fn::GetAtt:
758758
- IdeInstanceLauncherFunction803C5A2A
759759
- Arn
760-
InstanceTypes: m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
761760
UserData:
762761
Fn::Base64:
763762
Fn::Join:
@@ -918,6 +917,7 @@ Resources:
918917
- IdeInstanceProfile61B92038
919918
- Arn
920919
InstanceName: ide
920+
InstanceTypes: m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
921921
UpdateReplacePolicy: Delete
922922
DeletionPolicy: Delete
923923
IdeEipAssociationDFF81215:

infra/cfn/java-on-amazon-eks-stack.yaml

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,27 @@ Resources:
777777
Fn::GetAtt:
778778
- IdeInstanceLauncherFunction803C5A2A
779779
- Arn
780+
IamInstanceProfileArn:
781+
Fn::GetAtt:
782+
- IdeInstanceProfile61B92038
783+
- Arn
784+
VolumeSize: "50"
785+
SubnetIds:
786+
Fn::Join:
787+
- ""
788+
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
789+
- ","
790+
- Ref: VpcPublicSubnet2SubnetA811849C
791+
SecurityGroupIds:
792+
Fn::Join:
793+
- ""
794+
- - Fn::GetAtt:
795+
- IdeSecurityGroup73B02454
796+
- GroupId
797+
- ","
798+
- Fn::GetAtt:
799+
- IdeInternalSecurityGroupB0A5D76B
800+
- GroupId
780801
ImageId:
781802
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61arm64C96584B6F00A464EAD1953AFF4B05118Parameter
782803
UserData:
@@ -917,27 +938,6 @@ Resources:
917938
fi
918939
InstanceTypes: m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
919940
InstanceName: ide
920-
IamInstanceProfileArn:
921-
Fn::GetAtt:
922-
- IdeInstanceProfile61B92038
923-
- Arn
924-
VolumeSize: "50"
925-
SubnetIds:
926-
Fn::Join:
927-
- ""
928-
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
929-
- ","
930-
- Ref: VpcPublicSubnet2SubnetA811849C
931-
SecurityGroupIds:
932-
Fn::Join:
933-
- ""
934-
- - Fn::GetAtt:
935-
- IdeSecurityGroup73B02454
936-
- GroupId
937-
- ","
938-
- Fn::GetAtt:
939-
- IdeInternalSecurityGroupB0A5D76B
940-
- GroupId
941941
UpdateReplacePolicy: Delete
942942
DeletionPolicy: Delete
943943
IdeEipAssociationDFF81215:
@@ -1316,12 +1316,12 @@ Resources:
13161316
Environment:
13171317
ComputeType: BUILD_GENERAL1_MEDIUM
13181318
EnvironmentVariables:
1319-
- Name: GIT_BRANCH
1320-
Type: PLAINTEXT
1321-
Value: new-ws-infra
13221319
- Name: TEMPLATE_TYPE
13231320
Type: PLAINTEXT
13241321
Value: java-on-amazon-eks
1322+
- Name: GIT_BRANCH
1323+
Type: PLAINTEXT
1324+
Value: new-ws-infra
13251325
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
13261326
ImagePullCredentialsType: CODEBUILD
13271327
PrivilegedMode: false
@@ -1526,12 +1526,12 @@ Resources:
15261526
Description: workshop-setup build complete
15271527
EventPattern:
15281528
detail:
1529+
project-name:
1530+
- Ref: CodeBuildProjectA0FF5539
15291531
build-status:
15301532
- SUCCEEDED
15311533
- FAILED
15321534
- STOPPED
1533-
project-name:
1534-
- Ref: CodeBuildProjectA0FF5539
15351535
detail-type:
15361536
- CodeBuild Build State Change
15371537
source:
@@ -1563,13 +1563,13 @@ Resources:
15631563
Fn::GetAtt:
15641564
- CodeBuildStartLambdaFunction8349284F
15651565
- Arn
1566-
ContentHash: "1766259269788"
15671566
ProjectName:
15681567
Ref: CodeBuildProjectA0FF5539
15691568
CodeBuildIamRoleArn:
15701569
Fn::GetAtt:
15711570
- CodeBuildRoleE9A44575
15721571
- Arn
1572+
ContentHash: "1766262434985"
15731573
DependsOn:
15741574
- CodeBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C60919E0B0C89
15751575
- CodeBuildCompleteRuleEE9277E8
@@ -1921,7 +1921,7 @@ Resources:
19211921
- Ref: AWS::AccountId
19221922
- "-"
19231923
- Ref: AWS::Region
1924-
- "-20251220203430"
1924+
- "-20251220212715"
19251925
PublicAccessBlockConfiguration:
19261926
BlockPublicAcls: true
19271927
BlockPublicPolicy: true
@@ -2157,15 +2157,15 @@ Resources:
21572157
}
21582158
Environment:
21592159
Variables:
2160+
EKS_CLUSTER_NAME:
2161+
Ref: EksClusterB2BDED5B
21602162
S3_BUCKET_NAME:
21612163
Ref: WorkshopBucketFD5BC43F
21622164
SECRET_NAME: workshop-ide-password
21632165
KUBERNETES_AUTH_TYPE: aws
21642166
APP_LABEL: unicorn-store-spring
21652167
K8S_NAMESPACE: unicorn-store-spring
21662168
S3_THREAD_DUMPS_PREFIX: thread-dumps/
2167-
EKS_CLUSTER_NAME:
2168-
Ref: EksClusterB2BDED5B
21692169
FunctionName: workshop-thread-dump-lambda
21702170
Handler: index.lambda_handler
21712171
MemorySize: 512
@@ -2382,6 +2382,16 @@ Resources:
23822382
PolicyName: JvmAnalysisServiceRoleDefaultPolicyB35B4FC8
23832383
Roles:
23842384
- Ref: JvmAnalysisServiceRole87E5AD2B
2385+
UnicornUnicornStoreRepository7B15FB29:
2386+
Type: AWS::ECR::Repository
2387+
Properties:
2388+
EmptyOnDelete: true
2389+
ImageScanningConfiguration:
2390+
ScanOnPush: true
2391+
ImageTagMutability: MUTABLE
2392+
RepositoryName: unicorn-store-spring
2393+
UpdateReplacePolicy: Delete
2394+
DeletionPolicy: Delete
23852395
UnicornUnicornStoreEksPodRoleB15D12B7:
23862396
Type: AWS::IAM::Role
23872397
Properties:

0 commit comments

Comments
 (0)