Clean up test project

The project created using sample-app template includes an Amazon SQS queue, and an Amazon SNS topic. You’re not going to use them in your project, so remove them from your the CdkLabStack constructor.

Open CdkLabStack.cs and clean it up. It should look like this:

using Amazon.CDK;

namespace CdkLab
{
    public class CdkLabStack : Stack
    {
        internal CdkLabStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            // empty
        }
    }
}

Now that you have modified your stack’s contents, you can ask the toolkit to show you the difference between your CDK app and what’s currently deployed. This is a safe way to check what will happen once you deploy and is always good practice:

cdk diff

Output should look like the following. As expected, all resources are going to be destroyed.

Stack CdkLabStack
IAM Statement Changes
┌───┬────────────────────────────┬────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────┐
│   │ Resource                   │ Effect │ Action          │ Principal                 │ Condition                                    │
├───┼────────────────────────────┼────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────┤
│ - │ ${CdkLabQueue2E31BBF6.Arn} │ Allow  │ sqs:SendMessage │ Service:sns.amazonaws.com │ "ArnEquals": {                               │
│   │                            │        │                 │                           │   "aws:SourceArn": "${CdkLabTopic75C68173}"  │
│   │                            │        │                 │                           │ }                                            │
└───┴────────────────────────────┴────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────┘
(NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Resources
[-] AWS::SQS::Queue CdkLabQueue2E31BBF6 destroy
[-] AWS::SQS::QueuePolicy CdkLabQueuePolicy42EE3F64 destroy
[-] AWS::SNS::Subscription CdkLabQueueCdkLabStackCdkLabTopic1CBA682F3339E555 destroy
[-] AWS::SNS::Topic CdkLabTopic75C68173 destroy

Run cdk deploy and see the resources being deleted:

cdk deploy
CdkLabStack: deploying...
CdkLabStack: creating CloudFormation changeset...
 0/6 | 3:42:15 PM | UPDATE_IN_PROGRESS   | AWS::CDK::Metadata | CDKMetadata
 1/6 | 3:42:17 PM | UPDATE_COMPLETE      | AWS::CDK::Metadata | CDKMetadata
 1/6 | 3:42:18 PM | UPDATE_COMPLETE_CLEA | AWS::CloudFormation::Stack | CdkLabStack
 1/6 | 3:42:19 PM | DELETE_IN_PROGRESS   | AWS::SQS::QueuePolicy | CdkLabQueuePolicy42EE3F64
 1/6 | 3:42:19 PM | DELETE_IN_PROGRESS   | AWS::SNS::Subscription | CdkLabQueueCdkLabStackCdkLabTopic1CBA682F3339E555
 2/6 | 3:42:20 PM | DELETE_COMPLETE      | AWS::SQS::QueuePolicy | CdkLabQueuePolicy42EE3F64
 3/6 | 3:42:20 PM | DELETE_COMPLETE      | AWS::SNS::Subscription | CdkLabQueueCdkLabStackCdkLabTopic1CBA682F3339E555
 3/6 | 3:42:21 PM | DELETE_IN_PROGRESS   | AWS::SQS::Queue    | CdkLabQueue2E31BBF6
 3/6 | 3:42:21 PM | DELETE_IN_PROGRESS   | AWS::SNS::Topic    | CdkLabTopic75C68173
 4/6 | 3:42:21 PM | DELETE_COMPLETE      | AWS::SNS::Topic    | CdkLabTopic75C68173
4/6 Currently in progress: CdkLabStack, CdkLabQueue2E31BBF6

 ✅✅  CdkLabStack

Stack ARN:
arn:aws:cloudformation:<Your region>:<Your account ID>:stack/CdkLabStack/a3dbbb60-5fb4-11ea-b008-021ebf3a767c