@@ -20,10 +20,10 @@ Parameters:
2020 Description : ' 답장 받을 이메일 주소 (선택사항). 비워두면 FromEmailAddress 사용'
2121 AllowedPattern : ' ^$|^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
2222
23- GeminiApiKey :
23+ GroqApiKey :
2424 Type : String
2525 Default : ' '
26- Description : ' Google Gemini API 키 (Gemini API 사용 시 필수)'
26+ Description : ' Groq API 키 (Groq API 사용 시 필수)'
2727 NoEcho : true
2828
2929Conditions :
@@ -33,15 +33,27 @@ Conditions:
3333 - !Not [!Equals [!Ref ReplyToEmailAddress, '']]
3434
3535Resources :
36+ # Lambda 함수: 회원가입 자동 확인 (이메일 인증 없이 바로 사용 가능)
37+ # UserPool보다 먼저 정의해야 함 (참조 순서 문제)
38+ AutoConfirmUserFunction :
39+ Type : AWS::Serverless::Function
40+ Properties :
41+ FunctionName : !Sub 'auto-confirm-user-${Environment}'
42+ CodeUri : ../lambda/auto-confirm-user
43+ Handler : index.handler
44+ Runtime : nodejs18.x
45+ # Pre Sign-up Trigger에서는 autoConfirmUser만 설정하면 되므로 추가 권한 불필요
46+
3647 # Cognito User Pool
3748 UserPool :
3849 Type : AWS::Cognito::UserPool
50+ DependsOn : AutoConfirmUserFunction
3951 Properties :
4052 UserPoolName : !Sub 'fate-user-pool-${Environment}'
41- AutoVerifiedAttributes :
42- - email
53+ # 이메일 인증 없이 바로 사용 가능하도록 설정
4354 UsernameAttributes :
4455 - email
56+ AutoVerifiedAttributes : []
4557 Schema :
4658 - Name : email
4759 Required : true
@@ -54,25 +66,33 @@ Resources:
5466 Required : false
5567 Mutable : true
5668 UserAttributeUpdateSettings :
57- AttributesRequireVerificationBeforeUpdate :
58- - email
69+ AttributesRequireVerificationBeforeUpdate : []
5970 Policies :
6071 PasswordPolicy :
6172 MinimumLength : 8
6273 RequireUppercase : true
6374 RequireLowercase : true
6475 RequireNumbers : true
6576 RequireSymbols : false
66- EmailConfiguration : !If
67- - UseSES
68- - EmailSendingAccount : DEVELOPER
69- SourceArn : !Sub 'arn:aws:ses:${AWS::Region}:${AWS::AccountId}:identity/${FromEmailAddress}'
70- From : !Ref FromEmailAddress
71- ReplyToEmailAddress : !If
72- - HasReplyTo
73- - !Ref ReplyToEmailAddress
74- - !Ref FromEmailAddress
75- - !Ref ' AWS::NoValue'
77+ # 이메일 인증 없이 바로 사용 가능하도록 설정
78+ # Lambda Trigger를 통한 자동 계정 활성화
79+ LambdaConfig :
80+ PreSignUp : !GetAtt AutoConfirmUserFunction.Arn
81+ # VerificationMessageTemplate 제거 - 이메일 인증이 필요하지 않음
82+ # AdminCreateUserConfig 제거 - 기본 설정 사용
83+
84+ # Lambda Permission: Cognito User Pool이 Lambda 함수를 호출할 수 있도록 권한 부여
85+ # UserPool 생성 후에 설정해야 함 (순환 참조 방지)
86+ AutoConfirmUserFunctionPermission :
87+ Type : AWS::Lambda::Permission
88+ DependsOn :
89+ - UserPool
90+ - AutoConfirmUserFunction
91+ Properties :
92+ FunctionName : !Ref AutoConfirmUserFunction
93+ Principal : cognito-idp.amazonaws.com
94+ Action : lambda:InvokeFunction
95+ SourceArn : !GetAtt UserPool.Arn
7696
7797 # Cognito User Pool Client
7898 UserPoolClient :
@@ -176,6 +196,7 @@ Resources:
176196 AllowMethods : " 'GET,POST,OPTIONS'"
177197 AllowHeaders : " 'Content-Type,Authorization'"
178198 AllowOrigin : " '*'"
199+ # 참고: 504 오류 시 CORS 헤더는 Lambda 함수의 응답에서 처리됩니다.
179200
180201 # Lambda 함수: 사주 계산
181202 FateCalculatorFunction :
@@ -185,10 +206,12 @@ Resources:
185206 CodeUri : ../lambda/fate-calculator
186207 Handler : index.handler
187208 Runtime : nodejs18.x
209+ Timeout : 29
210+ MemorySize : 1024
188211 Environment :
189212 Variables :
190213 FATE_TABLE_NAME : !Ref FateTable
191- GEMINI_API_KEY : !Ref GeminiApiKey
214+ GROQ_API_KEY : !Ref GroqApiKey
192215 Policies :
193216 - DynamoDBCrudPolicy :
194217 TableName : !Ref FateTable
0 commit comments