etude_for_aws 0.7.4

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.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +103 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +10 -0
  6. data/Dockerfile +17 -0
  7. data/Dockerfile-dev +20 -0
  8. data/Gemfile +6 -0
  9. data/Gemfile.lock +89 -0
  10. data/Guardfile +22 -0
  11. data/Jenkinsfile +11 -0
  12. data/README.md +26 -0
  13. data/Rakefile +12 -0
  14. data/Vagrantfile +15 -0
  15. data/bin/aws_console.rb +10 -0
  16. data/bin/console +14 -0
  17. data/bin/setup +8 -0
  18. data/circle.yml +22 -0
  19. data/config.yml +124 -0
  20. data/docker-compose.yml +9 -0
  21. data/docs/README.md +54 -0
  22. data/docs/_config.yml +6 -0
  23. data/docs/dev/cfm/cfm.md +9 -0
  24. data/docs/dev/cfm/images/vpc_core_model.png +0 -0
  25. data/docs/dev/cfm/images/vpc_type1.png +0 -0
  26. data/docs/dev/cfm/images/vpc_type2.png +0 -0
  27. data/docs/dev/cfm/images/vpc_type3.png +0 -0
  28. data/docs/dev/cfm/images/vpc_type4.png +0 -0
  29. data/docs/dev/cfm/images/vpc_type5.png +0 -0
  30. data/docs/dev/cfm/images/vpc_type6.png +0 -0
  31. data/docs/dev/cfm/images/vpc_type7.png +0 -0
  32. data/docs/dev/cfm/vpc/core_model.puml +35 -0
  33. data/docs/dev/cfm/vpc/vpc.md +39 -0
  34. data/docs/dev/cfm/vpc/vpc_type1.puml +17 -0
  35. data/docs/dev/cfm/vpc/vpc_type2.puml +23 -0
  36. data/docs/dev/cfm/vpc/vpc_type3.puml +24 -0
  37. data/docs/dev/cfm/vpc/vpc_type4.puml +23 -0
  38. data/docs/dev/cfm/vpc/vpc_type5.puml +25 -0
  39. data/docs/dev/cfm/vpc/vpc_type6.puml +26 -0
  40. data/docs/dev/cfm/vpc/vpc_type7.puml +39 -0
  41. data/docs/dev/ec2/core_model.puml +43 -0
  42. data/docs/dev/ec2/ec2.md +36 -0
  43. data/docs/dev/ec2/ec2_type1.puml +27 -0
  44. data/docs/dev/ec2/ec2_type2.puml +43 -0
  45. data/docs/dev/ec2/ec2_type3.puml +44 -0
  46. data/docs/dev/ec2/ec2_type4.puml +43 -0
  47. data/docs/dev/ec2/ec2_type5.puml +45 -0
  48. data/docs/dev/ec2/ec2_type6.puml +46 -0
  49. data/docs/dev/ec2/ec2_type7.puml +79 -0
  50. data/docs/dev/ec2/images/.keep +0 -0
  51. data/docs/dev/ec2/images/ec2_core_model.png +0 -0
  52. data/docs/dev/ec2/images/ec2_type1.png +0 -0
  53. data/docs/dev/ec2/images/ec2_type2.png +0 -0
  54. data/docs/dev/ec2/images/ec2_type3.png +0 -0
  55. data/docs/dev/ec2/images/ec2_type4.png +0 -0
  56. data/docs/dev/ec2/images/ec2_type5.png +0 -0
  57. data/docs/dev/ec2/images/ec2_type6.png +0 -0
  58. data/docs/dev/ec2/images/ec2_type7.png +0 -0
  59. data/docs/dev/vpc/core_model.puml +49 -0
  60. data/docs/dev/vpc/images/core_model.png +0 -0
  61. data/docs/dev/vpc/images/simple.png +0 -0
  62. data/docs/dev/vpc/images/standard.png +0 -0
  63. data/docs/dev/vpc/simple.puml +17 -0
  64. data/docs/dev/vpc/standard.puml +24 -0
  65. data/docs/dev/vpc/vpc.md +19 -0
  66. data/docs/ops/build_aws_sdk_repl.md +19 -0
  67. data/docs/ops/images/.keep +0 -0
  68. data/docs/ops/run_rake_task.md +89 -0
  69. data/docs/ops/ship_circleci.md +9 -0
  70. data/docs/ops/ship_jenkins.md +20 -0
  71. data/docs/ops/ship_ruby_gem.md +26 -0
  72. data/docs/template_catalog.md +6 -0
  73. data/docs/template_pattern.md +13 -0
  74. data/docs/template_recipe.md +6 -0
  75. data/docs/template_spec.md +8 -0
  76. data/etude_for_aws.gemspec +41 -0
  77. data/etude_for_aws.iml +42 -0
  78. data/exe/etude_for_aws +3 -0
  79. data/lib/etude_for_aws.rb +38 -0
  80. data/lib/etude_for_aws/cfm/configuration.rb +39 -0
  81. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-1az-1subnet-pub.template +529 -0
  82. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-1az-2subnet-pub-pri.template +790 -0
  83. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-1az-2subnet-pub.template +634 -0
  84. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-2az-2subnet-pri.template +645 -0
  85. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-2az-2subnet-pub-pri.template +611 -0
  86. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-2az-2subnet-pub.template +646 -0
  87. data/lib/etude_for_aws/cfm/vpc/cfm_templates/vpc-2az-4subnet-pub-pri.template +1010 -0
  88. data/lib/etude_for_aws/cfm/vpc/null_vpc.rb +13 -0
  89. data/lib/etude_for_aws/cfm/vpc/one_az_one_public_subnet_vpc.rb +45 -0
  90. data/lib/etude_for_aws/cfm/vpc/one_az_two_public_and_private_subnet_vpc.rb +47 -0
  91. data/lib/etude_for_aws/cfm/vpc/one_az_two_public_subnet_vpc.rb +47 -0
  92. data/lib/etude_for_aws/cfm/vpc/two_az_one_public_subnet_and_private_subnet_vpc.rb +52 -0
  93. data/lib/etude_for_aws/cfm/vpc/two_az_two_private_subnet_vpc.rb +38 -0
  94. data/lib/etude_for_aws/cfm/vpc/two_az_two_public_subnet_and_private_subnet_vpc.rb +38 -0
  95. data/lib/etude_for_aws/cfm/vpc/two_az_two_public_subnet_vpc.rb +38 -0
  96. data/lib/etude_for_aws/cfm/vpc/vpc.rb +104 -0
  97. data/lib/etude_for_aws/ec2/configuration.rb +66 -0
  98. data/lib/etude_for_aws/ec2/ec2.rb +218 -0
  99. data/lib/etude_for_aws/ec2/ec2_api_gateway.rb +127 -0
  100. data/lib/etude_for_aws/ec2/ec2_instance.rb +107 -0
  101. data/lib/etude_for_aws/ec2/key_pair.rb +46 -0
  102. data/lib/etude_for_aws/ec2/security_group.rb +75 -0
  103. data/lib/etude_for_aws/ec2/vpc_interface.rb +11 -0
  104. data/lib/etude_for_aws/helpers/certification_helper.rb +16 -0
  105. data/lib/etude_for_aws/helpers/configuration_helper.rb +103 -0
  106. data/lib/etude_for_aws/tasks/cfm.rake +73 -0
  107. data/lib/etude_for_aws/tasks/ec2.rake +210 -0
  108. data/lib/etude_for_aws/tasks/vpc.rake +47 -0
  109. data/lib/etude_for_aws/version.rb +3 -0
  110. data/lib/etude_for_aws/vpc/configuration.rb +77 -0
  111. data/lib/etude_for_aws/vpc/customer_gateway.rb +28 -0
  112. data/lib/etude_for_aws/vpc/internet_gateway.rb +15 -0
  113. data/lib/etude_for_aws/vpc/route_table.rb +42 -0
  114. data/lib/etude_for_aws/vpc/simple_vpc.rb +57 -0
  115. data/lib/etude_for_aws/vpc/standard_vpc.rb +94 -0
  116. data/lib/etude_for_aws/vpc/subnet.rb +22 -0
  117. data/lib/etude_for_aws/vpc/vpc.rb +147 -0
  118. data/lib/etude_for_aws/vpc/vpc_api_gateway.rb +277 -0
  119. data/lib/etude_for_aws/vpc/vpc_director.rb +43 -0
  120. data/lib/etude_for_aws/vpc/vpn.rb +244 -0
  121. data/lib/etude_for_aws/vpc/vpn_connection.rb +28 -0
  122. data/lib/etude_for_aws/vpc/vpn_director.rb +47 -0
  123. data/lib/etude_for_aws/vpc/vpn_gateway.rb +36 -0
  124. metadata +280 -0
