aws_metadata 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23fc0654669922ff9d4131779dc09308d7491715
4
- data.tar.gz: 55fb15342c8d499a5e3d4ec94f2846a518a7e8d8
3
+ metadata.gz: f848656d02297d4237d2ee354bcfed769f35713a
4
+ data.tar.gz: d22372ceeba57b08c7414bc0585483f23760137a
5
5
  SHA512:
6
- metadata.gz: f0726ebb66175444ab5adf5d3153b313f11e95cdc7991b118f6d01c5808f99330f4c0d1cc8d97367d1875f741faec9f811f5b2522add5765d54693a30b7a4724
7
- data.tar.gz: 7b938f5c05bd5488f3fcc8b7eeab91e4ffa4f25973838fb827840eb25817c1d3d2e1be34e94cae75997658657c867d4cd00d7610480293614a2a38f3bbc858d3
6
+ metadata.gz: 0f93d679f0f092d1873f12a5065d424cc7d20ab92e83715dbedd9d79b3ccc4f59d3e6dada2338264acff9c0fd076e89204cd903dc15cc6569f209cc75340e498
7
+ data.tar.gz: cda4639dd418ed53ea0f90883424f634903dfd32cd3a3de3dff670658f6c8bf09beb0cbb558253c96aecf7cba3abedceab5d0de32ac12801aefe61ba05821271
data/README.md CHANGED
@@ -45,6 +45,27 @@ AWS::Metadata.stub_responses = Rails.env =~ /development|test/
45
45
  ```
46
46
 
47
47
  This will prevent HTTP calls to 169.254.169.254 and return canned results.
48
+
49
+ If you have `stub_responses` set to true, you can create a `aws_identity_stubs.yml` file with the data you want returned.
50
+ By default, the gem will look for `aws_identity_stubs.yml` in the `config` directory of a Rails app.
51
+ If you don't setup your own `aws_identity_stubs.yml`, then the gem will use it's own found in test/fixtures/aws_identity_stubs.yml. You can also use this file as a template for creating your own with custom data.
52
+ If you are not using this gem in a Rails app, then you need to specify the path in the initializer.
53
+
54
+ ```ruby
55
+ AWS::Metadata.configure do |config|
56
+ config.stub_responses = Rails.env =~ /development|test/
57
+ config.aws_identity_stubs_path = 'path/to/aws_identity_stubs.yml'
58
+ end
59
+ ```
60
+
61
+ or
62
+
63
+ ```ruby
64
+ AWS::Metadata.stub_responses = Rails.env =~ /development|test/
65
+ AWS::Metadata.aws_identity_stubs_path = 'path/to/aws_identity_stubs.yml'
66
+ AWS::StackOutput.get
67
+ ````
68
+
48
69
  When stubbing responses, both `AWS::Instance` and `AWS::StackOutput` will be stubbed.
49
70
 
50
71
  ## Usage for `AWS::StackOutput`
@@ -89,7 +89,8 @@ module AWS
89
89
  # Helper method to provide "stubs" for non aws deployments
90
90
  # @private
91
91
  def load_stubs
92
- responses = YAML.load_file(File.expand_path(File.dirname(__FILE__) + '/../../test/fixtures/responses.yml'))
92
+ yaml = Pathname.new(File.join(AWS::Metadata.aws_identity_stubs_path, 'aws_identity_stubs.yml'))
93
+ responses = YAML.load(ERB.new(yaml.read).result)
93
94
  @metadata = Hashish.new responses[:metadata]
94
95
  @user_data = responses[:user_data]
95
96
  @dynamic = Hashish.new responses[:dynamic]
@@ -1,5 +1,5 @@
1
1
  module AWS
2
2
  module Metadata
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/lib/aws_metadata.rb CHANGED
@@ -52,11 +52,28 @@ module AWS
52
52
  @stack_name
53
53
  end
54
54
 
55
+ # Set the path to the aws_identity_stubs.yml
56
+ #
57
+ # Only needs to be set if {.stub_responses} is set to true.
58
+ #
59
+ # @return [String]
60
+ def self.aws_identity_stubs_path=(aws_identity_stubs_path)
61
+ @aws_identity_stubs_path = aws_identity_stubs_path
62
+ end
63
+
64
+ # Set the path to the aws_identity_stubs.yml
65
+ #
66
+ # Defaults to the config directory in a Rails application, or the file in tests/fixtures/aws_identity_stubs.yml if not in a Rails app.
67
+ #
68
+ # @return [String]
69
+ def self.aws_identity_stubs_path
70
+ @aws_identity_stubs_path ||= defined?(Rails) ? Rails.root.join('config') : File.expand_path(File.dirname(__FILE__) + '/../test/fixtures')
71
+ end
72
+
55
73
  # Set the path to the cfn_dev_output.yml file with the keys you have defined as Outputs for your Cloud Formation stack.
56
74
  #
57
75
  # Only needs to be set if {.stub_responses} is set to true.
58
76
  #
59
- # @param stack_name
60
77
  # @return [String]
61
78
  def self.cfn_dev_outputs_path=(dev_outputs_path)
62
79
  @dev_outputs_path = dev_outputs_path
@@ -66,7 +83,6 @@ module AWS
66
83
  #
67
84
  # Defaults to the config directory in a Rails application.
68
85
  #
69
- # @param stack_name
70
86
  # @return [String]
71
87
  def self.cfn_dev_outputs_path
72
88
  @dev_outputs_path ||= defined?(Rails) ? Rails.root.join('config') : ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evident.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-29 00:00:00.000000000 Z
11
+ date: 2016-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,7 +108,7 @@ files:
108
108
  - lib/aws_metadata/instance_metadata.rb
109
109
  - lib/aws_metadata/version.rb
110
110
  - lib/extensions/string.rb
111
- - test/fixtures/responses.yml
111
+ - test/fixtures/aws_identity_stubs.yml
112
112
  homepage: https://github.com/EvidentSecurity/aws_metadata
113
113
  licenses: []
114
114
  metadata: {}
@@ -133,4 +133,4 @@ signing_key:
133
133
  specification_version: 4
134
134
  summary: Gem to provide the Instance Metadata and Cloud Formation template outputs.
135
135
  test_files:
136
- - test/fixtures/responses.yml
136
+ - test/fixtures/aws_identity_stubs.yml