vrt-ec2-tags 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 27702ee645463df7181c266d3ae8babd5f123a6da2c3c21b0ef4ab939d1650d4
4
+ data.tar.gz: 17929edc5a708addaadb8a1cb6bdbb11462a642f75bfe975c18a531681d1dcd9
5
+ SHA512:
6
+ metadata.gz: 945ab937edf04515b2921a0309d6e9da7c19bde25bd68c3b6a9ef8ab58f59d3c9f1deef1c571c197e7f6c133931a8c8e26d98774867746c17c88b3b8070d8757
7
+ data.tar.gz: 31efd9083ca6499ee09f889f1e6170d17091d7fd85a798317b0baf5a33c552016e9b7bdfb065d40d1e76d2a387e20a8d07c5f3d4ef24431e8ad1b1e75e326320
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ /vendor
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ AllCops:
3
+ TargetRubyVersion: 2.5
4
+
5
+ Metrics/LineLength:
6
+ Max: 140
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in vrt-ec2-tags.gemspec
8
+ gemspec
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vrt-ec2-tags (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ awesome_print (1.8.0)
11
+ diff-lcs (1.3)
12
+ parallel (1.12.1)
13
+ parser (2.5.3.0)
14
+ ast (~> 2.4.0)
15
+ powerpack (0.1.2)
16
+ rainbow (3.0.0)
17
+ rake (10.5.0)
18
+ rspec (3.8.0)
19
+ rspec-core (~> 3.8.0)
20
+ rspec-expectations (~> 3.8.0)
21
+ rspec-mocks (~> 3.8.0)
22
+ rspec-core (3.8.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-expectations (3.8.2)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-mocks (3.8.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-support (3.8.0)
31
+ rubocop (0.52.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.4.0.2, < 3.0)
34
+ powerpack (~> 0.1)
35
+ rainbow (>= 2.2.2, < 4.0)
36
+ ruby-progressbar (~> 1.7)
37
+ unicode-display_width (~> 1.0, >= 1.0.1)
38
+ ruby-progressbar (1.10.0)
39
+ unicode-display_width (1.4.0)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ awesome_print
46
+ bundler (~> 1.16)
47
+ rake (~> 10.0)
48
+ rspec (~> 3.0)
49
+ rubocop (~> 0.52.0)
50
+ vrt-ec2-tags!
51
+
52
+ BUNDLED WITH
53
+ 1.16.1
@@ -0,0 +1,35 @@
1
+ # Vrt::Ec2::Tags
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/vrt/ec2/tags`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'vrt-ec2-tags'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install vrt-ec2-tags
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vrt-ec2-tags.
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.formatters = %w[fuubar offenses]
11
+ task.fail_on_error = true
12
+ end
13
+
14
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'vrt/ec2/tags'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require 'pry'
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'vrt/ec2/tags'
5
+
6
+ Vrt::Ec2::Tags.tags
7
+
8
+ # vi:set fileencoding=utf8 fileformat=unix filetype=ruby tabstop=2 expandtab:
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'vrt/ec2/tags/version'
7
+
8
+ module Vrt
9
+ module Ec2
10
+ # This module will fetch the EC2 tags for this instance via custom lambda.
11
+ module Tags
12
+ def self.tags
13
+ yamlstring = read_tags
14
+ puts yamlstring if yamlstring
15
+ rescue StandardError => e
16
+ warn "Something failed.... Abort! : #{e.class} - #{e.message}"
17
+ end
18
+
19
+ def self.meta_data_uri
20
+ @meta_data_uri || @meta_data_uri = URI.parse('http://169.254.169.254')
21
+ end
22
+
23
+ def self.tag_uri
24
+ @tag_uri || @tag_uri = URI.parse('https://puppetapi.core.a51.be/tags')
25
+ end
26
+
27
+ def self.read_tags
28
+ http = Net::HTTP.new(tag_uri.host, tag_uri.port)
29
+ http.use_ssl = true
30
+ http.open_timeout = 2
31
+ http.read_timeout = 4
32
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
33
+ request = Net::HTTP::Post.new(tag_uri)
34
+ request.add_field 'Content-Type', 'text/plain; charset=utf-8'
35
+ request.body = instance_id
36
+ response = http.request(request)
37
+ response.body if response.is_a? Net::HTTPSuccess
38
+ end
39
+
40
+ def self.instance_id
41
+ id = read_instance_id
42
+ raise('Something bad happened since there was no error but this is not a string.') unless id.is_a? String
43
+
44
+ id
45
+ rescue StandardError
46
+ warn 'This is not an AWS EC2 instance or unable to contact the AWS instance-data web server.'
47
+ end
48
+
49
+ def self.read_instance_id
50
+ http = Net::HTTP.new(meta_data_uri.host, meta_data_uri.port)
51
+ http.open_timeout = 2
52
+ http.read_timeout = 4
53
+ request = Net::HTTP::Get.new('/latest/dynamic/instance-identity/rsa2048')
54
+ http.request(request).body
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ # vi:set fileencoding=utf8 fileformat=unix filetype=ruby tabstop=2 expandtab:
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vrt
4
+ module Ec2
5
+ module Tags
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'vrt/ec2/tags/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'vrt-ec2-tags'
9
+ spec.version = Vrt::Ec2::Tags::VERSION
10
+ spec.authors = ['Stefan - Zipkid - Goethals']
11
+ spec.email = ['stefan.goehals@vrt.be']
12
+
13
+ spec.summary = 'Fetch EC2 tags for the requesting host only via Lambda'
14
+ spec.description = 'Fetch EC2 tags for the requesting host only via Lambda'
15
+ spec.homepage = 'https://github.com/vrtdev/vrt-ec2-tags'
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
20
+
21
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features)/})
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency 'awesome_print'
31
+ spec.add_development_dependency 'bundler', '~> 1.16'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'rubocop', '~> 0.52.0'
35
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vrt-ec2-tags
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stefan - Zipkid - Goethals
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.52.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.52.0
83
+ description: Fetch EC2 tags for the requesting host only via Lambda
84
+ email:
85
+ - stefan.goehals@vrt.be
86
+ executables:
87
+ - vrt-ec2-tags
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".rubocop.yml"
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - exe/vrt-ec2-tags
101
+ - lib/vrt/ec2/tags.rb
102
+ - lib/vrt/ec2/tags/version.rb
103
+ - vrt-ec2-tags.gemspec
104
+ homepage: https://github.com/vrtdev/vrt-ec2-tags
105
+ licenses: []
106
+ metadata:
107
+ allowed_push_host: https://rubygems.org/
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.7.6
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Fetch EC2 tags for the requesting host only via Lambda
128
+ test_files: []