【发布时间】:2020-05-05 21:17:47
【问题描述】:
我正在尝试在我的堆栈之间共享 cognito 授权方,我正在导出我的授权方,但是当我尝试在另一个服务中引用它时出现错误
尝试从 CloudFormation 请求未导出的变量。堆栈名称:“myApp-services-test” 请求的变量:“ExtApiGatewayAuthorizer-test”。
这是我定义和导出授权方的堆栈:
CognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
# Generate a name based on the stage
UserPoolName: ${self:provider.stage}-user-pool
# Set email as an alias
UsernameAttributes:
- email
AutoVerifiedAttributes:
- email
ApiGatewayAuthorizer:
Type: AWS::ApiGateway::Authorizer
Properties:
Name: CognitoAuthorizer
Type: COGNITO_USER_POOLS
IdentitySource: method.request.header.Authorization
RestApiId: { "Ref": "ProxyApi" }
ProviderARNs:
- Fn::GetAtt:
- CognitoUserPool
- Arn
ApiGatewayAuthorizerId:
Value:
Ref: ApiGatewayAuthorizer
Export:
Name: ExtApiGatewayAuthorizer-${self:provider.stage}
这已成功导出,我可以在我的 aws 控制台的堆栈导出列表中看到它。
我尝试像这样在另一个堆栈中引用它:
myFunction:
handler: handler.myFunction
events:
- http:
path: /{userID}
method: put
cors: true
authorizer:
type: COGNITO_USER_POOLS
authorizerId: ${myApp-services-${self:provider.stage}.ExtApiGatewayAuthorizer-${self:provider.stage}}
我的环境信息
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.13.1
Framework Version: 1.60.5
Plugin Version: 3.2.7
SDK Version: 2.2.1
Components Core Version: 1.1.2
Components CLI Version: 1.4.0
【问题讨论】:
标签: aws-lambda amazon-cloudformation aws-api-gateway amazon-cognito serverless-framework