我试图建立一个詹金斯管道,该管道将部署一些常见的AWS资源,然后部署特定的服务资源。
这是公共资源部分,正在成功部署。
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的返回值,以便我了解发生了什么情况?
我做错了什么严重的事?
谢谢。
答案 0 :(得分:1)
您可以在堆栈的控制台,'${self:provider.stage}-ApiGatewayAuthorizerOutput'
选项卡或Outputs
菜单的CloudFormation控制台中查看Exports
的导出值。
!Ref
无法使用,因为导入的值来自其他堆栈。如果您只想使用导入的值,则不需要!Ref
。
您可以尝试以下操作:
authorizerId: {'Fn::ImportValue': '${self:provider.stage}-ApiGatewayAuthorizerOutput'}