diff --git a/.gitignore b/.gitignore index dc9b11d..1cf9d6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.venv *.sw* *.pyc *.zip @@ -5,4 +6,4 @@ *.terraform* *tfstate* *tfvars - +.coverage diff --git a/requirements.txt b/requirements.txt index 9b60a9d..0e5d48f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile requirements.in diff --git a/requirements_dev.txt b/requirements_dev.txt index fd69a2e..0e13f2c 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile --output-file=requirements_dev.txt requirements_dev.in @@ -16,14 +16,14 @@ aws-xray-sdk==2.6.0 # via moto black==20.8b1 # via -r requirements_dev.in -boto3==1.16.59 +boto==2.49.0 + # via moto +boto3==1.24.66 # via # -r requirements_dev.in # aws-sam-translator # moto -boto==2.49.0 - # via moto -botocore==1.19.59 +botocore==1.27.66 # via # aws-xray-sdk # boto3 @@ -117,12 +117,12 @@ pyparsing==2.4.7 # via packaging pyrsistent==0.17.3 # via jsonschema -pytest-cov==2.11.1 - # via -r requirements_dev.in pytest==6.2.1 # via # -r requirements_dev.in # pytest-cov +pytest-cov==2.11.1 + # via -r requirements_dev.in python-dateutil==2.8.1 # via # botocore @@ -146,7 +146,7 @@ responses==0.12.1 # via moto rsa==4.7 # via python-jose -s3transfer==0.3.4 +s3transfer==0.6.0 # via boto3 six==1.15.0 # via diff --git a/script/bootstrap b/script/bootstrap index db450d9..adba8a4 100644 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,23 +1,22 @@ if [ "$CI" -eq 1 ]; then - { - python -m pip install -U pip pip-tools && - pip install -r requirements_dev.txt - } -else - VENV=lambda-boilerplate.venv - - ################################################################# - # Bootstrapping sets up the Python 3.8 venv that allows the use # - # of the invoke commands. # - ################################################################# - - { - pyenv virtualenv-delete -f $VENV - pyenv virtualenv $VENV && - pyenv activate $VENV && - python -m pip install -U pip pip-tools && - pip install -r requirements_dev.txt && - echo "✨ Good to go! ✨" + { + python -m pip install -U pip pip-tools && + pip install -r requirements_dev.txt } +else + VENV=lambda-boilerplate.venv + + ################################################################# + # Bootstrapping sets up the Python 3.8 venv that allows the use # + # of the invoke commands. # + ################################################################# + + test -d $VENV || python3 -m venv $VENV || return + . $VENV/bin/activate + + python -m pip install -U pip pip-tools --no-cache-dir + python -m pip install -r requirements.txt + python -m pip install -r requirements_dev.txt + echo "✨ Good to go! ✨" fi diff --git a/tasks.py b/tasks.py index 2b390af..8668706 100644 --- a/tasks.py +++ b/tasks.py @@ -44,6 +44,7 @@ def cloud_plan(ctx, project): Builds the Terraform plan for the given project. """ with ctx.cd(PROJECT_PATHS[project]): + ctx.run("terraform init") ctx.run(f"terraform plan --var-file {VARIABLES_PATH}") @@ -53,6 +54,7 @@ def cloud_apply(ctx, project): Applies infrastructure changes to the given project. """ with ctx.cd(PROJECT_PATHS[project]): + ctx.run("terraform init") ctx.run("terraform taint --allow-missing aws_lambda_function.apgnd_lambda_func") ctx.run("terraform taint --allow-missing aws_lambda_permission.apigw") ctx.run(f"terraform apply --var-file {VARIABLES_PATH}") @@ -64,6 +66,7 @@ def cloud_destroy(ctx, project): Destroys resources associated with the given project. """ with ctx.cd(PROJECT_PATHS[project]): + ctx.run("terraform init") ctx.run(f"terraform destroy --var-file {VARIABLES_PATH}") @@ -90,8 +93,9 @@ def cloud_push(ctx, archive): with ctx.cd(_compose_path(PROJECT_PATHS["bootstrap"])): out = ctx.run("terraform output", hide="out").stdout artifacts_bucket_match = re.match( - "artifacts_bucket_name = (?P[0-9a-zA-Z\-]+)\n", out + 'artifacts_bucket_name = "(?P[0-9a-zA-Z-_]+)"\n?', out ) + artifacts_bucket = artifacts_bucket_match.group("bucket_name") with ctx.cd(BASE_PATH):