# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['tfmake', 'tfmake.custom']

package_data = \
{'': ['*'], 'tfmake': ['templates/*']}

install_requires = \
['Jinja2>=2.11.1,<3.0.0',
 'PyYAML>=5.3.1,<6.0.0',
 'click>=7.0,<8.0',
 'outdated>=0.2.0,<0.3.0',
 'pathlib>=1.0.1,<2.0.0']

entry_points = \
{'console_scripts': ['tfmake = tfmake.cli:main']}

setup_kwargs = {
    'name': 'tfmake',
    'version': '1.0.52',
    'description': 'Python based Makefile wrapper for terraform projects',
    'long_description': '# tfmake\n\n## Hello ! 👋\n\nThis is a Python based wrapper around an opionated `Makefile` I use for multi-cloud/cross-account `terraform` projects. \n\nYou still need `make`, though. The main advantage is that you don\'t have to copy the `Makefile`. \n\n## DISCLAIMER\nThis module includes a highly opinionated `Makefile` implementation. It\'s working very well for us, but your requirements might be different.\n\nAlso, I\'ve done my best to make this thing work on both MacOS and Linux. If you get an error message (~ and my colleagues haven\'t beat you to it) ... please get in touch and/or create a PR.\n\n## Install\n\n```\n$ pip install tfmake\n```\n\n## Usage\n> Here\'s the help for the wrapper\n```\n$ tfmake --help\nUsage: tfmake [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --version  Show the version and exit.\n  --help     Show this message and exit.\n\nCommands:\n  aws    Use AWS provider.\n  azure  Use Azure provider\n  guess  Default command that guesses what provider you\'re using.\n  init   Create configuration for provider.\n```\n\nA warning will be shown when your `tfmake` is out-of-date. If you see one, please update: `pip install --upgrade tfmake` \n\n## Providers\nCurrently, `tfmake` supports two providers: `aws` and `azure`. The default provider is `aws`. Depending on the selected provider, a different, provider specific, `Makefile` is used to wrap `terraform`. Here, the provider is selected by using the right command.\n\nSee \'examples\' for some ... examples.\n\nEach provider leads to a specific `Makefile`. For example: `provider==azure` leads to using `Makefile.azure`.\n\n## Provider Authentication\nThe used `Makefile` will _not_ handle authentication. It just assumes you\'re using an authenticated context.\n\nFor, `aws`, I use [`aws-vault`](https://github.com/99designs/aws-vault). For `azure`, I use the [`azure-cli`](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest).\n\n> Here\'s the help for the (bundled) Makefile\n```\n$ tfmake help\nThe AWS Edition\n\nUsage: make <TARGET> (env=<ENVIRONMENT>) (<TERRAFORM ARGUMENTS>)\n\nWhere:\n ENVIRONMENT is one of [\'dev\',\'tst\',\'acc\',\'qas\',\'prd\',\'run\']\n TARGET is one:\n    update                          Update terraform modules and providers\n    select                          Select and initialize terraform workspace (aka \'stage\')\n    show                            Show current terraform workspace\n    plan                            Generate and show an execution plan\n    apply                           Builds or changes infrastructure\n    destroy                         Destroy Terraform-managed infrastructure\n    refresh                         Refresh terraform state\n    import                          Import existing infrastructure into your Terraform state\n\nNote:\n\n - parameter \'env\' is only required when selecting an environment\n - <TERRAFORM ARGUMENTS> can be used to pass arbitrary terraform parameters (without a prefix dash). Example: "make apply input=false no-color auto-approve"\n```\n\n> Use `tfmake azure help` to see the `azure` edition ...\n\n## Workspace Prefix\n\nWhen selecting an environment, by default, the following naming convention is used to store the `terraform` state:\n\n```\n<ACCOUNT_ALIAS>/<TERRAFORM_S3_KEY>\n```\n\nWhere:\n* `ACCOUNT_ALIAS` is the alias of the account you\'re using (either: AWS or Azure)\n* `TERRAFORM_S3_KEY` is the value of the `key` in `terraform.tf`\n\nIf you want something in-between the alias and the key, you can use the \'workspace prefix\' like this:\n> Only needed when using the `select` command!\n\n```\n$ aws-vault exec my-aws-account -- tfmake select env=dev --workspace-key-prefix foo/bar\n```\n\nAfter you `select`ed the environment, the path to your `terraform` state is:\n\n```\n<ACCOUNT_ALIAS>/<WORKSPACE_PREFIX>/<TERRAFORM_S3_KEY>\n```\n\nAssuming the `key` value is `whatever/terraform.tfstate`, this leads to: `my-aws-account/foo/bar/whatever/terraform.tfstate`\n\n\n## Safeguarding Credentials\n> This works for both `AWS` and `Azure`\n\nAlthough, you have to provide the correct credentials yourself, `tfmake` _will_ check if the credentials you provide are expected.\n\n```\n$ cd /path/to/my/tf/project\n$ aws-vault exec ACCOUNT_ONE -- tfmake select env=dev\nInitializing modules...\n...\n>>> Now using Terraform workspace \'dev\' on AWS account \'aws-account-one\' ...\n```\n\nIf you use different credentials the next time you use `tfmake` in this project, you\'ll see a warning. Press `<ENTER>` to abort (or `y` to continue).\n\n```\n$ cd /path/to/my/tf/project\n$ aws-vault exec ACCOUNT_TWO -- tfmake plan\n[WARNING] You previously used \'aws-account-one\' for provider aws. Now you\'re using \'aws-account-two\'. Are you sure? [y/N]:\nAborted!\n```\n\n> The \'magic\' behind all this is a cache stored in `$(PWD)/.tfmake/cache`. So, if you delete this file, this safeguard won\'t work anymore :(\n\n## Auto-switching Credentials on Azure\n\nWhen you\'re using `Azure` _and_ installed [`azctx`](https://github.com/StiviiK/azctx), `tfmake` will use the cached credentials to automatically switch to the correct subscription.\n\nIn your `.tfmake/config`, make sure you enabled `auto_switching`:\n```\n---\nprovider: azure\nauto_switch: True\n\nenvironment:\n  - ARM_ACCESS_KEY = $(az keyvault secret show --name YOUR_SECRET --vault-name YOUR_VAULT --query value -o tsv)\n```\n\n> Support for `AWS` will follow in a future version of `tfmake`\n\n## Final Notes\n\nBy default, before any a `terraform` command is executed, you will be asked to confirm the usage of the current environment.\n\n```\n$ tfmake azure apply\n\nUsing workspace \'prd\' on \'My_fancy_Azure_Production_subscription\'.\n\nPress [ENTER] to continue or [CTRL-C] to stop.\n```\n\nPlease notice that the prompt shows the selected `terraform` workspace and the alias/name of the provider account.\n\n> Use `TFMAKE_AGREE=1` to auto confirm that prompt ...\n\n## Example\n\n> Initialise \'dev\' environment\n```\n$ aws-vault exec foobar -- tfmake select env=dev\n```\n\n> Plan changes\n```\n$ aws-vault exec foobar -- tfmake plan\n```\n\n> Plan changes with plan file\n```\n$ aws-vault exec foobar -- tfmake plan out=foobar.plan\n```\n\n> Apply changes\n```\n$ aws-vault exec foobar -- tfmake apply\n```\n\n> Apply changes using plan file\n```\n$ aws-vault exec foobar -- tfmake apply input=false auto-approve foobar.plan\n```\n\n> Apply changes using the `azure` provider\n```\n$ az login\n# (optionaly set subscription)\n$ az account set --subscription=YOUR_SUBSCRIPTION_ID_HERE\n$ tfmake azure apply\n```\n\n> Apply changes ... automagically\n```\n$ aws-vault exec foobar -- tfmake apply input=false no-color auto-approve\'\n```\n\n**Note**: you can use arbitrary Terraform arguments after the command you\'re executing (~ in this example: `apply`). So, in this example, `input=false no-color auto-approve` will be used to create the following `terraform` arguments: `-input=false -no-color -auto-approve`.\n\nNotice that you have to skip the dash in front of each argument.\n\n**Another Note**: :arrow_up ... this only applies when using `tfmake` ... if, for whatever reason, you choose to use the `Makefile` directly: run `make help`\n\n## Advanced Usage\n\nYou can use a _per_ project configuration file in which you can specify, for example, environment variables and/or arbitrary commands that need to be execute before or after the `make` target.\n\n```\n$ tfmake init aws\n\nConfiguration written to \'/your/current/directory/.tfmake\'\n```\n\n```\n---\n#\n# Welcome to the wonderful world of TFMAKE!\n#\n# This file is the main config file for your tfmake project.\n# It\'s very minimal at this point and uses default values.\n# You can always add more config options for more control.\n#\n# Happy Coding!\n#\nprovider: aws\n\n# You can define service wide environment variables here\n# Notes:\n# - when using commands, dont use single quotes (sorry)\n# - commands should be between $( and )\n#\n# environment:\n#    - variable1 = value\n#    - variable2 = $(command)\n\n# You can define commands here that are executed _before_ the Make target\n# Note: dont use single quotes (sorry)\n#\n# before:\n#    - echo "[INFO] before"\n\n# You can define commands here that are executed _after_ the Make target\n# Note: dont use single quotes (sorry)\n#\n# after:\n#    - echo "[INFO] after"%\n```\n\n#### Section `provider`\nThe `provider` section specifies what (default) provider to use for this project. As a result, you don\'t have to specify it anymore on the command-line.\n\nSo, no more `tfmake azure plan`. Instead, just configure the `provider` property and type `tfmake plan`.\n\n#### Section `environment`\nThe `environment` section can contain a list of environment variables that need to be set before calling the `make` target. \n\nFor example, when using the `azure` provider, you might want to dynamically fetch the value for the `ARM_SAS_TOKEN` or `ARM_ACCESS_KEY` from an Azure Key Vault.\n\n#### Section `before`\n\nThe `before` section can contain a list of commands that need to be executed preparing the call to the `make` target.\n\n#### Section `after`\n\nThe `after` section can contain a list of commands that you can use to cleanup after calling the `make` target.\n\n### Example\n\n> Azure\n\nThe following example configuration creates an environment variable using a specified secret from a given key vault. Then, it will execute all `before` statements. Next it will just execute the `Makefile` target. And finally, it will execute all `after` statements.\n\nPlease note that the `environment` variables will _not_ be exposed system-wide. They will only be \'visible\' within the context of the session. As a result, `terraform` can use it, but when the process is done, the variable will no longer be available.\n\n```\n---\nprovider: azure\n\nenvironment:\n    - ARM_ACCESS_KEY = $(az keyvault secret show --name YOUR_SECRET --vault-name YOUR_VAULT --query value -o tsv)\n\nbefore:\n    - echo $ARM_ACCESS_KEY\n\nafter:\n    - echo "DONE!!"\n```\n\n~ the end\n',
    'author': 'Pascal Prins',
    'author_email': 'pascal.prins@foobar-it.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/paprins/tfmake',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*',
}


setup(**setup_kwargs)
