serverless / template

Compose & provision a collection of Serverless Components
https://serverless.com
Apache License 2.0
10 stars 6 forks source link

remove() is not removing an AppSync API #15

Open veloware opened 4 years ago

veloware commented 4 years ago

I have the following serverless.js for a POC, that will create a dynamodb table for storing posts and an AppSync API for creating a post and getting all posts -

const { Component } = require('@serverless/core');

class ServerlessTemplate extends Component {
    async default(inputs) {
        inputs.env = inputs.env || 'dev';

        const template = await this.load('@serverless/template', inputs.env);

        return await template({
            template: {
                name: inputs.name,
                postsTable: {
                    component: '@serverless/aws-dynamodb',
                    inputs: {
                        name: `posts-${inputs.env}`,
                        region: 'eu-west-1'
                    }
                },
                appSync: {
                    component: '@serverless/aws-app-sync',
                    inputs: {
                        name: `posts-api-${inputs.env}`,
                        region: 'eu-west-1',
                        authenticationType: 'API_KEY',
                        apiKeys: ['myApiKey'],
                        dataSources: [{
                            type: 'AMAZON_DYNAMODB',
                            name: 'Posts',
                            config: {
                                tableName: `posts-${inputs.env}`
                            }
                        }],
                        mappingTemplates: [{
                            dataSource: 'Posts',
                            type: 'Mutation',
                            field: 'addPost',
                            request: 'addPostRequest.vtl',
                            response: 'addPostResponse.vtl'
                        }, {
                            dataSource: 'Posts',
                            type: 'Query',
                            field: 'posts',
                            request: 'getAllPostsRequest.vtl',
                            response: 'getAllPostsResponse.vtl'
                        }]
                    }
                }
            }
        });
    }

    async remove(inputs) {
        inputs.env = inputs.env || 'dev';
        const template = await this.load('@serverless/template', inputs.env);
        console.log(template);
        await template.remove();
        return {};
    }
}

module.exports = ServerlessTemplate;

sls --env dev will create the resources correctly - however running sls remove --env dev will only remove the dynamodb table, but not the AppSync API. Not sure if this is a bug or if I have missed something in my config?