【发布时间】:2018-10-18 20:25:19
【问题描述】:
我正在使用无服务器框架将无服务器应用程序部署到 AWS。但是,CloudFormation 部分未按预期工作。我在网上查了一下,没有发现我的 YAML 有什么问题。
我正在使用 CloudFormation 创建 UserPool,然后创建 UserPoolClient。我有以下 YAML 用于 resources:
resources:
Resources:
HttpBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: ${self:service}-${UserPoolId}
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
UserPool:
Type: "AWS::Cognito::UserPool"
Properties:
UserPoolName: ${self:service}-user-pool
MfaConfiguration: "OFF"
EmailVerificationSubject: "Your verification code"
EmailVerificationMessage: "Your verification code is {####}. "
Schema:
- Name: name
AttributeDataType: String
Mutable: true
Required: true
- Name: email
AttributeDataType: String
Mutable: false
Required: true
- Name: teamName
AttributeDataType: String
Mutable: true
Required: false
- Name: custom:supportedTeam
AttributeDataType: String
Mutable: true
Required: false
- Name: custom:payment
AttributeDataType: String
Mutable: true
Required: false
DeveloperOnlyAttribute: true
UsernameAttributes:
- email
AutoVerifiedAttributes:
- email
AdminCreateUserConfig:
InviteMessageTemplate:
EmailMessage: 'Your username is {username} and temporary password is {####}. '
EmailSubject: Your temporary password
SMSMessage: 'Your username is {username} and temporary password is {####}. '
UnusedAccountValidityDays: 7
AllowAdminCreateUserOnly: false
Policies:
PasswordPolicy:
RequireLowercase: true
RequireSymbols: false
RequireNumbers: true
MinimumLength: 6
RequireUppercase: true
UserPoolClient:
Type: "AWS::Cognito::UserPoolClient"
Properties:
ClientName: ${self:service}-client
GenerateSecret: false
UserPoolId:
Ref: UserPool
Outputs:
UserPoolId:
Value:
Ref: UserPool
Export:
Name: "UserPool::Id"
UserPoolClientId:
Value:
Ref: UserPoolClient
Export:
Name: "UserPoolClient::Id"
在指定UserPoolClient(用作UserPoolId)时,我无法引用UserPool。
以下内容:
UserPoolId:
Ref: UserPool
产生错误:
变量 UserPoolId 的变量引用语法无效。你可以 仅参考环境变量、选项和文件。您可以查看我们的文档 更多信息。
我不确定的另一件事是,我看到有人共享包含以下语法的 YAML:
UserPoolId: !Ref UserPool
但它也会失败并出现有关无效语法的错误(由于!Ref)。谁能帮我解惑?
【问题讨论】:
标签: node.js amazon-web-services yaml serverless-framework serverless