Description:
When defining an AWS AppSync GraphQL schema in CloudFormation, there is an option to embed the definition (Definition property) in the template or load from S3 (DefinitionS3Location property). Embedding the definition in a SAM template leads to inclusion of DefinitionS3Location in the packaged template, an error condition for the CloudFormation engine.
Steps to reproduce the issue:
Definition and DefinitionS3Location property in the AWS::AppSync::GraphQLSchema resource.Observed result:
CloudFormation error: "Cannot set both the Definition and the DefinitionS3Location."
Expected result:
Successful deployment.
Example: template.yaml
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
MyAppSyncApi:
Type: AWS::AppSync::GraphQLApi
Properties:
AuthenticationType: API_KEY
Name: my-api
SessionManagerSchema:
Type: AWS::AppSync::GraphQLSchema
Description: Session Manager GraphQL schema
Properties:
ApiId: !GetAtt MyAppSyncApi.ApiId
Definition: |
type User {
username: String!
}
type Query {
allUsers(nextToken: String): [User]
}
schema {
query: Query
}
MyFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs8.10
I am having the exact same issue.
For now, I've modified my template as follows and added a little bit of automation:
SessionManagerSchema:
Type: AWS::AppSync::GraphQLSchema
Description: Session Manager GraphQL schema
Properties:
ApiId: !GetAtt MyAppSyncApi.ApiId
DefinitionS3Location: s3://mybucket/schema.graphql
Using a Makefile (though you could do this in any number of ways), I added the following to my "deploy" task to upload the schema.graphql file to my S3 location:
aws s3 cp schema.graphql s3://mybucket/schema.graphql
aws cloudformation deploy ...
A side benefit of this approach is that the my GraphQL schema is managed independently of the rest of my stack.
Thanks for the tip. I've ended up adopting the same approach.
This has been a regression somewhere, probably in aws-sam-translator 1.6.0. I'm running aws-sam-translator 1.5.4 and works fine.
Ok, I investigated this issue a little bit more. It's not aws-sam-translator 1.6.0, it's actually aws-cli 1.15.23+. With aws-cli 1.15.22 it works.
I believe this regression was introduced in https://github.com/aws/aws-cli/commit/c7a22bcc3f437b3e25318c9133af23a687572c92.
Could you open an issue over there and cross link?
Thanks!
Most helpful comment
For now, I've modified my template as follows and added a little bit of automation:
Using a Makefile (though you could do this in any number of ways), I added the following to my "deploy" task to upload the schema.graphql file to my S3 location:
A side benefit of this approach is that the my GraphQL schema is managed independently of the rest of my stack.