Aws-cli: GraphQLSchema defines both 'Definition' and 'DefinitionS3Location'

Created on 20 Jun 2018  路  8Comments  路  Source: aws/aws-cli

This bug affects aws-cli 1.15.23+.

Given the following cloudformation template:

AWSTemplateFormatVersion: '2010-09-09'

Resources:
  GraphQLApi:
    Type: "AWS::AppSync::GraphQLApi"
    Properties:
      Name: Test
      AuthenticationType: "API_KEY"

  GraphQLSchema:
    Type: "AWS::AppSync::GraphQLSchema"
    Properties:
      ApiId: !GetAtt GraphQLApi.ApiId
      Definition: schema {}

Running aws cloudformation package --template-file test.yaml --s3-bucket bucket results in the following:

Uploading to 05e9ac726edc2118dbfb0b34faffc602  14043648 / 14043648.0  (100.00%)
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  GraphQLApi:
    Properties:
      AuthenticationType: API_KEY
      Name: Test
    Type: AWS::AppSync::GraphQLApi
  GraphQLSchema:
    Properties:
      ApiId:
        Fn::GetAtt:
        - GraphQLApi
        - ApiId
      Definition: schema {}
      DefinitionS3Location: s3://bucket/05e9ac726edc2118dbfb0b34faffc602
    Type: AWS::AppSync::GraphQLSchema

Note that both Definition and DefinitionS3Location are defined, when only Definition should be defined. Also note that nothing should be uploaded to S3 in this case either. This causes cloudformation deploy to fail with Cannot set both the Definition and the DefinitionS3Location..

I believe this was introduced in https://github.com/aws/aws-cli/pull/3297

closing-soon cloudformation packagdeploy customization

Most helpful comment

+1 affected by it. Downgrading AWS CLI was not possible as I was using CodePipeline/CodeBuild to deploy the template.
But the making schema separate and using DefinitionS3Location solved the problem for me.

Schema:
Type: "AWS::AppSync::GraphQLSchema"
Properties:
ApiId: !GetAtt GraphQLApi.ApiId
DefinitionS3Location: src/graphQLSchema/schema.graphql

All 8 comments

Thanks for reporting, cc @sanathkr, thoughts?

+1 affected by it.

Also support for DefinitionS3Location is not documented.

Downgraded to aws-cli/1.11.157 and using SAM CLI, version 0.4.0 solved it. FYI

With aws-cli 1.15.22 it works.

I believe this regression was introduced in aws/aws-cli@c7a22bc.

+1 affected by it. Downgrading AWS CLI was not possible as I was using CodePipeline/CodeBuild to deploy the template.
But the making schema separate and using DefinitionS3Location solved the problem for me.

Schema:
Type: "AWS::AppSync::GraphQLSchema"
Properties:
ApiId: !GetAtt GraphQLApi.ApiId
DefinitionS3Location: src/graphQLSchema/schema.graphql

Ran into this issue as well, aws-cli 1.15.22 worked thanks @adrai!

Nice feature! This makes my former approach obsolete 馃帀

# Makefile

SCHEMA := $(shell cat schema.graphql)

deploy:
  aws cloudformation package [...]
  aws cloudformation deploy [...] --parameter-overrides ParamSchema="$(SCHEMA)"
# template.yaml

AppSyncSchema:
  Type: AWS::AppSync::GraphQLSchema
  Properties:
    ApiId: !GetAtt [ AppSyncAPI, ApiId ]
    Definition: !Ref ParamSchema

Parameters:
  ParamSchema:
    Type: String

All I need to configure now is

# template.yml

AppSyncSchema:
  Type: AWS::AppSync::GraphQLSchema
  Properties:
    ApiId: !GetAtt [AppSyncAPI, ApiId]
    DefinitionS3Location: schema.graphql

Works great, Thanks!

All - this issue has been resolved under PR #3558. Please reply if there any other questions or concerns.

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Was this page helpful?
0 / 5 - 0 ratings