gpt4 book ai didi

node.js - 无法在 serverless.yml 中引用 CloudFormation 资源。变量 UserPoolId 的变量引用语法无效

转载 作者:搜寻专家 更新时间:2023-10-31 22:44:29 24 4
gpt4 key购买 nike

我正在使用无服务器框架将无服务器应用程序部署到 AWS。但是,CloudFormation 部分未按预期工作。我在网上查了一下,没有发现我的 YAML 有任何问题。

我正在创建 UserPool,然后使用 CloudFormation 创建 UserPoolClient。我有以下用于 resources:

的 YAML
    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

产生错误:

Invalid variable reference syntax for variable UserPoolId. You can only reference env vars, options, & files. You can check our docs for more info.

我不确定的另一件事是,我看到有人共享包含以下语法的 YAML:

UserPoolId: !Ref UserPool

但它也失败了,并且出现了有关无效语法的错误(由于 !Ref)。谁能帮我解决这个问题?

最佳答案

在离开计算机一段时间后,我认为问题可能出在其他地方,这里就是这种情况。

我在环境变量下使用 ${UserPoolId} 并意识到这就是问题所在。我改成下面的方式,问题解决了。我没有正确引用用户池 ID(它引用了名为 UserPoolId 的 serverless.yml 局部变量,该变量不存在)

userPoolId: 
Ref: UserPool

这只是我的错误,现在已经解决了。

关于node.js - 无法在 serverless.yml 中引用 CloudFormation 资源。变量 UserPoolId 的变量引用语法无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50241159/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com