stax-examples 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 692c98abc649e25a20f6be4f37c28a464552d932db25d58c1fce0cc259b09761
4
+ data.tar.gz: 7145033511f003e461a47d5caec0df043343c969043ebfb93be549a1fd737f9e
5
+ SHA512:
6
+ metadata.gz: 46986e985a848028f4183444cd5beaf52eb0634643aa8b19aa8132f8600ccd2231dde4b8f059983f5922c199c6d7810a273d97f285d46830b1e9e4872d50ed8e
7
+ data.tar.gz: 1bc371daecfa958581eda7dd5c92edda3ca06052eb834a2f660a5d27be122eefef29031c636b70ada7b3ea0c11d7d5ae2edfdec09107c69fe44e88c4aa85586c
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rlister@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in stax-examples.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ stax-examples (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (5.2.0)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ addressable (2.5.2)
15
+ public_suffix (>= 2.0.2, < 4.0)
16
+ aws-sdk (2.11.62)
17
+ aws-sdk-resources (= 2.11.62)
18
+ aws-sdk-core (2.11.62)
19
+ aws-sigv4 (~> 1.0)
20
+ jmespath (~> 1.0)
21
+ aws-sdk-resources (2.11.62)
22
+ aws-sdk-core (= 2.11.62)
23
+ aws-sigv4 (1.0.2)
24
+ cfer (0.6.0)
25
+ activesupport (>= 3)
26
+ aws-sdk (~> 2.2)
27
+ aws-sdk-resources (~> 2.2)
28
+ cri (~> 2.7)
29
+ docile (~> 1.1)
30
+ git (~> 1.3)
31
+ highline (~> 1.7)
32
+ preconditions (~> 0.3.0)
33
+ rainbow (~> 2.1)
34
+ semantic (~> 1.4)
35
+ table_print (~> 1.5)
36
+ colored (1.2)
37
+ concurrent-ruby (1.0.5)
38
+ cri (2.10.1)
39
+ colored (~> 1.2)
40
+ docile (1.2.0)
41
+ faraday (0.15.2)
42
+ multipart-post (>= 1.2, < 3)
43
+ git (1.4.0)
44
+ git_clone_url (2.0.0)
45
+ uri-ssh_git (>= 2.0)
46
+ highline (1.7.10)
47
+ i18n (1.0.1)
48
+ concurrent-ruby (~> 1.0)
49
+ jmespath (1.4.0)
50
+ minitest (5.11.3)
51
+ multipart-post (2.0.0)
52
+ octokit (4.9.0)
53
+ sawyer (~> 0.8.0, >= 0.5.3)
54
+ preconditions (0.3.0)
55
+ public_suffix (3.0.2)
56
+ rainbow (2.2.2)
57
+ rake
58
+ rake (10.5.0)
59
+ sawyer (0.8.1)
60
+ addressable (>= 2.3.5, < 2.6)
61
+ faraday (~> 0.8, < 1.0)
62
+ semantic (1.6.1)
63
+ stax (0.0.6)
64
+ aws-sdk (~> 2)
65
+ cfer
66
+ git_clone_url
67
+ octokit
68
+ thor
69
+ table_print (1.5.6)
70
+ thor (0.20.0)
71
+ thread_safe (0.3.6)
72
+ tzinfo (1.2.5)
73
+ thread_safe (~> 0.1)
74
+ uri-ssh_git (2.0.0)
75
+
76
+ PLATFORMS
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ bundler (~> 1.16)
81
+ docile (= 1.2.0)
82
+ rake (~> 10.0)
83
+ stax (>= 0.0.6)
84
+ stax-examples!
85
+
86
+ BUNDLED WITH
87
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Richard Lister
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # Stax Examples
2
+
3
+ This project is a bunch of generators for
4
+ [stax](https://github.com/rlister/stax), to demonstrate the creation
5
+ of stacks and/or individual resources for Cloudformation using `stax`.
6
+
7
+ Currently, generators all use the
8
+ [cfer](https://github.com/seanedwards/cfer) wrapper to generate
9
+ templates from ruby code. We may add json and/or yaml template
10
+ examples later.
11
+
12
+ These templates are all just an expression of the author's ideas about
13
+ Cloudformation architecture and style. Stacks and highly de-coupled
14
+ and orthogonal, and use Outputs/Exports and Imports very heavily to
15
+ wire related stacks up to each other.
16
+
17
+ You are encouraged to use these merely as a starting-point for
18
+ boilerplate, and then modify to your needs. Even better, fork and
19
+ create generators embodying your opinions instead.
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'stax-examples'
27
+ ```
28
+
29
+ or use `HEAD` with:
30
+
31
+ ```ruby
32
+ gem 'stax-examples', git: 'https://github.com/rlister/stax-examples'
33
+ ```
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install stax-examples
42
+
43
+ ## Usage
44
+
45
+ `require` the gem wherever you put such things, such as your
46
+ `Staxfile`:
47
+
48
+ ```ruby
49
+ require 'stax/examples'
50
+ ```
51
+
52
+ You should now see your new generators listed:
53
+
54
+ ```sh
55
+ $ bundle exec stax g
56
+
57
+ ```
58
+
59
+ Use a generator by name to create your new boilerplate in `lib/` and
60
+ `cf/`, e.g.:
61
+
62
+ ```sh
63
+ $ bundle exec stax g vpc
64
+ cidr block for vpc? (10.0.0.0/16)
65
+ number of subnets to create? (3)
66
+ create cf
67
+ create cf/vpc.rb
68
+ create cf/vpc/endpoints.rb
69
+ create cf/vpc/subnets.rb
70
+ create cf/vpc/vpc.rb
71
+ append Staxfile
72
+ ```
73
+
74
+ As seen above, most generators will query interactively for any
75
+ decisions they would like you to make.
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at
80
+ https://github.com/rlister/stax-examples. This project is intended
81
+ to be a safe, welcoming space for collaboration, and contributors are
82
+ expected to adhere to the [Contributor
83
+ Covenant](http://contributor-covenant.org) code of conduct.
84
+
85
+ ## License
86
+
87
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+
89
+ ## Code of Conduct
90
+
91
+ Everyone interacting in the Stax::Examples project’s codebases, issue
92
+ trackers, chat rooms and mailing lists is expected to follow the [code of
93
+ conduct](https://github.com/rlister/stax-examples/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/Staxfile ADDED
@@ -0,0 +1,2 @@
1
+ # require_relative 'lib/stax/examples'
2
+ stack :vpc
@@ -0,0 +1,11 @@
1
+ resource :vpcedyn, 'AWS::EC2::VPCEndpoint', DependsOn: [:vpc, :routetable] do
2
+ vpc_id Fn::ref(:vpc)
3
+ route_table_ids [Fn::ref(:routetable)]
4
+ service_name Fn::sub('com.amazonaws.${AWS::Region}.dynamodb')
5
+ end
6
+
7
+ resource :vpces3, 'AWS::EC2::VPCEndpoint', DependsOn: [:vpc, :routetable] do
8
+ vpc_id Fn::ref(:vpc)
9
+ route_table_ids [Fn::ref(:routetable)]
10
+ service_name Fn::sub('com.amazonaws.${AWS::Region}.s3')
11
+ end
@@ -0,0 +1,20 @@
1
+ subnets = <%= subnets.to_i %>.times.map do |i|
2
+ "subnet#{i}".tap do |subnet|
3
+
4
+ resource subnet, 'AWS::EC2::Subnet', DependsOn: :vpc do
5
+ vpc_id Fn::ref(:vpc)
6
+ availability_zone Fn::select(i, Fn::get_azs)
7
+ cidr_block Fn::select(i, Fn::cidr(Fn::get_att(:vpc, :CidrBlock), 256, 8))
8
+ map_public_ip_on_launch true
9
+ tag :Name, Fn::ref('AWS::StackName')
10
+ end
11
+
12
+ resource "rt#{subnet}", 'AWS::EC2::SubnetRouteTableAssociation', DependsOn: subnet do
13
+ subnet_id Fn::ref(subnet)
14
+ route_table_id Fn::ref(:routetable)
15
+ end
16
+
17
+ end
18
+ end
19
+
20
+ output :SubnetIds, Fn::join(',', subnets.map(&Fn.method(:ref))), export: Fn::sub('${AWS::StackName}-SubnetIds')
@@ -0,0 +1,33 @@
1
+ resource :vpc, 'AWS::EC2::VPC' do
2
+ cidr_block '<%= cidr_block %>'
3
+ enable_dns_support true
4
+ enable_dns_hostnames true
5
+ instance_tenancy :default
6
+ tag :Name, Fn::ref('AWS::StackName')
7
+ end
8
+
9
+ ## allow internet access for instances in vpc
10
+ resource :igw, 'AWS::EC2::InternetGateway' do
11
+ tag :Name, Fn::ref('AWS::StackName')
12
+ end
13
+
14
+ ## attach gateway to vpc
15
+ resource :igwattach, 'AWS::EC2::VPCGatewayAttachment', DependsOn: [:vpc, :igw] do
16
+ vpc_id Fn::ref(:vpc)
17
+ internet_gateway_id Fn::ref(:igw)
18
+ end
19
+
20
+ ## routing table for vpc
21
+ resource :routetable, 'AWS::EC2::RouteTable', DependsOn: [:vpc] do
22
+ vpc_id Fn::ref(:vpc)
23
+ tag :Name, Fn::ref('AWS::StackName')
24
+ end
25
+
26
+ ## default route for outgoing packets
27
+ resource :route, 'AWS::EC2::Route', DependsOn: [:routetable, :igw] do
28
+ route_table_id Fn::ref(:routetable)
29
+ gateway_id Fn::ref(:igw)
30
+ destination_cidr_block '0.0.0.0/0'
31
+ end
32
+
33
+ output :VpcId, Fn::ref(:vpc), export: Fn::sub('${AWS::StackName}-VpcId')
@@ -0,0 +1,7 @@
1
+ description 'vpc stack'
2
+
3
+ include_template(
4
+ '<%= stack_name %>/vpc.rb',
5
+ '<%= stack_name %>/subnets.rb',
6
+ '<%= stack_name %>/endpoints.rb',
7
+ )
@@ -0,0 +1,29 @@
1
+ module Stax
2
+ module Examples
3
+ class VpcGenerator < Stax::Generators::Base
4
+ desc 'Create a new stack with VPC and networking.'
5
+
6
+ class_option :stack, type: :string, default: 'vpc', desc: 'name of stack to create'
7
+ attr_accessor :cidr_block, :subnets
8
+
9
+ source_root File.expand_path('templates', __dir__)
10
+
11
+ def create_vpc_files
12
+ @cidr_block = ask('cidr block for vpc?', default: '10.0.0.0/16')
13
+ @subnets = ask('number of subnets to create?', default: '3')
14
+ directory '.', 'cf'
15
+ end
16
+
17
+ def add_to_staxfile
18
+ append_to_file 'Staxfile', "stack :#{options[:stack]}"
19
+ end
20
+
21
+ private
22
+
23
+ def stack_name
24
+ options[:stack]
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module Stax
2
+ module Examples
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'stax/examples/version'
2
+
3
+ ## auto require generators
4
+ Dir[File.join(__dir__, '..', 'generators', '**', '*_generator.rb')].map(&method(:require))
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stax-examples
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Lister
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: stax
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.6
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: docile
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ description: Stax example stacks and generators for cloudformation templates.
70
+ email:
71
+ - rlister@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - CODE_OF_CONDUCT.md
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - Staxfile
83
+ - lib/generators/vpc/templates/%stack_name%.rb.tt
84
+ - lib/generators/vpc/templates/%stack_name%/endpoints.rb
85
+ - lib/generators/vpc/templates/%stack_name%/subnets.rb.tt
86
+ - lib/generators/vpc/templates/%stack_name%/vpc.rb.tt
87
+ - lib/generators/vpc/vpc_generator.rb
88
+ - lib/stax/examples.rb
89
+ - lib/stax/examples/version.rb
90
+ homepage: https://github.com/rlister/stax-examples
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.7.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Stax example generators.
114
+ test_files: []