Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ Policyfile.lock.json
.vagrant/
.vagrant.d/
.kitchen/

# secrets for testing this Cookbook
test/fixtures/encrypted_data_bag_secret
test/fixtures/data_bags/
14 changes: 8 additions & 6 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
---
driver:
name: vagrant

provisioner:
name: chef_zero

platforms:
- name: centos-6.5
- name: centos-6.8
- name: centos-7.2
- name: ubuntu-14.04
- name: ubuntu-16.04

suites:
- name: add_test
data_bags_path: "test/integration/add_test/data_bags"
encrypted_data_bag_secret_key_path: "test/integration/add_test/encrypted_data_bag_secret"
data_bags_path: "test/fixtures/data_bags"
encrypted_data_bag_secret_key_path: "test/fixtures/encrypted_data_bag_secret"
run_list:
- recipe[fake::aws_mock]
- recipe[fake::add_test]
Expand All @@ -21,8 +23,8 @@ suites:
encrypted_data_bag: aws_security

- name: remove_test
data_bags_path: "test/integration/remove_test/data_bags"
encrypted_data_bag_secret_key_path: "test/integration/remove_test/encrypted_data_bag_secret"
data_bags_path: "test/fixtures/data_bags"
encrypted_data_bag_secret_key_path: "test/fixtures/encrypted_data_bag_secret"
run_list:
- recipe[fake::aws_mock]
- recipe[fake::add_test]
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@ This cookbook provides libraries, resource and providers to config and manage Am
- chefspec
- rspec_junit_formatter

# AWS Credentials

The default recipe will look for a encrypted data bag defined by node['aws_security']['encrypted_data_bag'] with the following keys

- aws_access_key_id
- aws_secret_access_key

E.G.

```json
{
"id": "aws",
"aws_access_key_id": "YOUR_ACCESS_KEY",
"aws_secret_access_key": "YOUR_SECRET_ACCESS_KEY"
}
```

# Recipes

## default
Expand Down Expand Up @@ -157,6 +140,23 @@ end
- Egress rules
- Apply security groups to instances, elbs, vpcs, etc

# AWS Credentials for testing

The default testing recipe will look for a encrypted data bag item aws_keys in the data bag defined by node['aws_security']['encrypted_data_bag'] with the following keys:

- aws_access_key_id
- aws_secret_access_key

E.G.

```json
{
"id": "aws_keys",
"aws_access_key_id": "YOUR_ACCESS_KEY",
"aws_secret_access_key": "YOUR_SECRET_ACCESS_KEY"
}
```

# License and Author

- Author:: Greg Hellings ([greg@thesub.net](mailto:greg@thesub.net))
Expand Down
3 changes: 1 addition & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
default['aws_security']['encrypted_data_bag'] = nil
default['aws_security']['aws_access_key_id'] = nil
default['aws_security']['aws_secret_access_key'] = nil
default['aws_security']['mocking'] = false
default['aws_security']['mocking'] = false
4 changes: 4 additions & 0 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ Strainerfile
###########
.vagrant
Vagrantfile

# secrets for testing this Cookbook
test/fixtures/encrypted_data_bag_secret
test/fixtures/data_bags/*
4 changes: 3 additions & 1 deletion libraries/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def ec2

def create_aws_interface
begin
require 'fog-aws'
require 'fog/aws'
rescue LoadError
chef_gem 'fog-aws' do
compile_time true if Chef::Resource::ChefGem.method_defined?(:compile_time)
action :install
end

require 'fog/aws'
end
options = { provider: 'AWS', region: @current_resource.region }

Expand Down
9 changes: 1 addition & 8 deletions test/fixtures/cookbooks/fake/recipes/add_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@
# limitations under the License.
#

include_recipe 'aws_security::default'

credentials = Chef::EncryptedDataBagItem.load(
node['aws_security']['encrypted_data_bag'],
'aws_keys'
)

credentials = Chef::EncryptedDataBagItem.load(
credentials = data_bag_item(
node['aws_security']['encrypted_data_bag'],
'aws_keys'
)
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/cookbooks/fake/recipes/remove_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# limitations under the License.
#

include_recipe 'aws_security::default'

credentials = Chef::EncryptedDataBagItem.load(
node['aws_security']['encrypted_data_bag'],
'aws_keys'
Expand Down
2 changes: 1 addition & 1 deletion test/integration/remove_test/serverspec/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem 'fog', '~> 1.24'
gem 'fog-aws', '~> 0.11'