Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
feat(infra): intialise CDK project
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
Simon Planzer authored Sep 26, 2020
1 parent b68838d commit ded441b
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 3 deletions.
62 changes: 59 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Central storage, management and access for important geospatial datasets
Developed by [Land Information New Zealand](https://github.com/linz)


## Installation
* Create and activate a virtual environment.
# Dependencies Installation
## Python Virtual Environment (for Python CLI and AWS CDK)
* Create and activate a Python virtual environment

```bash
$ python3 -m venv .venv
Expand All @@ -17,6 +18,41 @@ $ source .venv/bin/activate

```bash
$ pip install --upgrade pip
```


## AWS CDK Environment (AWS Infrastructure)
* Install NVM (use latest version)

```bash
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v<LATEST-VERSION>/install.sh | bash
```

* Enable NVM

```bash
$ export NVM_DIR="$HOME/.nvm"
$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
$ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
```

* Install latest LTS Node version

```bash
$ nvm install --lts
```

* Install latest AWS CDK version

```bash
$ npm install -g aws-cdk
```


## Python CLI Installation
* Install Python dependencies

```bash
$ pip install -r requirements.txt
```

Expand All @@ -27,8 +63,28 @@ $ python ./setup.py install
```


## AWS Infrastructure Deployment (CDK Stack)
* Install Python CDK dependencies

```bash
$ pip install -r requirements-infra.txt
```

* Get AWS credentials (see: https://www.npmjs.com/package/aws-azure-login)

```bash
$ aws-azure-login -p <linz-data-lake-nonprod|linz-data-lake-prod>
```

* Deploy CDK stack

```bash
$ cdk deploy --profile <linz-data-lake-nonprod|linz-data-lake-prod> <data-lake-raster-nonprod|data-lake-raster-prod>
```


## Development
* Install development dependencies
* Install Python development dependencies

```bash
$ pip install -r requirements-dev.txt
Expand Down
22 changes: 22 additions & 0 deletions infra/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3

from aws_cdk import core
from data_stores.data_lake_stack import DataLakeStack

app = core.App()

DataLakeStack(
app,
"data-lake-nonprod",
stack_name="geospatial-data-lake-nonprod",
env={"region": "ap-southeast-2", "account": "632223577832"},
)

DataLakeStack(
app,
"data-lake-prod",
stack_name="geospatial-data-lake-prod",
env={"region": "ap-southeast-2", "account": "715898075157"},
)

app.synth()
8 changes: 8 additions & 0 deletions infra/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"app": "python3 app.py",
"context": {
"@aws-cdk/core:enableStackNameDuplicates": "true",
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true"
}
}
Empty file added infra/data_stores/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions infra/data_stores/data_lake_stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from aws_cdk import core


class DataLakeStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)

# The code that defines your stack goes here
3 changes: 3 additions & 0 deletions requirements-infra.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
aws-cdk.aws-s3
aws-cdk.aws-iam
awscli

0 comments on commit ded441b

Please sign in to comment.