@@ -40,26 +40,34 @@ lint-cicd:
4040 fi
4141 @echo -e " $( GREEN) All code quality checks passed!$( NC) "
4242
43- # Check CloudFormation templates for hardcoded AWS partition ARNs
43+ # Check CloudFormation templates for hardcoded AWS partition ARNs and service principals
4444check-arn-partitions :
45- @echo " Checking CloudFormation templates for hardcoded ARN partitions..."
45+ @echo " Checking CloudFormation templates for hardcoded ARN partitions and service principals ..."
4646 @FOUND_ISSUES=0; \
4747 for template in template.yaml patterns/* /template.yaml patterns/* /sagemaker_classifier_endpoint.yaml options/* /template.yaml; do \
4848 if [ -f " $$ template" ]; then \
4949 echo " Checking $$ template..." ; \
50- MATCHES =$$(grep -n "arn:aws:" "$$template" | grep -v "arn:\$${AWS::Partition}:" || true ) ; \
51- if [ -n " $$ MATCHES " ]; then \
50+ ARN_MATCHES =$$(grep -n "arn:aws:" "$$template" | grep -v "arn:\$${AWS::Partition}:" || true ) ; \
51+ if [ -n " $$ ARN_MATCHES " ]; then \
5252 echo -e " $( RED) ERROR: Found hardcoded 'arn:aws:' references in $$ template:$( NC) " ; \
53- echo " $$ MATCHES " | sed ' s/^/ /' ; \
53+ echo " $$ ARN_MATCHES " | sed ' s/^/ /' ; \
5454 echo -e " $( YELLOW) These should use 'arn:\$ ${AWS:: Partition} :' instead for GovCloud compatibility$( NC) " ; \
5555 FOUND_ISSUES=1; \
5656 fi ; \
57+ SERVICE_MATCHES=$$(grep -n "\.amazonaws\.com" "$$template" | grep -v "\$${AWS::URLSuffix}" | grep -v "^[[:space:]]*#" | grep -v "Description:" | grep -v "Comment:" | grep -v "cognito" | grep -v "ContentSecurityPolicy" || true ) ; \
58+ if [ -n " $$ SERVICE_MATCHES" ]; then \
59+ echo -e " $( RED) ERROR: Found hardcoded service principal references in $$ template:$( NC) " ; \
60+ echo " $$ SERVICE_MATCHES" | sed ' s/^/ /' ; \
61+ echo -e " $( YELLOW) These should use '\$ ${AWS:: URLSuffix} ' instead of 'amazonaws.com' for GovCloud compatibility$( NC) " ; \
62+ echo -e " $( YELLOW) Example: 'lambda.amazonaws.com' should be 'lambda.\$ ${AWS:: URLSuffix} '$( NC) " ; \
63+ FOUND_ISSUES=1; \
64+ fi ; \
5765 fi ; \
5866 done ; \
5967 if [ $$ FOUND_ISSUES -eq 0 ]; then \
60- echo -e " $( GREEN) ✅ No hardcoded ARN partition references found!$( NC) " ; \
68+ echo -e " $( GREEN) ✅ No hardcoded ARN partition or service principal references found!$( NC) " ; \
6169 else \
62- echo -e " $( RED) ❌ Found hardcoded ARN partition references that need to be fixed$( NC) " ; \
70+ echo -e " $( RED) ❌ Found hardcoded references that need to be fixed for GovCloud compatibility $( NC) " ; \
6371 exit 1; \
6472 fi
6573
0 commit comments