Metadata-Version: 2.1
Name: aviv-cdk
Version: 0.0.5
Summary: Aviv CDK Python library
Home-page: https://github.com/aviv-group/aviv-cdk-python
Author: Jules Clement
Author-email: jules.clement@aviv-group.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: boto3 (>=1.14)
Requires-Dist: click (>=7.1)
Requires-Dist: aws-parsecf (>=1.1aws-cdk-core>=1.85)
Requires-Dist: aws-cdk-aws-iam (>=1.85)
Requires-Dist: aws-cdk-aws-s3 (>=1.85)
Requires-Dist: aws-cdk-aws-lambda (>=1.85)
Requires-Dist: aws-cdk-aws-events (>=1.85)
Requires-Dist: aws-cdk-aws-events-targets (>=1.85)
Requires-Dist: aws-cdk-aws-ssm (>=1.85)
Requires-Dist: aws-cdk-aws-secretsmanager (>=1.85)
Provides-Extra: cicd
Requires-Dist: aws-cdk-aws-cloudformation ; extra == 'cicd'
Requires-Dist: aws-cdk-aws-codebuild ; extra == 'cicd'
Requires-Dist: aws-cdk-aws-codecommit ; extra == 'cicd'
Requires-Dist: aws-cdk-aws-codepipeline ; extra == 'cicd'
Requires-Dist: aws-cdk-aws-codepipeline-actions ; extra == 'cicd'
Requires-Dist: aws-cdk-aws-codestarconnections ; extra == 'cicd'
Requires-Dist: pyyaml (>=5.3.1) ; extra == 'cicd'
Provides-Extra: data
Requires-Dist: aws-cdk-glue ; extra == 'data'
Requires-Dist: aws-cdk-athena ; extra == 'data'
Provides-Extra: nextstep
Requires-Dist: aws-cdk-aws-stepfunctions ; extra == 'nextstep'
Requires-Dist: aws-cdk-aws-stepfunctions-tasks ; extra == 'nextstep'

# AVIV CDK for Python

A set of AWS CDK examples and constructs.

## Install

Requires:

- Python >= 3.6
- pip

```sh
pip install aviv-cdk
```

Extras (provides additionnal libraries, in order to build some constructs):

- `cicd` - CDK codebuild/deploy
- `nextstep` - Stepfunctions & co
- `data` - data related stuff

```sh
pip install aviv-cdk[EXTRA]
```

## Build, distrib & release

_Requires __twine__ to be installed (`pip install twine`) and credentials to upload a new verison to pypi._

```sh
python3 setup.py sdist bdist_wheel
# test distrib
python3 -m twine upload --repository testpypi dist/*
```

## Included CDK apps / samples

### CICD

```bash
cdk -a 'python3 cicd.py' synth
```

### IAM Idp

A construct that includes an AWS [lambda](lambdas/iam_idp/saml.py) function and a [cfn_resources layer](lambdas/cfn_resources/) to support it.  
This lambda is used to validate the IAM idp SAML provider.  

Use the [sample stack](app_idp.py) to get started!

```bash
# 1. Build the cfn_resources layer
cfnreqpath=$(python3 -c 'import sys; print(sys.prefix)')/share/aviv-cdk/cfn-resources/
pip install ${PIP_FLAGS} -r ${cfnreqpath}requirements.txt -t build/cfn_resources/
(cd build/cfn_resources/ &&  zip -q -r ../artifacts-cfn_resources.zip .)

# 2. Generate idp stack (example)
cdk -a 'python3 app_idp.py' synth
```

Resulting the stack and artifacts generated in `cdk.out/`.

Or use the more automated way with AWS codebuild (locally) and the [buildspec-iam-idp](buildspec-iam-idp.yml).

```bash
codebuild_build.sh -i aws/codebuild/standard:4.0 -a build -b buildspec-iam-idp.yml
```

Resulting in 2 zip files, `artifacts.zip` with the whole cdk.out/ app and `artifacts-cfn_resources.zip` which contains the python packages for the **cfn_resources** AWS lambda layer.


## Command line tools

- [aviv-aws](bin/aws_local.py) (WIP)  
  Helper to run AWS stuff locally (CDK / SAM / StepFunctionsLocal)
- [aviv-cdk-sfn-extract](bin/sfn_extract.py)  
  Extract a StateMachine from a CFN template

## Develop and contribute :)

Requirements:

- Pipenv
- AWS cdk client
- [optional] docker
- [optional] AWS codebuild docker image (standard >= 4.0)

```sh
git clone https://github.com/aviv-group/aviv-cdk-python && cd aviv-cdk-python
pipenv install -d -e .
```

### Use it

```sh
# Build layer for release

pip install -r lambdas/cfn_resources/requirements.txt -t build/layers/cfn_resources/
(cd build/layers/cfn_resources/ &&  zip -q -r ../../artifacts-cfn_resources.zip .)

# Or with codebuild agent - see: buildspec.yml
codebuild_build.sh -i aws/codebuild/standard:4.0 -a build
```

### Test

Requires: pytest

```sh
pipenv run pytest -v tests/
```

## Contribute

Yes please! Fork this project, tweak it and share it back by sending your PRs.  
Have a look at the [TODO's](TODO) and [changelog](CHANGELOG) file if you're looking for inspiration.

## License

This project is developed under the [MIT license](license).

## Author(s) and Contributors

- Jules Clement \<jules.clement@aviv-group.com>


