---
# System prepended metadata

title: Assignment Submission - Atlan

---

# Assignment Submission - Atlan

- Submission by: Manish Kumar
- Email: [manishprivet808@gmail.com](mailto:manishprivet808@gmail.com)

## Problem Statement

We need a solution to run a cloudformation template and test it without actually launching the resources and costing anything.

Complete details can be found [here](https://docs.google.com/document/d/1C7o2Z6_KwiVOLjUPtBjcyivmIQpoErZ4QHsBu9L_Dj0/edit)

## Steps to test the solution

### Prerequisites

- [AWS CLI](https://aws.amazon.com/cli/)
- [Python 3.6+](https://www.python.org/)
- [Pip](https://pypi.org/project/pip/)
- [Virtualenv](https://pypi.org/project/virtualenv/)
- [Docker](https://www.docker.com/)

### Step 1

Create a Virtualenv

```bash
virtualenv assignment_env
source assignment_env/bin/activate
```

### Step 2

1. Make sure all the template files are present in the `/templates` folder.
2. Configure the test parameters for the templates in the `.taskcat.yml` file.

Example:

```yaml
tests:
  eks:
    template: ./templates/eks.template.yml
    parameters: 
      ClusterName: "atlan-assignment"
      VpcId: "vpc-9a564ed1"
      Subnets: "subnet-d4c2eff4"
      ClusterRole: "atlan-assignment"
      ClusterControlPlaneSecurityGroup: ""
```

### Step 3

Run the following command to install the required dependencies:

```bash
make setup
```

![image](https://user-images.githubusercontent.com/54291836/184506127-00083ec5-867e-4126-b56b-4368a43630cf.png)

### Step 4

Run the following command to run the tests

```bash
make test
```

![image](https://user-images.githubusercontent.com/54291836/184506123-3582731e-271a-4bfe-b07b-a5112c5e1f6a.png)

## Approach

### Research

At first, I looked into the internet for any existing solutions for this problem.

I was able to find two different sets of tools.

1. [cfn-lint](https://github.com/aws-cloudformation/cfn-lint) - A tool to lint CloudFormation templates. Works offline!
2. [taskcat](https://github.com/aws-ia/taskcat) - A tool to test CloudFormation templates by launching them online. Needs an AWS account.

The first tool worked well for an initial deep linting check of the template offline.
However, as the problem required the tests to cost 0 dollars, taskcat was posing a problem, as it worked by deploying the template to an AWS account.

To tackle that, I found another tool, [localstack](https://localstack.cloud/), which is a fully functional cloud simulator that can work offline.

So my final approach to the problem was:

1. Run an initial test using `cfn-lint`
2. Run taskcat for the template on the `localstack` environment, which will help us minimize the cost to 0 for repeated testing.

### Problems Faced

The major problem I faced in this approach was the fact that the `localstack` environment runs, well, on `http://localhost:4566`, and needed all aws commands to have the `--endpoint-url http://localhost:4566` flag.

However, since `taskcat` was not configured for `localstack`, it had no way to pass the `--endpoint-url` flag.

To solve that, I decided to monkey-patch the `taskcat` command, and added the `http://localhost:4566` value inside the code, wherever it was required. That is why we have the `taskcat_patched` folder in this project.

After a lot of debugging and testing, I was able to get the solution working.

### Limitations

The primary limitation comes from `localstack` itself, as it has a limited set of AWS services that it supports offline. Full list can be found [here](https://docs.localstack.cloud/aws/feature-coverage/).
