복사 # L25-350: CloudFormation 템플릿으로 Cognito 리소스 일괄 생성
COGNITO_TEMPLATE = {
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CloudFormation template for Troubleshooting Agent System with Cognito authentication",
"Parameters": { # L28-46: 스택 파라미터
"ResourceServerIdentifier": { "Default": "troubleshooting-connectivity-analyzer" },
"TestUserPassword": { "Default": "TestPassword123!" },
"TempPassword": { "Default": "TempPassword123!" }
},
"Resources": { # L47-309: 리소스 정의
"UserPool": { # L48: Cognito User Pool
"Type": "AWS::Cognito::UserPool",
"Properties": {
"UserPoolName": "TroubleshootingAgentGatewayPool",
"UsernameAttributes": ["email"],
"AutoVerifiedAttributes": ["email"]
}
},
"ResourceServer": { # L78: 리소스 서버
"Type": "AWS::Cognito::UserPoolResourceServer",
"Properties": {
"Identifier": {"Ref": "ResourceServerIdentifier"},
"Scopes": [{"ScopeName": "invoke", "ScopeDescription": "Invoke troubleshooting agent runtime"}]
}
},
# Web Client: 사용자 인증 — Authorization Code Flow (L92)
"WebUserPoolClient": { ... "AllowedOAuthFlows": ["code"] },
# Machine Client: M2M 인증 — Client Credentials Flow (L126)
"MachineUserPoolClient": { ... "AllowedOAuthFlows": ["client_credentials"] },
# SSM Parameters (L164-309): 9개 파라미터 자동 생성
"CognitoMachineClientIdParameter": { ... }, # /app/troubleshooting/agentcore/machine_client_id
"CognitoWebClientIdParameter": { ... }, # /app/troubleshooting/agentcore/web_client_id
# ... 외 7개 SSM 파라미터
},
"Outputs": { ... } # L311-349: UserPoolId, WebClientId, MachineClientId, CognitoDomain
}