Clean Up

If you are running this workshop at an AWS event using a temporary AWS Account, you do not need to complete this section. You have already completed the workshop. Congratulations!

Destroy the deployed environment

Go to the the terminal on your environment and type the following command. Be sure to navigate to your cdk folder.

~/environment/aws-alien-attack/infrastructure/cdk (master) $ cdk destroy -c envname=$envname

If everything went well, you will receive a message that looks like the following:

✅  <YourEnvironmentName>: destroyed

If you receive an error that looks something like this:

<YourEnvironmentName>: destroy failed Error: The stack named <YourEnvironmentName> is in a failed state: DELETE_FAILED (The following resource(s) failed to delete: [WebSocketLayer<YourEnvironmentName>WebSocketSynchronizeStartFnRole]. )

That is ok we have worked with AWS CDK at Unicorn Games before and can solve this!

  1. Go to to the CloudFormation console.
  2. Click on
  3. Click Delete. A window should pop up.
    • Scroll all the way to the bottom and find the role that was giving an issue earlier. Should look like WebSocketLayerWebSocketSynchronizeStartFnRole
    • Check the box to left of it.
    • Press Delete Stack
  4. We just have to remember to make sure that we delete this role manually. We can do this easily by just searching for it while we are in the IAM page.

If by any reason you no longer have access to the Cloud9 environment, or you are unable to destroy the environment using AWS CDK, go to CloudFormation on your AWS console, and delete the stack with “Stack Name” corresponding to your . Then move to the next activity.

Cleaning up the last resources

Everything that was created by CloudFormation was deleted with the exception of your S3 buckets. Additionally, the resources that you created directly on the console were not deleted.

Let’s fix this.

  1. Go to Systems Manager, then Parameter Store, and delete the parameter /session and /websocket
  2. Go to Kinesis, then Kinesis Firehose, and delete the resource that you created by hand
  3. Go to IAM, and search for . Delete any resource configured like that. For sure the only resource will be FirehoseRole
  4. Delete the S3 buckets .app and .raw
  5. Delete your Cloud9 environment if you created it just for this workshop.