我正在使用serverless-graphql构建GraphQL Serverless API。
我已经建立了serverless.yml
来尝试拥有多个GraphQL API,这些API使用不同的服务提供商角色。我希望能够获得序列中的第二个引用,以引用该角色的名称
例如 “ $ {self:custom.appSync [1] .serviceRole}” \
但是在部署API时会出错:
An error occurred: AuthenticatedAppSyncServiceRole - The specified value for roleName is invalid. It must contain only alphanumeric characters and/or the following: +=,.@_- (Service: AmazonIdentityManagement; Status Code: 400; Error Code: ValidationError; Request ID: 6b209659-8afc-11e9-aca7-1b89a9ac9c40).
serverless.yml
appSync:
- name: API_ONE
authenticationType: API_KEY
mappingTemplates:
- ...
schema: schema_one.graphql
serviceRole: AuthenticatedAppSyncServiceRole
dataSources:
- type: AWS_LAMBDA
name: awsLambdaDataSource
description: "Lambda DataSource"
config:
lambdaFunctionArn: { Fn::GetAtt: [GraphqlLambdaFunction, Arn] }
serviceRoleArn:
{ Fn::GetAtt: [AuthenticatedAppSyncServiceRole, Arn] }
- name: API_TWO
authenticationType: API_KEY
mappingTemplates:
- ...
schema: schema_two.graphql
serviceRole: PublicAppSyncServiceRole
dataSources:
- type: AWS_LAMBDA
name: awsLambdaDataSource
description: "Lambda DataSource"
config:
lambdaFunctionArn: { Fn::GetAtt: [GraphqlLambdaFunction, Arn] }
serviceRoleArn:
{ Fn::GetAtt: [PublicAppSyncServiceRole, Arn] }
resources:
Resources:
AuthenticatedAppSyncServiceRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: "Lambda-${self:custom.appSync[0].serviceRole}"
...
PublicAppSyncServiceRole:
Type: "AWS::IAM::Role"
Properties:
RoleName: "Lambda-${self:custom.appSync[1].serviceRole}"