From ff4586358cbed480adf87bdef644b1d01f70518d Mon Sep 17 00:00:00 2001 From: Nick Huanca Date: Tue, 23 Oct 2018 11:03:51 -0600 Subject: [PATCH 1/3] Changes Breaking changes: - Changed contract with module to not require provider details - Removed provider configuration Intent: The provider details should be inherited through newer mechanisms in Terraform. The newer versions of terraform can support inferred context for where to make the changes in the module instance. This should be leveraged instead of loading in the credentials for AWS. --- aws-vpc.tf | 19 ------------------- variables.tf | 2 -- 2 files changed, 21 deletions(-) delete mode 100644 aws-vpc.tf diff --git a/aws-vpc.tf b/aws-vpc.tf deleted file mode 100644 index ad9426d..0000000 --- a/aws-vpc.tf +++ /dev/null @@ -1,19 +0,0 @@ -#Copyright 2017 Reactive Ops Inc. -# -#Licensed under the Apache License, Version 2.0 (the “License”); -#you may not use this file except in compliance with the License. -#You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an “AS IS” BASIS, -#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -#See the License for the specific language governing permissions and -#limitations under the License. - -provider "aws" { - access_key = "${var.aws_access_key}" - secret_key = "${var.aws_secret_key}" - region = "${var.aws_region}" -} diff --git a/variables.tf b/variables.tf index 8ecaa50..1045db8 100644 --- a/variables.tf +++ b/variables.tf @@ -12,8 +12,6 @@ #See the License for the specific language governing permissions and #limitations under the License. -variable "aws_access_key" {} -variable "aws_secret_key" {} variable "aws_region" {} variable "aws_vpc_name" { From 842cae0193bd49b5f9a4aa13d48d18cb04e3fdcc Mon Sep 17 00:00:00 2001 From: Nick Huanca Date: Tue, 23 Oct 2018 11:16:06 -0600 Subject: [PATCH 2/3] Adjusted documentation --- README.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 0af12f6..4e47325 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ This module has been tested with Terraform version 0.11.8 module "vpc" { source = "git::ssh://git@github.com/reactiveops/terraform-vpc.git?ref=2.0.2" - aws_access_key = "${var.aws_access_key}" - aws_secret_key = "${var.aws_secret_key}" aws_region = "${var.aws_region}" az_count = "${var.az_count}" @@ -31,8 +29,6 @@ module "vpc" { * Create the required variables either in `main.tf` or a separate `variables.tf` file: ``` -variable "aws_access_key" {} -variable "aws_secret_key" {} variable "aws_region" {} variable "aws_azs" {} @@ -155,12 +151,7 @@ This repo contains a few `.tfvars.example` files in the root illustrating differ ### Setup -Running `make test` requires an actual AWS account for plan generation. The AWS account used requires read-only access to VPC/EC2 resources. No changes are applied. Credentials can be set via environment variables. - -``` -export TF_VAR_aws_access_key=XXXXXXXXXXXXXXXXX -export TF_VAR_aws_secret_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXX -``` +Running `make test` requires an actual AWS account for plan generation. The AWS account used requires read-only access to VPC/EC2 resources. No changes are applied. Credentials should be inferred from your awscli config, usually found in `~/.aws/config`. ### Executing tests From ddfb5ad250e2dc336afd5f4d95a43c3a3960328a Mon Sep 17 00:00:00 2001 From: Nick Huanca Date: Tue, 23 Oct 2018 13:12:30 -0600 Subject: [PATCH 3/3] Adjusted testing --- Makefile | 1 + tests/provider.tf | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 tests/provider.tf diff --git a/Makefile b/Makefile index 5072d87..3cdc17d 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ requirements: bin/terraform ## Install required software test: requirements ## Execute all tests @echo "Temp directory: $(TEMPDIR)" + @cp tests/provider.tf temp_provider.tf @bin/terraform init > /dev/null 2>&1 @for i in `find . -name terraform.\*.tfvars.example`; do \ bin/terraform plan -var-file $$i 1> $(TEMPDIR)/$$i.output && \ diff --git a/tests/provider.tf b/tests/provider.tf new file mode 100644 index 0000000..6cdfee7 --- /dev/null +++ b/tests/provider.tf @@ -0,0 +1,8 @@ +variable "aws_access_key" {} +variable "aws_secret_key" {} + +provider "aws" { + access_key = "${var.aws_access_key}" + secret_key = "${var.aws_secret_key}" + region = "${var.aws_region}" +}