gpt4 book ai didi

amazon-web-services - 导入 AWS::ApiGateway::Authorizer 无服务器框架

转载 作者:行者123 更新时间:2023-12-03 07:35:08 25 4
gpt4 key购买 nike

我尝试构建一个 jenkins 管道,该管道将部署一些常见的 AWS 资源,然后部署特定的服务资源。

这是公共(public)资源部分,正在成功部署。

resources:
Resources:
GoatfolioUserPool:
Type: 'AWS::Cognito::UserPool'
Properties:
AccountRecoverySetting:
RecoveryMechanisms:
- Name: verified_email
Priority: 1
AutoVerifiedAttributes:
- email
EmailVerificationSubject: "GOATFOLIO - Verifique seu e-mail"
Policies:
PasswordPolicy:
MinimumLength: 6
RequireLowercase: true
RequireNumbers: true
RequireSymbols: true
RequireUppercase: true
TemporaryPasswordValidityDays: 1
Schema:
- AttributeDataType: String
Name: email
Required: true
- AttributeDataType: String
Name: given_name
Required: true
AliasAttributes:
- email
UsernameConfiguration:
CaseSensitive: false
UserPoolName: "goatfolio"

ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: ApiGatewayRestApi

ApiGatewayAuthorizer:
Type: AWS::ApiGateway::Authorizer
Properties:
AuthorizerResultTtlInSeconds: 10
IdentitySource: method.request.header.Authorization
Name: GoatCognitoAuthorizer
RestApiId:
Ref: ApiGatewayRestApi
Type: COGNITO_USER_POOLS
ProviderARNs:
- {"Fn::Join": ["", ["arn:aws:cognito-idp:", {Ref: "AWS::Region"}, ":", {Ref: "AWS::AccountId"}, ":userpool/goatfolio", Ref: GoatfolioUserPool]]}

Outputs:
ApiGatewayAuthorizerOutput:
Value:
Ref: ApiGatewayAuthorizer
Export:
Name: ${self:provider.stage}-ApiGatewayAuthorizerOutput

具体部分:

functions:
getConsolidated:
handler: handlers.consolidate_investments_handler
events:
- http:
path: portfolio/
method: get
authorizer:
type: COGNITO_USER_POOLS
authorizerId:
Ref: {'Fn::ImportValue': '${self:provider.stage}-ApiGatewayAuthorizerOutput'}

我正在尝试使用此 ImportValue 但出现此错误:

Error: The CloudFormation template is invalid: Template error: every Ref object must have a single String value.

我也尝试过其他一些方法,但没有成功。

有一种方法可以打印 ImportValue 的返回值,以便我了解发生了什么?

我做错了什么可怕的事情?

提前致谢。

最佳答案

您可以在堆栈控制台、Outputs 选项卡或 CloudFormation 控制台中查看 '${self:provider.stage}-ApiGatewayAuthorizerOutput' 的导出值导出菜单。

您的上下文中的

!Ref 无法使用,因为导入的值来自其他堆栈。如果您只想使用导入的值,则不需要 !Ref

您可以尝试以下操作:

    authorizerId: {'Fn::ImportValue': '${self:provider.stage}-ApiGatewayAuthorizerOutput'}

关于amazon-web-services - 导入 AWS::ApiGateway::Authorizer 无服务器框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62974231/

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