@@ -0,0 +1,9 @@
1
+ version: '2'
2
+ services:
3
+ app:
4
+ build: .
5
+ image: aws-cli
6
+ volumes:
7
+ - .:/project
8
+ env_file:
9
+ - .env
data/docs/README.md ADDED
@@ -0,0 +1,54 @@
1
+ Etude for AWS
2
+ ===================
3
+
4
+ # 目的 #
5
+ AWS構築のための練習プログラム集
6
+
7
+ # 前提 #
8
+ | ソフトウェア | バージョン | 備考 |
9
+ |:---------------|:----------|:------------|
10
+ | aws-cli | 1.11.81 | |
11
+ | eb | 3.10.1 | |
12
+ | terraform | 0.6.16 | |
13
+ | vagrant |1.8.7 | |
14
+ | packer |0.10.1 | |
15
+ | chef-dk |1.3.43 | |
16
+ | docker |17.04.0 | |
17
+ | docker-compose |1.8.0 | |
18
+
19
+ # 構成 #
20
+ 1. [構築](#構築)
21
+ 1. [配置](#配置)
22
+ 1. [開発](#開発)
23
+ 1. [運用](#運用)
24
+
25
+ ## 構築
26
+ [Using the AWS SDK for Ruby REPL](./ops/build_aws_sdk_repl.md)
27
+
28
+ **[⬆ back to top](#構成)**
29
+
30
+ ## 配置
31
+ ### [CircleCI配置](./ops/ship_circleci.md)
32
+ ### [Jenkins配置](./ops/ship_jenkins.md)
33
+ ### [RubyGemパッケージの配置](./ops/ship_ruby_gem.md)
34
+
35
+ **[⬆ back to top](#構成)**
36
+
37
+ ## 開発
38
+ ### [CFM](./dev/cfm/cfm.md)
39
+ ### [VPC](./dev/vpc/vpc.md)
40
+ ### [EC2](./dev/ec2/ec2.md)
41
+
42
+ **[⬆ back to top](#構成)**
43
+
44
+ ## 運用
45
+ [Rake Task](./ops/run_rake_task.md)
46
+
47
+ **[⬆ back to top](#運用)**
48
+
49
+ # 参照 #
50
+ + [AWS SDK for Ruby - Version 2](https://github.com/aws/aws-sdk-ruby)
51
+ + [AWS SDK for Ruby - Version 2 API Docs](http://docs.aws.amazon.com/sdkforruby/api/index.html)
52
+ + [AWS SDK for Ruby Code Examples](http://docs.aws.amazon.com/ja_jp/sdk-for-ruby/v2/developer-guide/examples.html)
53
+ + [RSpec Expectations 3.5](http://www.relishapp.com/rspec/rspec-expectations/v/3-5/docs)
54
+ + [PlantUML](http://plantuml.com/)
data/docs/_config.yml ADDED
@@ -0,0 +1,6 @@
1
+ highlighter: rouge
2
+ markdown: kramdown
3
+ kramdown:
4
+ input: GFM
5
+ auto_ids: true
6
+ syntax_highlighter: rouge
@@ -0,0 +1,9 @@
1
+ CloudFormation
2
+ ---
3
+
4
+ ## 基本仕様
5
+
6
+ ## ユースケース
7
+ ### [VPC](./vpc/vpc.md)
8
+
9
+ ## コアモデル
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,35 @@
1
+ @startuml
2
+
3
+ package Aws {
4
+ class CloudFormation
5
+ }
6
+
7
+ package EC2 {
8
+ Interface VpcInterface
9
+ }
10
+
11
+ Interface CertificationHelper
12
+ Interface ConfigurationHelper
13
+
14
+ package CFM {
15
+ class Vpc {
16
+ create()
17
+ destroy()
18
+ }
19
+
20
+ Vpc <|-- VpcInterface
21
+ CertificationHelper <|-- Configuration
22
+ ConfigurationHelper <|-- Configuration
23
+ Configuration -l-> CloudFormation
24
+ Vpc *-l- Configuration
25
+ Vpc <|-- NullVpc
26
+ Vpc <|-- OneAzOnePublicSubnetVpc
27
+ Vpc <|-- OneAzTwoPublicAndPrivateSubnetVpc
28
+ Vpc <|-- OneAzTwoPublicSubnetVpc
29
+ Vpc <|-- TwoAzOnePublicSubnetAndPrivateSubnetVpc
30
+ Vpc <|-- TwoAzTwoPrivateSubnetVpc
31
+ Vpc <|-- TwoAzTwoPublicSubnetAndPrivateSubnetVpc
32
+ Vpc <|-- TwoAzTwoPublicSubnetVpc
33
+ }
34
+
35
+ @enduml
@@ -0,0 +1,39 @@
1
+ VPC
2
+ ---
3
+
4
+ ## 基本仕様
5
+ + CloudFormationのテンプレートファイルに記述されたパターンごとにVPC環境を構築する
6
+ + 7パターンに対応する
7
+ 1. 1つのアベイラビリティゾーンに1つのパブリックサブネット
8
+ 1. 1つのアベイラビリティゾーンに2つのパブリックサブネット
9
+ 1. 1つのアベイラビリティゾーンに1つのパブリックサブネットと1つのプライベートサブネット
10
+ 1. 2つのアベイラビリティゾーンに2つのプライベートサブネット
11
+ 1. 2つのアベイラビリティゾーンに2つのパブリックサブネット
12
+ 1. 2つのアベイラビリティゾーンに1つのパブリックサブネットと1つのプライベートサブネット
13
+ 1. 2つのアベイラビリティゾーンに2つのパブリックサブネットと2つのプライベートサブネット
14
+
15
+ ## ユースケース
16
+ ### パターン1
17
+ ![](../images/vpc_type1.png)
18
+
19
+ ### パターン2
20
+ ![](../images/vpc_type2.png)
21
+
22
+ ### パターン3
23
+ ![](../images/vpc_type3.png)
24
+
25
+ ### パターン4
26
+ ![](../images/vpc_type4.png)
27
+
28
+ ### パターン5
29
+ ![](../images/vpc_type5.png)
30
+
31
+ ### パターン6
32
+ ![](../images/vpc_type6.png)
33
+
34
+ ### パターン7
35
+ ![](../images/vpc_type7.png)
36
+
37
+
38
+ ## コアモデル
39
+ ![](../images/vpc_core_model.png)
@@ -0,0 +1,17 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ Internet - [InternetGateway]
6
+ [InternetGateway] -- [RouteTable]
7
+ [RouteTable] -- PublicSubnet1
8
+ frame "AZ1" {
9
+ frame "PublicSubnet1" {
10
+ }
11
+ }
12
+ }
13
+ }
14
+ note right of PublicSubnet1
15
+ 10.0.0.0/24
16
+ end note
17
+ @enduml
@@ -0,0 +1,23 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ Internet - [InternetGateway]
6
+ [InternetGateway] -- [RouteTable]
7
+ [RouteTable] -- PublicSubnet1
8
+ [RouteTable] -- PublicSubnet2
9
+ frame "AZ1" {
10
+ frame "PublicSubnet1" {
11
+ }
12
+ frame "PublicSubnet2" {
13
+ }
14
+ }
15
+ }
16
+ }
17
+ note right of PublicSubnet1
18
+ 10.0.0.0/24
19
+ end note
20
+ note right of PublicSubnet2
21
+ 10.0.1.0/24
22
+ end note
23
+ @enduml
@@ -0,0 +1,24 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ Internet - [InternetGateway]
6
+ [InternetGateway] -- [RouteTable1]
7
+ [RouteTable1] -- PublicSubnet1
8
+ [RouteTable2] -- PublicSubnet1
9
+ [RouteTable2] -- PrivateSubnet1
10
+ frame "AZ1" {
11
+ frame "PublicSubnet1" {
12
+ }
13
+ frame "PrivateSubnet1" {
14
+ }
15
+ }
16
+ }
17
+ }
18
+ note right of PublicSubnet1
19
+ 10.0.0.0/24
20
+ end note
21
+ note right of PrivateSubnet1
22
+ 10.0.1.0/24
23
+ end note
24
+ @enduml
@@ -0,0 +1,23 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ [RouteTable] -- PrivateSubnet1
6
+ [RouteTable] -- PrivateSubnet2
7
+ frame "AZ1" {
8
+ frame "PrivateSubnet1" {
9
+ }
10
+ }
11
+ frame "AZ2" {
12
+ frame "PrivateSubnet2" {
13
+ }
14
+ }
15
+ }
16
+ }
17
+ note right of PrivateSubnet1
18
+ 10.0.2.0/24
19
+ end note
20
+ note right of PrivateSubnet2
21
+ 10.0.3.0/24
22
+ end note
23
+ @enduml
@@ -0,0 +1,25 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ Internet - [InternetGateway]
6
+ [InternetGateway] -- [RouteTable]
7
+ [RouteTable] -- PublicSubnet1
8
+ [RouteTable] -- PublicSubnet2
9
+ frame "AZ1" {
10
+ frame "PublicSubnet1" {
11
+ }
12
+ }
13
+ frame "AZ2" {
14
+ frame "PublicSubnet2" {
15
+ }
16
+ }
17
+ }
18
+ }
19
+ note right of PublicSubnet1
20
+ 10.0.0.0/24
21
+ end note
22
+ note right of PublicSubnet2
23
+ 10.0.1.0/24
24
+ end note
25
+ @enduml
@@ -0,0 +1,26 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ Internet - [InternetGateway]
6
+ [InternetGateway] -- [RouteTable1]
7
+ [RouteTable1] -- PublicSubnet1
8
+ [RouteTable2] -- PublicSubnet1
9
+ [RouteTable2] -- PrivateSubnet1
10
+ frame "AZ1" {
11
+ frame "PublicSubnet1" {
12
+ }
13
+ }
14
+ frame "AZ2" {
15
+ frame "PrivateSubnet1" {
16
+ }
17
+ }
18
+ }
19
+ }
20
+ note right of PublicSubnet1
21
+ 10.0.0.0/24
22
+ end note
23
+ note right of PrivateSubnet1
24
+ 10.0.1.0/24
25
+ end note
26
+ @enduml
@@ -0,0 +1,39 @@
1
+ @startuml
2
+ cloud Internet
3
+ frame "AWS" {
4
+ frame "VPC" {
5
+ Internet - [InternetGateway]
6
+ [InternetGateway] -- [RouteTable1]
7
+ [RouteTable1] -- PublicSubnet1
8
+ [RouteTable1] -- PublicSubnet2
9
+ [RouteTable2] -- PublicSubnet1
10
+ [RouteTable2] -- PublicSubnet2
11
+ [RouteTable2] -- PrivateSubnet1
12
+ [RouteTable2] -- PrivateSubnet2
13
+ frame "AZ1" {
14
+ frame "PublicSubnet1" {
15
+ }
16
+ frame "PrivateSubnet1" {
17
+ }
18
+ }
19
+ frame "AZ2" {
20
+ frame "PublicSubnet2" {
21
+ }
22
+ frame "PrivateSubnet2" {
23
+ }
24
+ }
25
+ }
26
+ }
27
+ note right of PublicSubnet1
28
+ 172.16.1.0/24
29
+ end note
30
+ note right of PrivateSubnet1
31
+ 172.16.3.0/24
32
+ end note
33
+ note right of PublicSubnet2
34
+ 172.16.2.0/24
35
+ end note
36
+ note right of PrivateSubnet2
37
+ 172.16.4.0/24
38
+ end note
39
+ @enduml
@@ -0,0 +1,43 @@
1
+ @startuml
2
+
3
+ package Aws {
4
+ class EC2::Client
5
+ class EC2::Resource
6
+ }
7
+
8
+ package CFM {
9
+ class CFM::Vpc
10
+ }
11
+
12
+ package VPC {
13
+ class VPC::Vpc
14
+ }
15
+
16
+ Interface CertificationHelper
17
+ Interface ConfigurationHelper
18
+
19
+ package EC2 {
20
+ Interface VpcInterface
21
+ VpcInterface <|-r- CFM::Vpc
22
+ VpcInterface <|-l- VPC::Vpc
23
+
24
+ class Ec2 {
25
+ create()
26
+ destroy()
27
+ start()
28
+ stop()
29
+ reboot()
30
+ }
31
+ CertificationHelper <|-- Ec2ApiGateway
32
+ ConfigurationHelper <|-- Configuration
33
+ Ec2ApiGateway -u-> Aws
34
+ Ec2 -r-> VpcInterface
35
+ Ec2 "1" *-u- "1" Configuration
36
+ Ec2 "1" *-u- "1" Ec2ApiGateway
37
+ Ec2 "1" *-- "1..*" Ec2Instance
38
+ Ec2 "1" *-- "1" KeyPair
39
+ Ec2 "1" *-- "1" SecurityGroup
40
+
41
+ }
42
+
43
+ @enduml
@@ -0,0 +1,36 @@
1
+ EC2
2
+ ---
3
+
4
+ ## 基本仕様
5
+ + VPCで作成されたネットワークにインスタンスを作成する。
6
+ + 対応するパターンは[7パターン](../vpc/vpc.md)
7
+ + すべてのインスタンスに共通のセキュリティグループが適用される。
8
+ + すべてのインスタンスに共通のキーペアが適用される。
9
+ + シンプルなVPC環境はパターン1に対応する。
10
+ + 標準的なVPC環境はパターン3に対応する。
11
+
12
+ ## ユースケース
13
+ ### パターン1
14
+ ![](images/ec2_type1.png)
15
+
16
+ ### パターン2
17
+ ![](images/ec2_type2.png)
18
+
19
+ ### パターン3
20
+ ![](images/ec2_type3.png)
21
+
22
+ ### パターン4
23
+ ![](images/ec2_type4.png)
24
+
25
+ ### パターン5
26
+ ![](images/ec2_type5.png)
27
+
28
+ ### パターン6
29
+ ![](images/ec2_type6.png)
30
+
31
+ ### パターン7
32
+ ![](images/ec2_type7.png)
33
+
34
+
35
+ ## コアモデル
36
+ ![](images/ec2_core_model.png)