iacer


Nameiacer JSON
Version 0.0.15 PyPI version JSON
download
home_page
SummaryIacer
upload_time2023-02-01 09:08:10
maintainer
docs_urlNone
authorqitan
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # What is Iacer?

Iacer is a tool that tests [Terraform](https://developer.hashicorp.com/terraform) and [ROS(Resource Orchestration Service)](https://www.alibabacloud.com/help/resource-orchestration-service) templates. It deploys your template in multiple Alibaba Cloud Regions and generates a report for each region via a simple configuration file.  

# Installation

`pip install iacer`

# Requirements
Python 3.7+

The iacer is run on requires access to an Alibaba Cloud account, this can be done by any of the following mechanisms:
1. AliyunCli default configuration file (`~/.aliyun/config.json`)
2. Environment variables (`ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET`)
3. The ini configuration file defined by the environment variable ALIBABA_CLOUD_CREDENTIALS_FILE
4. Alibaba Cloud SDK Credentials default configuration file (`~/.alibabacloud/credentials.ini` or `~/.aliyun/credentials.ini`)

# Usage

iacer adopts a similar cli command structure to `git` with a `iacer command subcommand --flag` style. The cli is also designed to be the simplest if run from the root of a project. Let's have a look at equivalent command to run a test:

cd into the project root and type test run
```shell
cd ./demo
iacer test run
```

or run it from anywhere by providing the path to the project root
```shell
iacer test run --project-path ./demo
```


## Cli Command
The cli is self documenting by using `--help` or `-h`, the most common command is `iacer test`

```
iacer test -h
usage: iacer [args] test [args] [subcommand] [args] 

Performs functional tests on IaC templates.

options:
  -h, --help  show this help message and exit

subcommands:
  clean - Manually clean up the stacks which were created by Iacer
  list - List stacks which were created by Iacer for all regions
  params - Generate pseudo parameters
  run - tests whether IaC templates are able to successfully launch
```

```
iacer test run -h
usage: iacer [args] <command> [args] run [args] 

tests whether IaC templates are able to successfully launch

options:
  -h, --help            show this help message and exit
  -t TEMPLATE, --template TEMPLATE
                        path to a template
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        path to a config file
  -o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
                        path to an output directory
  -r REGIONS, --regions REGIONS
                        comma separated list of regions to test in
  --test-names TEST_NAMES
                        comma separated list of tests to run
  --no-delete           don't delete stacks after test is complete
  --project-path PROJECT_PATH
                        root path of the project relative to config file,
                        template file and output file
  --keep-failed         do not delete failed stacks
  --dont-wait-for-delete
                        exits immediately after calling delete stack
  -g, --generate-parameters
                        generate pseudo parameters
```

## Configuration files
There are 2 config files which can be used to set behaviors.

1. Global config file, located in `~/.iacer.yml`
2. Project config file, located in `<PROJECT_ROOT>/.iacer.yml`

Each configuration file supports three-tier configuration, which includes `general`, `project` and `tests`, and `tests` is required.

### general configuration item

- `auth` Aliyun authentication section.
```json
{
  "name": "default", 
  "location": "~/.aliyun/config.json"
}
```

- `oss_config` Oss bucket configuration, include BucketName, BucketRegion and etc.
```json
{
  "bucket_name": "",
  "bucket_region": "",
  "object_prefix": "",
  "callback_params": {
    "callback_url": "",
    "callback_host": "",
    "callback_body": "",
    "callback_body_type": "",
    "callback_var_params": ""
  }
}
```

- `parameters` Parameter key-values to pass to template.
```json
{
  "vpc_id": "",
  "vsw_id": ""
}
```

### project configuration item

- `name` Project Name
- `regions` List of aliyun regions.
- `parameters` Parameter key-values to pass to template.
- `tags` Tags
- `role_name` Role name
- `template_config` Template config
```json
{
  "template_location": "myTemplate/",
  "template_url": "oss://xxx",
  "template_body": "",
  "template_id": "",
  "template_version": ""
}
```

### tests configuration item

- `name` Project Name
- `regions` List of aliyun regions.
- `parameters` Parameter key-values to pass to template.
- `tags` Tags
- `role_name` Role name
- `template_config` Template config
```json
{
  "template_location": "myTemplate/",
  "template_url": "oss://xxx",
  "template_body": "",
  "template_id": "",
  "template_version": ""
}
```

## Precedence

Except the parameters section, more specific config with the same key takes precedence.

> The rationale behind having parameters function this way is so that values can be overridden at a system level outside a project, that is likely committed to source control. parameters that define account specific things like VPC details, Key Pairs, or secrets like API keys can be defined per host outside of source control. 

For example, consider this global config in `~/.iacer.yml`

```yaml
general:
  oss_config: 
    bucket_name: global-bucket
  parameters:
    KeyPair: my-global-ecs-key-pair
```

and this project config
```yaml
project:
  name: my-project
  regions:
    - cn-hangzhou
  oss_config:
    bucket_name: project-bucket
tests:
  default:
    template_config:
      template_url: "oss://xxx"
    regions:
      - cn-beijing
    parameters:
      KeyPair: my-test-ecs-key-pair
```
Would result in this effective test configuration:

```yaml
tests:
  default:
    template_config:
      template_url: "oss://xxx"
    regions:
      - cn-beijing
    oss_config:
      bucket_name: project-bucket
    parameters:
      KeyPair: my-test-ecs-key-pair
```

Notice that `bucket_name` and `regions` took the most specific value and `KeyPair` the most general.

## Pseudo Parameters

You can automatically get the available parameters through the `$[iacer-auto]` pseudo-parameter if the parameter is the following 2 cases
1. The resource attribute corresponding to the parameter supports the ROS [GetTemplateParameterConstraints](https://www.alibabacloud.com/help/en/resource-orchestration-service/latest/gettemplateparameterconstraints) interface.
2. Parameters whose name itself has a specific meaning. For example, `VpcId` means the id of virtual private cloud and `$[iacer-auto]` will automatically obtain a vpcId randomly in the current region of the current account. Currently supported are as follows:
   1. Satisfying the regularity `r"(\w*)vpc(_|)id(_|)(\d*)"` will automatically and randomly obtain the VpcId in the current region.
   2. Satisfying the regularity `r"(\w*)v(_|)switch(_|)id(_|)(\d*)"` will automatically and randomly obtain the VswitchId in the current region. If there is a parameter whose name satisfies the regularity `r"(\w*)zone(_|)id(_|)(\d*)"`, it will query the VswitchId of the corresponding availability zone
   3. Satisfying the regularity `r"(\w*)security(_|)group(_id|id)(_|)(\d*)"` will automatically and randomly obtain the SecurityGroupId in the current region.
   4. Satisfying the regularity `r"(\w*)name(_|)(\d*)"` will automatically generate a random string starting with `iacer-`.
   5. Satisfying the regularity `r"(\w*)password(_|)(\d*)"` will automatically generate a password.
   6. Satisfying the regularity `r"(\w*)uuid(_|)(\d*)"` will automatically generate an uuid.




















            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "iacer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "qitan",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/1d/0a/87e4e6a13bc297fcc90f61ffd8914a2cc1ae5238f3e7a37f964028235745/iacer-0.0.15.tar.gz",
    "platform": null,
    "description": "# What is Iacer?\n\nIacer is a tool that tests [Terraform](https://developer.hashicorp.com/terraform) and [ROS(Resource Orchestration Service)](https://www.alibabacloud.com/help/resource-orchestration-service) templates. It deploys your template in multiple Alibaba Cloud Regions and generates a report for each region via a simple configuration file.  \n\n# Installation\n\n`pip install iacer`\n\n# Requirements\nPython 3.7+\n\nThe iacer is run on requires access to an Alibaba Cloud account, this can be done by any of the following mechanisms:\n1. AliyunCli default configuration file (`~/.aliyun/config.json`)\n2. Environment variables (`ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET`)\n3. The ini configuration file defined by the environment variable ALIBABA_CLOUD_CREDENTIALS_FILE\n4. Alibaba Cloud SDK Credentials default configuration file (`~/.alibabacloud/credentials.ini` or `~/.aliyun/credentials.ini`)\n\n# Usage\n\niacer adopts a similar cli command structure to `git` with a `iacer command subcommand --flag` style. The cli is also designed to be the simplest if run from the root of a project. Let's have a look at equivalent command to run a test:\n\ncd into the project root and type test run\n```shell\ncd ./demo\niacer test run\n```\n\nor run it from anywhere by providing the path to the project root\n```shell\niacer test run --project-path ./demo\n```\n\n\n## Cli Command\nThe cli is self documenting by using `--help` or `-h`, the most common command is `iacer test`\n\n```\niacer test -h\nusage: iacer [args] test [args] [subcommand] [args] \n\nPerforms functional tests on IaC templates.\n\noptions:\n  -h, --help  show this help message and exit\n\nsubcommands:\n  clean - Manually clean up the stacks which were created by Iacer\n  list - List stacks which were created by Iacer for all regions\n  params - Generate pseudo parameters\n  run - tests whether IaC templates are able to successfully launch\n```\n\n```\niacer test run -h\nusage: iacer [args] <command> [args] run [args] \n\ntests whether IaC templates are able to successfully launch\n\noptions:\n  -h, --help            show this help message and exit\n  -t TEMPLATE, --template TEMPLATE\n                        path to a template\n  -c CONFIG_FILE, --config-file CONFIG_FILE\n                        path to a config file\n  -o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY\n                        path to an output directory\n  -r REGIONS, --regions REGIONS\n                        comma separated list of regions to test in\n  --test-names TEST_NAMES\n                        comma separated list of tests to run\n  --no-delete           don't delete stacks after test is complete\n  --project-path PROJECT_PATH\n                        root path of the project relative to config file,\n                        template file and output file\n  --keep-failed         do not delete failed stacks\n  --dont-wait-for-delete\n                        exits immediately after calling delete stack\n  -g, --generate-parameters\n                        generate pseudo parameters\n```\n\n## Configuration files\nThere are 2 config files which can be used to set behaviors.\n\n1. Global config file, located in `~/.iacer.yml`\n2. Project config file, located in `<PROJECT_ROOT>/.iacer.yml`\n\nEach configuration file supports three-tier configuration, which includes `general`, `project` and `tests`, and `tests` is required.\n\n### general configuration item\n\n- `auth` Aliyun authentication section.\n```json\n{\n  \"name\": \"default\", \n  \"location\": \"~/.aliyun/config.json\"\n}\n```\n\n- `oss_config` Oss bucket configuration, include BucketName, BucketRegion and etc.\n```json\n{\n  \"bucket_name\": \"\",\n  \"bucket_region\": \"\",\n  \"object_prefix\": \"\",\n  \"callback_params\": {\n    \"callback_url\": \"\",\n    \"callback_host\": \"\",\n    \"callback_body\": \"\",\n    \"callback_body_type\": \"\",\n    \"callback_var_params\": \"\"\n  }\n}\n```\n\n- `parameters` Parameter key-values to pass to template.\n```json\n{\n  \"vpc_id\": \"\",\n  \"vsw_id\": \"\"\n}\n```\n\n### project configuration item\n\n- `name` Project Name\n- `regions` List of aliyun regions.\n- `parameters` Parameter key-values to pass to template.\n- `tags` Tags\n- `role_name` Role name\n- `template_config` Template config\n```json\n{\n  \"template_location\": \"myTemplate/\",\n  \"template_url\": \"oss://xxx\",\n  \"template_body\": \"\",\n  \"template_id\": \"\",\n  \"template_version\": \"\"\n}\n```\n\n### tests configuration item\n\n- `name` Project Name\n- `regions` List of aliyun regions.\n- `parameters` Parameter key-values to pass to template.\n- `tags` Tags\n- `role_name` Role name\n- `template_config` Template config\n```json\n{\n  \"template_location\": \"myTemplate/\",\n  \"template_url\": \"oss://xxx\",\n  \"template_body\": \"\",\n  \"template_id\": \"\",\n  \"template_version\": \"\"\n}\n```\n\n## Precedence\n\nExcept the parameters section, more specific config with the same key takes precedence.\n\n> The rationale behind having parameters function this way is so that values can be overridden at a system level outside a project, that is likely committed to source control. parameters that define account specific things like VPC details, Key Pairs, or secrets like API keys can be defined per host outside of source control. \n\nFor example, consider this global config in `~/.iacer.yml`\n\n```yaml\ngeneral:\n  oss_config: \n    bucket_name: global-bucket\n  parameters:\n    KeyPair: my-global-ecs-key-pair\n```\n\nand this project config\n```yaml\nproject:\n  name: my-project\n  regions:\n    - cn-hangzhou\n  oss_config:\n    bucket_name: project-bucket\ntests:\n  default:\n    template_config:\n      template_url: \"oss://xxx\"\n    regions:\n      - cn-beijing\n    parameters:\n      KeyPair: my-test-ecs-key-pair\n```\nWould result in this effective test configuration:\n\n```yaml\ntests:\n  default:\n    template_config:\n      template_url: \"oss://xxx\"\n    regions:\n      - cn-beijing\n    oss_config:\n      bucket_name: project-bucket\n    parameters:\n      KeyPair: my-test-ecs-key-pair\n```\n\nNotice that `bucket_name` and `regions` took the most specific value and `KeyPair` the most general.\n\n## Pseudo Parameters\n\nYou can automatically get the available parameters through the `$[iacer-auto]` pseudo-parameter if the parameter is the following 2 cases\n1. The resource attribute corresponding to the parameter supports the ROS [GetTemplateParameterConstraints](https://www.alibabacloud.com/help/en/resource-orchestration-service/latest/gettemplateparameterconstraints) interface.\n2. Parameters whose name itself has a specific meaning. For example, `VpcId` means the id of virtual private cloud and `$[iacer-auto]` will automatically obtain a vpcId randomly in the current region of the current account. Currently supported are as follows:\n   1. Satisfying the regularity `r\"(\\w*)vpc(_|)id(_|)(\\d*)\"` will automatically and randomly obtain the VpcId in the current region.\n   2. Satisfying the regularity `r\"(\\w*)v(_|)switch(_|)id(_|)(\\d*)\"` will automatically and randomly obtain the VswitchId in the current region. If there is a parameter whose name satisfies the regularity `r\"(\\w*)zone(_|)id(_|)(\\d*)\"`, it will query the VswitchId of the corresponding availability zone\n   3. Satisfying the regularity `r\"(\\w*)security(_|)group(_id|id)(_|)(\\d*)\"` will automatically and randomly obtain the SecurityGroupId in the current region.\n   4. Satisfying the regularity `r\"(\\w*)name(_|)(\\d*)\"` will automatically generate a random string starting with `iacer-`.\n   5. Satisfying the regularity `r\"(\\w*)password(_|)(\\d*)\"` will automatically generate a password.\n   6. Satisfying the regularity `r\"(\\w*)uuid(_|)(\\d*)\"` will automatically generate an uuid.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Iacer",
    "version": "0.0.15",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f6893373484d634a9621e4f43358cc6af518a988f96fa4acc3b0152accebdcb",
                "md5": "cc01da92164a59ccc361d06d66507a71",
                "sha256": "30595da9b1edd4b33f69bdcbb3f8cf25bffe35c0a6832decedf1e9b805bc9cc5"
            },
            "downloads": -1,
            "filename": "iacer-0.0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cc01da92164a59ccc361d06d66507a71",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 45666,
            "upload_time": "2023-02-01T09:08:08",
            "upload_time_iso_8601": "2023-02-01T09:08:08.060880Z",
            "url": "https://files.pythonhosted.org/packages/2f/68/93373484d634a9621e4f43358cc6af518a988f96fa4acc3b0152accebdcb/iacer-0.0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1d0a87e4e6a13bc297fcc90f61ffd8914a2cc1ae5238f3e7a37f964028235745",
                "md5": "02948110053473d464b6b5cdc414c5cc",
                "sha256": "90aa4964f666911787b0ab76f994e8a30f08474b43fba2d254278af02f04b464"
            },
            "downloads": -1,
            "filename": "iacer-0.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "02948110053473d464b6b5cdc414c5cc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 40702,
            "upload_time": "2023-02-01T09:08:10",
            "upload_time_iso_8601": "2023-02-01T09:08:10.322356Z",
            "url": "https://files.pythonhosted.org/packages/1d/0a/87e4e6a13bc297fcc90f61ffd8914a2cc1ae5238f3e7a37f964028235745/iacer-0.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-01 09:08:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "iacer"
}
        
Elapsed time: 0.03377s