From 9bbb43946795f5541c361b14cc18380571185e6f Mon Sep 17 00:00:00 2001 From: Jerry Aldrich III Date: Tue, 10 Oct 2017 19:20:25 -0500 Subject: [PATCH] Add support for `ENV['AWS_REGION']` (#92) The `aws-sdk` will raise an error mentioning `ENV['AWS_REGION']` if you omit `ENV['AWS_DEFAULT_REGION']`. This adds support for either via `||`. Signed-off-by: Jerry Aldrich --- README.md | 4 ++-- libraries/aws_conn.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bda06a79b..b2b4d73a5 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ As of now, AWS resources are implemented as an InSpec resource pack. It will shi To run the profile, use InSpec with an environment variable for AWS credentials: -- `AWS_DEFAULT_REGION` +- `AWS_REGION` - `AWS_ACCESS_KEY_ID` - `AWS_SECRET_ACCESS_KEY` @@ -92,7 +92,7 @@ bundle exec rake test ### Integration tests To run the integration tests, please make sure all required environment variables like `AWS_ACCESS_KEY_ID` -, `AWS_SECRET_ACCESS_KEY` and `AWS_DEFAULT_REGION` are set properly. (`AWS_DEFAULT_REGION` **must** be set to **us-east-1** when running the integration tests.) We use terraform to create the AWS setup and InSpec to verify the all aspects. If you want to use a specific terraform environment, set environment variable `INSPEC_TERRAFORM_ENV`. Integration tests can be executed via: +, `AWS_SECRET_ACCESS_KEY` and `AWS_REGION` are set properly. (`AWS_REGION` **must** be set to **us-east-1** when running the integration tests.) We use terraform to create the AWS setup and InSpec to verify the all aspects. If you want to use a specific terraform environment, set environment variable `INSPEC_TERRAFORM_ENV`. Integration tests can be executed via: ``` bundle exec rake test:integration diff --git a/libraries/aws_conn.rb b/libraries/aws_conn.rb index cc583689b..9e6d74466 100644 --- a/libraries/aws_conn.rb +++ b/libraries/aws_conn.rb @@ -4,7 +4,7 @@ class AWSConnection def initialize require 'aws-sdk' opts = { - region: ENV['AWS_DEFAULT_REGION'], + region: ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION'], credentials: Aws::Credentials.new( ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'],