b-aws-testing-framework


Nameb-aws-testing-framework JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/biomapas/B.AwsTestingFramework.git
SummaryAWS infrastructure testing framework that supports multiple IAC tools.
upload_time2023-08-02 12:15:06
maintainer
docs_urlNone
authorLaimonas Sutkus
requires_python
licenseApache License 2.0
keywords aws test iac
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # B.AwsTestingFramework

A python based AWS infrastructure testing micro-framework.<br>
It supports multiple IAC tools like AWS CDK and AWS CloudFormation.

### Description

Creating infrastructure in AWS is quite hard. There are many nuances,
pitfalls and "gotchas" that sometimes are awfully frustrating. Often some 
IAC code changes might result in some unexpected infrastructure changes.
That is why the created infrastructure should have automated integration tests. 
This python based framework provides you basic functionality to help you
write unit ant integration tests to test AWS infrastructure created
via UI or via tools like AWS CDK. 

The framework is based on pytest - a python based testing library. With that
said, all pytest functionality and configs can be applied on this framework too.

The framework is easy to use with explicit examples for each IAC tool. Go to
examples section and find which example suits you the most.

### Remarks

[Biomapas](https://biomapas.com) aims to modernise life-science 
industry by sharing its IT knowledge with other companies and 
the community. This is an open source library intended to be used 
by anyone. Improvements and pull requests are welcome.

### Related technology

- Python 3
- Pytest
- AWS CDK
- AWS CloudFormation

### Assumptions

The project assumes the following:

- You have basic-good knowledge in python programming.
- You have basic-good knowledge in AWS.
- You have basic knowledge in testing.

### Useful sources

- Read more about pytest:<br>
https://docs.pytest.org/en/latest/

### Install

The project is built and uploaded to PyPi. Install it by using pip.

```
pip install b_aws_testing_framework
```

Or directly install it through source.

```
pip install .
```

### Usage & Examples

The framework uses flexible credentials management. You can either
set credentials in the constructor:
```python
from b_aws_testing_framework.credentials import Credentials
Credentials(
    aws_access_key_id='key',
    aws_secret_access_key='secret',
    region_name='region'
)
```

Or you can set the environment:
```
set AWS_ACCESS_KEY_ID=key
set AWS_SECRET_ACCESS_KEY=key
set AWS_DEFAULT_REGION=region
```

And then in your python program:
```python
from b_aws_testing_framework.credentials import Credentials
Credentials()
```

After setting the credentials you can set a `global prefix`. Global prefix
is a globally accessible peace of string that can be used when naming AWS 
resources. This is extremely useful when running tests in CI/CD pipelines
where we can have more than one parallel pipeline running. To access and
manage a global prefix, import your testing manager and use these commands:
```python
# Set a random string.
TestingManager.set_global_prefix()

# Create a resource with a unique name. E.g.
CdkStack(
    scope=scope,
    id=f'{TestingManager.get_global_prefix()}TestingStackId',
    stack_name=f'{TestingManager.get_global_prefix()}TestingStackName'
)
```

See the specific examples for specific tools:

- [Testing AWS CDK based projects](https://github.com/Biomapas/B.AwsTestingFramework/blob/master/documentation/example-cdk.md)
- [Testing CloudFormation based projects](https://github.com/Biomapas/B.AwsTestingFramework/blob/master/documentation/example-cf.md)

### Testing

The project has tests that can be run. 
Note, that tests are integration tests inherently because they
test how resources are created in AWS environment. Since resources 
are created and tested in AWS you are subject for all the applicable
charges while tests are being run.

#### Setting environment

Before running tests set environment variables:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION

Or:
- AWS_PROFILE
- AWS_DEFAULT_REGION

#### Running tests

Then run tests from a root directory with `pytest` python testing library.

Testing *CloudFormation* functionality:
```
pytest b_aws_testing_framework_test/tools/testing_with_cf
```

Testing *Cloud Development Kit* functionality:
```
pytest b_aws_testing_framework_test/tools/testing_with_cdk
```

Note that integration tests usually take a while to complete (from 5 to 30
minutes on average).

### Contribution

Found a bug? Want to add or suggest a new feature?<br>
Contributions of any kind are gladly welcome. You may contact us 
directly, create a pull-request or an issue in github platform.
Lets modernize the world together.


# Release history

### 1.0.1
* Update pipelines to fix "unclosed SSLSocket" warnings.

### 1.0.0
* Upgrade CDK support from v1 to v2.
* Upgrade GitHub pipelines checkout version from v2 to v3.
* Upgrade biomapas/cicd-full image version to 5.0.0.

### 0.6.0
* Too many bugs. Revert.

### 0.5.5
* Warn if not cdk tool was found.

### 0.5.4
* Make sure to exit after successful cdk execution.

### 0.5.3
* Use "." instead of "source".

### 0.5.2
* Execute cdk command in the same shell to preserve environment.

### 0.5.1
* Allow running cdk command even though it might be now defined globally.

### 0.5.0
* Pass config object to custom actions.

### 0.4.3
* Fix version retrieval.

### 0.4.2
* For the default SSM parameter name use "name" instead of "global prefix".

### 0.4.1
* Make sure default SSM parameter is unique.

### 0.4.0
* Add default SSM parameter for package version.

### 0.3.3.
* Fix logging issues.
* Run prehooks on session-start and session-finish.
* Add more logging.

### 0.3.2
* Fix warnings. 

### 0.3.1
* Bug fixes.

### 0.3.0
* Add ability to specify custom deployment command in AWS CDK flow (destroy action).

### 0.2.0
* Add ability to specify custom deployment command in AWS CDK flow (deploy action).

### 0.1.0
* Allow to override the TestingStack's name.

### 0.0.24
* Update boto version requirement.

### 0.0.23
* Prettify example CDK project.

### 0.0.22
* Add prefixes for CF outputs too.
* Prettify CDK testing.

### 0.0.21
* Add ability to specify session token.

### 0.0.20
* Remove root path from cdk config in the documentation.

### 0.0.19
* Make sure that Python path is propagated to the process.

### 0.0.18
* Expose global prefix in the Testing stack.
* Update example project.
* Add ability to specify root project to fix import errors.
* Updated tests.
* Update documentation.

### 0.0.17
* Improve documentation with better cdk project examples.
* Add an example cdk project.
* Remove test coverage.

### 0.0.13
* Add testing stack for more convenient CF outputs management.
* Update documentation.
* Add docstrings.
* Updates tests and conftest configuration files.
* Version bump.

### 0.0.12
* Add a flag to specify whether the infrastructure should be destroyed
before creating a new one.

### 0.0.11
* Add documentation about global prefix in readme.

### 0.0.10
* Create a global prefix for unique resources.

### 0.0.9
* Create github pipelines.
* Update code.

### 0.0.8
* Make sure CDK deploy works both on linux based systems and windows based systems.

### 0.0.7
* Bug fix related to environment.

### 0.0.6
* Update pytest dependency version.

### 0.0.5
* Rethink how this framework should be used.

### 0.0.4
* Fix imports.
* Update examples.

### 0.0.3
* Rename project.
* Update gitignore and ignore idea files.
* Update MANIFEST.
* Move examples to a documentation folder.

### 0.0.2
* Add hyperlinks for examples.

### 0.0.1
* Initial build.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/biomapas/B.AwsTestingFramework.git",
    "name": "b-aws-testing-framework",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "AWS Test IAC",
    "author": "Laimonas Sutkus",
    "author_email": "laimonas.sutkus@biomapas.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/dd/08f699420962887f814c72c434a3df1479577ea82faf88efdc6050f6ce2d/b_aws_testing_framework-1.0.1.tar.gz",
    "platform": null,
    "description": "# B.AwsTestingFramework\n\nA python based AWS infrastructure testing micro-framework.<br>\nIt supports multiple IAC tools like AWS CDK and AWS CloudFormation.\n\n### Description\n\nCreating infrastructure in AWS is quite hard. There are many nuances,\npitfalls and \"gotchas\" that sometimes are awfully frustrating. Often some \nIAC code changes might result in some unexpected infrastructure changes.\nThat is why the created infrastructure should have automated integration tests. \nThis python based framework provides you basic functionality to help you\nwrite unit ant integration tests to test AWS infrastructure created\nvia UI or via tools like AWS CDK. \n\nThe framework is based on pytest - a python based testing library. With that\nsaid, all pytest functionality and configs can be applied on this framework too.\n\nThe framework is easy to use with explicit examples for each IAC tool. Go to\nexamples section and find which example suits you the most.\n\n### Remarks\n\n[Biomapas](https://biomapas.com) aims to modernise life-science \nindustry by sharing its IT knowledge with other companies and \nthe community. This is an open source library intended to be used \nby anyone. Improvements and pull requests are welcome.\n\n### Related technology\n\n- Python 3\n- Pytest\n- AWS CDK\n- AWS CloudFormation\n\n### Assumptions\n\nThe project assumes the following:\n\n- You have basic-good knowledge in python programming.\n- You have basic-good knowledge in AWS.\n- You have basic knowledge in testing.\n\n### Useful sources\n\n- Read more about pytest:<br>\nhttps://docs.pytest.org/en/latest/\n\n### Install\n\nThe project is built and uploaded to PyPi. Install it by using pip.\n\n```\npip install b_aws_testing_framework\n```\n\nOr directly install it through source.\n\n```\npip install .\n```\n\n### Usage & Examples\n\nThe framework uses flexible credentials management. You can either\nset credentials in the constructor:\n```python\nfrom b_aws_testing_framework.credentials import Credentials\nCredentials(\n    aws_access_key_id='key',\n    aws_secret_access_key='secret',\n    region_name='region'\n)\n```\n\nOr you can set the environment:\n```\nset AWS_ACCESS_KEY_ID=key\nset AWS_SECRET_ACCESS_KEY=key\nset AWS_DEFAULT_REGION=region\n```\n\nAnd then in your python program:\n```python\nfrom b_aws_testing_framework.credentials import Credentials\nCredentials()\n```\n\nAfter setting the credentials you can set a `global prefix`. Global prefix\nis a globally accessible peace of string that can be used when naming AWS \nresources. This is extremely useful when running tests in CI/CD pipelines\nwhere we can have more than one parallel pipeline running. To access and\nmanage a global prefix, import your testing manager and use these commands:\n```python\n# Set a random string.\nTestingManager.set_global_prefix()\n\n# Create a resource with a unique name. E.g.\nCdkStack(\n    scope=scope,\n    id=f'{TestingManager.get_global_prefix()}TestingStackId',\n    stack_name=f'{TestingManager.get_global_prefix()}TestingStackName'\n)\n```\n\nSee the specific examples for specific tools:\n\n- [Testing AWS CDK based projects](https://github.com/Biomapas/B.AwsTestingFramework/blob/master/documentation/example-cdk.md)\n- [Testing CloudFormation based projects](https://github.com/Biomapas/B.AwsTestingFramework/blob/master/documentation/example-cf.md)\n\n### Testing\n\nThe project has tests that can be run. \nNote, that tests are integration tests inherently because they\ntest how resources are created in AWS environment. Since resources \nare created and tested in AWS you are subject for all the applicable\ncharges while tests are being run.\n\n#### Setting environment\n\nBefore running tests set environment variables:\n- AWS_ACCESS_KEY_ID\n- AWS_SECRET_ACCESS_KEY\n- AWS_DEFAULT_REGION\n\nOr:\n- AWS_PROFILE\n- AWS_DEFAULT_REGION\n\n#### Running tests\n\nThen run tests from a root directory with `pytest` python testing library.\n\nTesting *CloudFormation* functionality:\n```\npytest b_aws_testing_framework_test/tools/testing_with_cf\n```\n\nTesting *Cloud Development Kit* functionality:\n```\npytest b_aws_testing_framework_test/tools/testing_with_cdk\n```\n\nNote that integration tests usually take a while to complete (from 5 to 30\nminutes on average).\n\n### Contribution\n\nFound a bug? Want to add or suggest a new feature?<br>\nContributions of any kind are gladly welcome. You may contact us \ndirectly, create a pull-request or an issue in github platform.\nLets modernize the world together.\n\n\n# Release history\n\n### 1.0.1\n* Update pipelines to fix \"unclosed SSLSocket\" warnings.\n\n### 1.0.0\n* Upgrade CDK support from v1 to v2.\n* Upgrade GitHub pipelines checkout version from v2 to v3.\n* Upgrade biomapas/cicd-full image version to 5.0.0.\n\n### 0.6.0\n* Too many bugs. Revert.\n\n### 0.5.5\n* Warn if not cdk tool was found.\n\n### 0.5.4\n* Make sure to exit after successful cdk execution.\n\n### 0.5.3\n* Use \".\" instead of \"source\".\n\n### 0.5.2\n* Execute cdk command in the same shell to preserve environment.\n\n### 0.5.1\n* Allow running cdk command even though it might be now defined globally.\n\n### 0.5.0\n* Pass config object to custom actions.\n\n### 0.4.3\n* Fix version retrieval.\n\n### 0.4.2\n* For the default SSM parameter name use \"name\" instead of \"global prefix\".\n\n### 0.4.1\n* Make sure default SSM parameter is unique.\n\n### 0.4.0\n* Add default SSM parameter for package version.\n\n### 0.3.3.\n* Fix logging issues.\n* Run prehooks on session-start and session-finish.\n* Add more logging.\n\n### 0.3.2\n* Fix warnings. \n\n### 0.3.1\n* Bug fixes.\n\n### 0.3.0\n* Add ability to specify custom deployment command in AWS CDK flow (destroy action).\n\n### 0.2.0\n* Add ability to specify custom deployment command in AWS CDK flow (deploy action).\n\n### 0.1.0\n* Allow to override the TestingStack's name.\n\n### 0.0.24\n* Update boto version requirement.\n\n### 0.0.23\n* Prettify example CDK project.\n\n### 0.0.22\n* Add prefixes for CF outputs too.\n* Prettify CDK testing.\n\n### 0.0.21\n* Add ability to specify session token.\n\n### 0.0.20\n* Remove root path from cdk config in the documentation.\n\n### 0.0.19\n* Make sure that Python path is propagated to the process.\n\n### 0.0.18\n* Expose global prefix in the Testing stack.\n* Update example project.\n* Add ability to specify root project to fix import errors.\n* Updated tests.\n* Update documentation.\n\n### 0.0.17\n* Improve documentation with better cdk project examples.\n* Add an example cdk project.\n* Remove test coverage.\n\n### 0.0.13\n* Add testing stack for more convenient CF outputs management.\n* Update documentation.\n* Add docstrings.\n* Updates tests and conftest configuration files.\n* Version bump.\n\n### 0.0.12\n* Add a flag to specify whether the infrastructure should be destroyed\nbefore creating a new one.\n\n### 0.0.11\n* Add documentation about global prefix in readme.\n\n### 0.0.10\n* Create a global prefix for unique resources.\n\n### 0.0.9\n* Create github pipelines.\n* Update code.\n\n### 0.0.8\n* Make sure CDK deploy works both on linux based systems and windows based systems.\n\n### 0.0.7\n* Bug fix related to environment.\n\n### 0.0.6\n* Update pytest dependency version.\n\n### 0.0.5\n* Rethink how this framework should be used.\n\n### 0.0.4\n* Fix imports.\n* Update examples.\n\n### 0.0.3\n* Rename project.\n* Update gitignore and ignore idea files.\n* Update MANIFEST.\n* Move examples to a documentation folder.\n\n### 0.0.2\n* Add hyperlinks for examples.\n\n### 0.0.1\n* Initial build.\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "AWS infrastructure testing framework that supports multiple IAC tools.",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/biomapas/B.AwsTestingFramework.git"
    },
    "split_keywords": [
        "aws",
        "test",
        "iac"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7236f6660ebe099718190038bd7959de18cb0d2ffcf4118b64d37c8242c3526a",
                "md5": "b23aeed38cc66ebdf66b46f41818c234",
                "sha256": "e0c43a5fc0dfdfec081a746ff5e2932505721c03de79c7ae03f108a63731effc"
            },
            "downloads": -1,
            "filename": "b_aws_testing_framework-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b23aeed38cc66ebdf66b46f41818c234",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22943,
            "upload_time": "2023-08-02T12:15:05",
            "upload_time_iso_8601": "2023-08-02T12:15:05.188429Z",
            "url": "https://files.pythonhosted.org/packages/72/36/f6660ebe099718190038bd7959de18cb0d2ffcf4118b64d37c8242c3526a/b_aws_testing_framework-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ddd08f699420962887f814c72c434a3df1479577ea82faf88efdc6050f6ce2d",
                "md5": "19ec5a200bccde8c1835bd45abf6b14b",
                "sha256": "81fca5343e16c8d59ec33832b772202327ffbe0ca205c4996522d842871394d6"
            },
            "downloads": -1,
            "filename": "b_aws_testing_framework-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "19ec5a200bccde8c1835bd45abf6b14b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18780,
            "upload_time": "2023-08-02T12:15:06",
            "upload_time_iso_8601": "2023-08-02T12:15:06.915463Z",
            "url": "https://files.pythonhosted.org/packages/9d/dd/08f699420962887f814c72c434a3df1479577ea82faf88efdc6050f6ce2d/b_aws_testing_framework-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-02 12:15:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "biomapas",
    "github_project": "B.AwsTestingFramework",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "b-aws-testing-framework"
}
        
Elapsed time: 0.30956s