@@ -777,12 +777,8 @@ Resources:
777777 Fn::GetAtt :
778778 - IdeInstanceLauncherFunction803C5A2A
779779 - Arn
780- IamInstanceProfileArn :
781- Fn::GetAtt :
782- - IdeInstanceProfile61B92038
783- - Arn
784- InstanceName : ide
785- InstanceTypes : m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
780+ ImageId :
781+ Ref : SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61arm64C96584B6F00A464EAD1953AFF4B05118Parameter
786782 UserData :
787783 Fn::Base64 :
788784 Fn::Join :
@@ -919,8 +915,19 @@ Resources:
919915 "
920916 exit 1
921917 fi
922- ImageId :
923- Ref : SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61arm64C96584B6F00A464EAD1953AFF4B05118Parameter
918+ InstanceTypes : m7g.xlarge,m6g.xlarge,c7g.xlarge,t4g.xlarge
919+ 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
924931 SecurityGroupIds :
925932 Fn::Join :
926933 - " "
@@ -931,13 +938,6 @@ Resources:
931938 - Fn::GetAtt :
932939 - IdeInternalSecurityGroupB0A5D76B
933940 - GroupId
934- SubnetIds :
935- Fn::Join :
936- - " "
937- - - Ref : VpcPublicSubnet1Subnet8E8DEDC0
938- - " ,"
939- - Ref : VpcPublicSubnet2SubnetA811849C
940- VolumeSize : " 50"
941941 UpdateReplacePolicy : Delete
942942 DeletionPolicy : Delete
943943 IdeEipAssociationDFF81215 :
@@ -1563,13 +1563,13 @@ Resources:
15631563 Fn::GetAtt :
15641564 - CodeBuildStartLambdaFunction8349284F
15651565 - Arn
1566- ContentHash : " 1766254404082"
1566+ ContentHash : " 1766259269788"
1567+ ProjectName :
1568+ Ref : CodeBuildProjectA0FF5539
15671569 CodeBuildIamRoleArn :
15681570 Fn::GetAtt :
15691571 - CodeBuildRoleE9A44575
15701572 - Arn
1571- ProjectName :
1572- Ref : CodeBuildProjectA0FF5539
15731573 DependsOn :
15741574 - CodeBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C60919E0B0C89
15751575 - CodeBuildCompleteRuleEE9277E8
@@ -1921,7 +1921,7 @@ Resources:
19211921 - Ref : AWS::AccountId
19221922 - " -"
19231923 - Ref : AWS::Region
1924- - " -20251220191324 "
1924+ - " -20251220203430 "
19251925 PublicAccessBlockConfiguration :
19261926 BlockPublicAcls : true
19271927 BlockPublicPolicy : true
@@ -2157,13 +2157,13 @@ Resources:
21572157 }
21582158 Environment :
21592159 Variables :
2160- S3_THREAD_DUMPS_PREFIX : thread-dumps/
2161- K8S_NAMESPACE : unicorn-store-spring
2162- APP_LABEL : unicorn-store-spring
2163- KUBERNETES_AUTH_TYPE : aws
2164- SECRET_NAME : workshop-ide-password
21652160 S3_BUCKET_NAME :
21662161 Ref : WorkshopBucketFD5BC43F
2162+ SECRET_NAME : workshop-ide-password
2163+ KUBERNETES_AUTH_TYPE : aws
2164+ APP_LABEL : unicorn-store-spring
2165+ K8S_NAMESPACE : unicorn-store-spring
2166+ S3_THREAD_DUMPS_PREFIX : thread-dumps/
21672167 EKS_CLUSTER_NAME :
21682168 Ref : EksClusterB2BDED5B
21692169 FunctionName : workshop-thread-dump-lambda
@@ -2709,9 +2709,6 @@ Resources:
27092709 Fn::GetAtt :
27102710 - UnicornUnicornStoreDatabaseSetupFunction04E12F8B
27112711 - Arn
2712- SqlStatements : |
2713- CREATE TABLE IF NOT EXISTS unicorns(id TEXT DEFAULT gen_random_uuid() PRIMARY KEY, name TEXT, age TEXT, size TEXT, type TEXT);
2714- CREATE EXTENSION IF NOT EXISTS vector;
27152712 SecretName :
27162713 Fn::Join :
27172714 - " -"
@@ -2742,6 +2739,9 @@ Resources:
27422739 - Fn::Split :
27432740 - " :"
27442741 - Ref : DatabaseSecret3B817195
2742+ SqlStatements : |
2743+ CREATE TABLE IF NOT EXISTS unicorns(id TEXT DEFAULT gen_random_uuid() PRIMARY KEY, name TEXT, age TEXT, size TEXT, type TEXT);
2744+ CREATE EXTENSION IF NOT EXISTS vector;
27452745 DependsOn :
27462746 - DatabaseClusterDatabaseWriterF4C0B9A6
27472747 - DatabaseCluster5B53A178
@@ -2859,8 +2859,8 @@ Resources:
28592859
28602860 return endpoint_ids
28612861
2862- def cleanup_guardduty_security_groups(vpc_id):
2863- """Delete GuardDuty managed security groups for the VPC."""
2862+ def cleanup_guardduty_security_groups(vpc_id, max_retries=6, retry_delay=10 ):
2863+ """Delete GuardDuty managed security groups for the VPC with retry logic ."""
28642864 if not vpc_id:
28652865 print("No VPC ID provided, skipping security group cleanup")
28662866 return
@@ -2884,11 +2884,20 @@ Resources:
28842884 sg_id = sg['GroupId']
28852885 sg_name = sg['GroupName']
28862886 print(f"Deleting GuardDuty security group: {sg_name} ({sg_id})")
2887- try:
2888- ec2.delete_security_group(GroupId=sg_id)
2889- print(f"Deleted security group: {sg_id}")
2890- except Exception as e:
2891- print(f"Error deleting security group {sg_id}: {e}")
2887+
2888+ # Retry deletion - ENIs may take time to detach after endpoint deletion
2889+ for attempt in range(max_retries):
2890+ try:
2891+ ec2.delete_security_group(GroupId=sg_id)
2892+ print(f"Deleted security group: {sg_id}")
2893+ break
2894+ except ec2.exceptions.ClientError as e:
2895+ if 'DependencyViolation' in str(e) and attempt < max_retries - 1:
2896+ print(f"Security group has dependencies, waiting {retry_delay}s (attempt {attempt + 1}/{max_retries})...")
2897+ time.sleep(retry_delay)
2898+ else:
2899+ print(f"Error deleting security group {sg_id}: {e}")
2900+ break
28922901
28932902 except Exception as e:
28942903 print(f"Error listing GuardDuty security groups: {e}")
0 commit comments