Make AppSync and MappingTemplate L2-constructs work with CodePipeline deployments
See original GitHub issueDeploy an AppSync API with a schema definition file and resolver mapping templates in a CodePipeline using CloudFormation actions.
Use Case
I want to deploy an AppSync API in a CodePipeline and I don’t want to inline the schema into the CDK code because I want to generate model classes from it.
Currently, the schema definition must be provided either as a string or as an asset (not yet supported by CloudFormations actions). It is not possible to provide S3-locations without redefining the current L2-construct.
CDK source code:
Proposed Solution
Provide S3-locations of the schema definition file and any resolver mapping templates to the synthesized template using CloudFormation parameters, similar to CfnParametersCode (see example here).
Since the number of mapping templates can be very high, a solution that requires only one parameter representing the S3-folder containing the mapping templates would be useful.
Creating an AppSync API and mapping templates could look like:
const schema = new cdk.CfnParameter(this, 'GraphQLSchemaS3Location');
const resolversDir = new cdk.CfnParameter(this, 'GraphQLMappingTemplatesS3Location');
const api = new appsync.GraphQLApi(this, 'GraphQLApi', {
name: `GraphQLApi`,
schemaDefinitionLocation: schema,
});
someDataSource.createQueryResolver({
field: 'getHello',
requestTemplate: appsync.MappingTemplate.fromS3Location(resolversDir, 'getHello-request-mapping-template.vtl'),
responseTemplate: appsync.MappingTemplate.fromS3Location(resolversDir, 'getHello-response-mapping-template.vtl'),
});
Other
Related question on Gitter.
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (8 by maintainers)
Top GitHub Comments
Ah I see. I think this discussion would be great to keep open.
I think if we could change the issue name/message to reflect our discussion that would be fantastic!
@BryanPan342 Thanks for you response.
I don’t completely understand. Could you maybe sketch your solution? My idea was that the CDK would take care of uploading the referenced schema/resolver files to S3 and use the corresponding S3 locations (strings) as input parameters to the synthesized CFN template during deployment. Very similar to how
lambda.CfnParametersCode
, see this example.Since
pipelines.CdkPipeline
now supportsAssets
, I think sth. like the following would best cover all use cases (cdk deploy
and pipeline deployments usingpipelines.CdkPipeline
)