Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

remove() is not removing an AppSync API #15

Open
veloware opened this issue Mar 5, 2020 · 0 comments
Open

remove() is not removing an AppSync API #15

veloware opened this issue Mar 5, 2020 · 0 comments

Comments

@veloware
Copy link

veloware commented Mar 5, 2020

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant