kumogata-template 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +13 -40
- data/README.md +34 -83
- data/bin/kumogata-template +2 -2
- data/kumogata-template.gemspec +4 -4
- data/lib/kumogata/template/autoscaling.rb +19 -0
- data/lib/kumogata/template/cloudwatch.rb +1 -9
- data/lib/kumogata/template/const.rb +22 -4
- data/lib/kumogata/template/ec2.rb +18 -8
- data/lib/kumogata/template/ecs.rb +34 -0
- data/lib/kumogata/template/elasticbeanstalk.rb +937 -3
- data/lib/kumogata/template/ext/kumogata.rb +64 -16
- data/lib/kumogata/template/helper.rb +146 -19
- data/lib/kumogata/template/iam.rb +2 -3
- data/lib/kumogata/template/lambda.rb +10 -1
- data/lib/kumogata/template/version.rb +1 -1
- data/template/_template.rb +20 -3
- data/template/alb-load-balancer.rb +8 -1
- data/template/autoscaling-launch-configuration.rb +2 -11
- data/template/autoscaling-scheduled-action.rb +2 -17
- data/template/ec2-instance.rb +5 -7
- data/template/ec2-network-acl-entry.rb +3 -1
- data/template/ec2-route.rb +3 -1
- data/template/ec2-security-group.rb +2 -0
- data/template/ec2-subnet.rb +2 -1
- data/template/ec2-vpc.rb +2 -1
- data/template/ecs-service.rb +4 -0
- data/template/ecs-task-definition.rb +6 -4
- data/template/elasticbeanstalk-application-version.rb +9 -4
- data/template/elasticbeanstalk-application.rb +4 -3
- data/template/elasticbeanstalk-configuration-template.rb +7 -2
- data/template/elasticbeanstalk-environment.rb +10 -10
- data/template/emr-cluster.rb +8 -3
- data/template/iam-instance-profile.rb +2 -0
- data/template/lambda-function.rb +8 -3
- data/template/mappings-ec2.rb +44 -44
- data/template/output-access-key.rb +7 -2
- data/template/output-alb.rb +16 -11
- data/template/output-arn.rb +6 -3
- data/template/output-autoscaling.rb +7 -2
- data/template/output-dynamodb.rb +7 -2
- data/template/output-ec2-subnet.rb +14 -0
- data/template/output-ec2.rb +13 -4
- data/template/output-elasticache.rb +23 -7
- data/template/output-elasticbeanstalk-environment.rb +8 -0
- data/template/output-elb.rb +13 -6
- data/template/output-emr.rb +8 -3
- data/template/output-iam-instance-profile.rb +7 -2
- data/template/output-iam-role.rb +7 -2
- data/template/output-name.rb +3 -1
- data/template/output-rds.rb +7 -3
- data/template/output-redshift.rb +7 -3
- data/template/output-s3.rb +11 -3
- data/template/output-security-group.rb +4 -1
- data/template/output-sqs.rb +4 -1
- data/template/output-topic.rb +8 -3
- data/template/output-vpc.rb +16 -4
- data/template/output.rb +3 -1
- data/template/rds-db-instance.rb +7 -0
- data/template/redshift-cluster.rb +2 -0
- data/template/sqs-queue.rb +14 -0
- data/test/abstract_unit.rb +31 -8
- data/test/elasticbeanstalk_test.rb +3 -3
- data/test/helper_test.rb +431 -0
- data/test/template/autoscaling-launch-configuration_test.rb +1 -4
- data/test/template/ec2-instance_test.rb +2 -2
- data/test/template/ec2-vpc_test.rb +2 -2
- data/test/template/ecs-task-definition_test.rb +13 -13
- data/test/template/elasticbeanstalk-application-version_test.rb +13 -3
- data/test/template/elasticbeanstalk-template_test.rb +1 -1
- data/test/template/iam-instance-profile_test.rb +20 -0
- data/test/template/lambda-function_test.rb +60 -4
- data/test/template/{output-az_test.rb → output-ec2-subet_test.rb} +7 -8
- data/test/template/output-elasticache_test.rb +18 -0
- data/test/template/output_test.rb +23 -0
- data/test/template/rds-db-instance_test.rb +1 -1
- metadata +22 -22
- data/lib/kumogata/template/ext/argument_parser.rb +0 -8
- data/template/output-az.rb +0 -6
data/template/output-name.rb
CHANGED
data/template/output-rds.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
#
|
2
2
|
# Output rds
|
3
3
|
#
|
4
|
+
require 'kumogata/template/helper'
|
4
5
|
|
5
6
|
_output "#{args[:name]} db instance",
|
6
|
-
ref_value: "#{args[:name]} db instance"
|
7
|
+
ref_value: "#{args[:name]} db instance",
|
8
|
+
export: _export_string(args, "db instance")
|
7
9
|
_output "#{args[:name]} db instance address",
|
8
|
-
ref_value: [ "#{args[:name]} db instance", "Endpoint.Address" ]
|
10
|
+
ref_value: [ "#{args[:name]} db instance", "Endpoint.Address" ],
|
11
|
+
export: _export_string(args, "db instance endpoint address")
|
9
12
|
_output "#{args[:name]} db instance port",
|
10
|
-
ref_value: [ "#{args[:name]} db instance", "Endpoint.Port" ]
|
13
|
+
ref_value: [ "#{args[:name]} db instance", "Endpoint.Port" ],
|
14
|
+
export: _export_string(args, "db instance endpoint port")
|
data/template/output-redshift.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
#
|
2
2
|
# Output redshift
|
3
3
|
#
|
4
|
+
require 'kumogata/template/helper'
|
4
5
|
|
5
6
|
_output "#{args[:name]} redshift cluster",
|
6
|
-
ref_value: "#{args[:name]} redshift cluster"
|
7
|
+
ref_value: "#{args[:name]} redshift cluster",
|
8
|
+
export: _export_string(args, "redshift cluster")
|
7
9
|
_output "#{args[:name]} redshift cluster address",
|
8
|
-
ref_value: [ "#{args[:name]} redshift cluster", "Endpoint.Address" ]
|
10
|
+
ref_value: [ "#{args[:name]} redshift cluster", "Endpoint.Address" ],
|
11
|
+
export: _export_string(args, "redshift cluster endpoint address")
|
9
12
|
_output "#{args[:name]} redshift cluster port",
|
10
|
-
ref_value: [ "#{args[:name]} redshift cluster", "Endpoint.Port" ]
|
13
|
+
ref_value: [ "#{args[:name]} redshift cluster", "Endpoint.Port" ],
|
14
|
+
export: _export_string(args, "redshift cluster endpoint port")
|
data/template/output-s3.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# Output s3
|
3
3
|
#
|
4
|
+
require 'kumogata/template/helper'
|
4
5
|
|
5
6
|
bucket = "#{args[:name]} bucket"
|
6
7
|
|
7
|
-
_output "#{bucket} s3 domain name",
|
8
|
-
|
8
|
+
_output "#{bucket} s3 domain name",
|
9
|
+
ref_value: [ bucket, "DomainName" ],
|
10
|
+
export: _export_string(args, "s3 domain name")
|
11
|
+
_output "#{bucket} s3 web site url",
|
12
|
+
ref_value: [ bucket, "WebsiteURL" ],
|
13
|
+
export: _export_string(args, "s3 website url")
|
14
|
+
_output "#{bucket} s3 dual stack domain name",
|
15
|
+
ref_value: [ bucket, "DualStackDomainName" ],
|
16
|
+
export: _export(args, "s3 dual stack domain name") if args.key? :ipv6
|
@@ -1,5 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Output security group
|
3
3
|
#
|
4
|
+
require 'kumogata/template/helper'
|
4
5
|
|
5
|
-
_output "#{args[:name]} security group",
|
6
|
+
_output "#{args[:name]} security group",
|
7
|
+
ref_value: "#{args[:name]} security group",
|
8
|
+
export: _export_string(args, "security group")
|
data/template/output-sqs.rb
CHANGED
data/template/output-topic.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
#
|
2
|
-
# Output name
|
2
|
+
# Output name and topic
|
3
3
|
#
|
4
|
+
require 'kumogata/template/helper'
|
4
5
|
|
5
|
-
_output "#{args[:name]} topic",
|
6
|
-
|
6
|
+
_output "#{args[:name]} topic",
|
7
|
+
ref_value: "#{args[:name]} topic",
|
8
|
+
export: _export_string(args, "topic")
|
9
|
+
_output "#{args[:name]} topic name",
|
10
|
+
ref_value: [ "#{args[:name]} topic", "TopicName" ],
|
11
|
+
export: _export_string(args, "topic name")
|
data/template/output-vpc.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
#
|
2
2
|
# Output VPC
|
3
3
|
#
|
4
|
+
require 'kumogata/template/helper'
|
4
5
|
|
5
6
|
vpc = "#{args[:name]} vpc"
|
6
7
|
|
7
|
-
_output "#{args[:name]} vpc",
|
8
|
-
|
9
|
-
|
10
|
-
_output "#{args[:name]} vpc
|
8
|
+
_output "#{args[:name]} vpc",
|
9
|
+
ref_value: vpc,
|
10
|
+
export: _export_string(args, "vpc")
|
11
|
+
_output "#{args[:name]} vpc cidr block",
|
12
|
+
ref_value: [ vpc, "CidrBlock" ],
|
13
|
+
export: _export_string(args, "vpc cidr block")
|
14
|
+
_output "#{args[:name]} vpc network acl",
|
15
|
+
ref_value: [ vpc, "DefaultNetworkAcl" ],
|
16
|
+
export: _export_string(args, "vpc default nework acl")
|
17
|
+
_output "#{args[:name]} vpc security group",
|
18
|
+
ref_value: [ vpc, "DefaultSecurityGroup" ],
|
19
|
+
export: _export_string(args, "vpc default security group")
|
20
|
+
_output "#{args[:name]} vpc ipv6 cidr blocks",
|
21
|
+
ref_value: [ vpc, "Ipv6CidrBlocks" ],
|
22
|
+
export: _export_string(args, "vpc ipv6 cidr bocks") if args.key? :ipv6
|
data/template/output.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require 'kumogata/template/helper'
|
6
6
|
|
7
7
|
name = _resource_name(args[:name])
|
8
|
+
description = args[:description] || "description of #{name}"
|
8
9
|
value =
|
9
10
|
if args.key? :value
|
10
11
|
if args[:value].is_a?(Array) and args[:value].length == 2
|
@@ -21,9 +22,10 @@ value =
|
|
21
22
|
else
|
22
23
|
name
|
23
24
|
end
|
24
|
-
|
25
|
+
export = _export(args)
|
25
26
|
|
26
27
|
_(name) do
|
27
28
|
Description description
|
28
29
|
Value value
|
30
|
+
Export export unless export.empty?
|
29
31
|
end
|
data/template/rds-db-instance.rb
CHANGED
@@ -16,6 +16,12 @@ auto = _bool("auto", args, true)
|
|
16
16
|
az = _availability_zone(args, false)
|
17
17
|
backup_retention = args[:backup_retention] || 7
|
18
18
|
character = args[:character] || ""
|
19
|
+
copy_tags =
|
20
|
+
if args.key? :copy_tags
|
21
|
+
_bool("copy_tags", args, true)
|
22
|
+
else
|
23
|
+
""
|
24
|
+
end
|
19
25
|
cluster = _ref_string("cluster", args, "db cluster")
|
20
26
|
instance_class = _ref_string("instance_class", args, "db instance classes")
|
21
27
|
instance_class = _valid_values(instance_class, RDS_INSTANCE_CLASSES, RDS_DEFAULT_INSTANCE_CLASS) unless instance_class.is_a? Hash
|
@@ -56,6 +62,7 @@ _(name) do
|
|
56
62
|
AvailabilityZone az unless multi_az
|
57
63
|
BackupRetentionPeriod backup_retention if 0 < backup_retention
|
58
64
|
CharacterSetName character if !character.empty? and engine =~ /^oracle.*$/
|
65
|
+
CopyTagsToSnapshot copy_tags unless copy_tags.empty?
|
59
66
|
DBClusterIdentifier cluster if engine == "aurora" and !cluster.empty?
|
60
67
|
DBInstanceClass instance_class
|
61
68
|
DBInstanceIdentifier instance_id
|
@@ -15,6 +15,7 @@ version = args[:version] || ""
|
|
15
15
|
db_name = _ref_string("db_name", args, "db name")
|
16
16
|
elastic = args[:elastic] || ""
|
17
17
|
encrypted = _bool("encrypted", args, false)
|
18
|
+
iam_role = args[:iam_role] || ""
|
18
19
|
user_name = _ref_string("user_name", args, "cluster master user name")
|
19
20
|
user_password = _ref_string("user_password", args, "cluster master user password")
|
20
21
|
node = _ref_string("node", args, "redshift cluster node types")
|
@@ -45,6 +46,7 @@ _(name) do
|
|
45
46
|
Encrypted encrypted if encrypted == true
|
46
47
|
#HsmClientCertificateIdentifie
|
47
48
|
#HsmConfigurationIdentifier
|
49
|
+
IamRoles iam_role unless iam_role.empty?
|
48
50
|
#KmsKeyId
|
49
51
|
MasterUsername user_name
|
50
52
|
MasterUserPassword user_password
|
data/template/sqs-queue.rb
CHANGED
@@ -5,7 +5,19 @@
|
|
5
5
|
require 'kumogata/template/helper'
|
6
6
|
|
7
7
|
name = _resource_name(args[:name], "queue")
|
8
|
+
content =
|
9
|
+
if args.key? :content
|
10
|
+
_bool("content", args, true)
|
11
|
+
else
|
12
|
+
""
|
13
|
+
end
|
8
14
|
deplay = args[:deplay] || 0
|
15
|
+
fifo =
|
16
|
+
if args.key? :fifo
|
17
|
+
_bool("fifo", args, true)
|
18
|
+
else
|
19
|
+
""
|
20
|
+
end
|
9
21
|
max = args[:max] || 262144 # default 256KiB
|
10
22
|
retention = args[:retention] || 345600 # default 4 days
|
11
23
|
queue = _ref_name("queue", args)
|
@@ -16,7 +28,9 @@ visibility = args[:visibility] || 30 # default 30 seconds
|
|
16
28
|
_(name) do
|
17
29
|
Type "AWS::SQS::Queue"
|
18
30
|
Properties do
|
31
|
+
ContentBasedDeduplication content unless content.empty?
|
19
32
|
DelaySeconds deplay
|
33
|
+
FifoQueue fio unless fifo.empty?
|
20
34
|
MaximumMessageSize max
|
21
35
|
MessageRetentionPeriod retention
|
22
36
|
QueueName queue
|
data/test/abstract_unit.rb
CHANGED
@@ -1,13 +1,24 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
-
require '
|
3
|
-
require '
|
2
|
+
require 'kumogata2'
|
3
|
+
require 'kumogata2/cli/option_parser'
|
4
|
+
require 'kumogata2/plugin/ruby'
|
4
5
|
require 'json'
|
5
6
|
require 'tempfile'
|
7
|
+
require 'yaml'
|
6
8
|
|
7
9
|
# for only test
|
8
10
|
ENV['TZ'] = 'Asia/Tokyo'
|
9
11
|
|
10
|
-
class
|
12
|
+
class Kumogata2::Client
|
13
|
+
include Kumogata2::Logger::Helper
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
@options = options.kind_of?(Hashie::Mash) ? options : Hashie::Mash.new(options)
|
17
|
+
@plugin_by_ext = {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Kumogata2::Plugin::Ruby::Context
|
11
22
|
def define_template_func(scope, path_or_url)
|
12
23
|
functions = ""
|
13
24
|
Dir.glob("template/*.rb").all? do |file|
|
@@ -73,6 +84,11 @@ def tempfile(content, template_ext = nil)
|
|
73
84
|
basename = "#{File.basename __FILE__}.#{$$}"
|
74
85
|
basename = [basename, template_ext] if template_ext
|
75
86
|
|
87
|
+
content = <<EOS
|
88
|
+
template do
|
89
|
+
#{content}
|
90
|
+
end
|
91
|
+
EOS
|
76
92
|
Tempfile.open(basename) do |f|
|
77
93
|
f << content
|
78
94
|
f.flush
|
@@ -84,14 +100,16 @@ end
|
|
84
100
|
def run_client(template)
|
85
101
|
$stdout = open('/dev/null', 'w') unless ENV['DEBUG']
|
86
102
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
103
|
+
Kumogata2::Plugin.load_plugins
|
104
|
+
|
105
|
+
options = Kumogata2::CLI::OptionParser::DEFAULT_OPTIONS
|
106
|
+
options[:output_format] = 'json'
|
107
|
+
options[:result_log] = '/dev/null'
|
108
|
+
options[:command_result_log] = '/dev/null'
|
91
109
|
template_ext = '.rb'
|
92
110
|
|
93
111
|
template = tempfile(template, template_ext) do |f|
|
94
|
-
|
112
|
+
Kumogata2::Client.new(options).send(:open_template, f.path)
|
95
113
|
end
|
96
114
|
end
|
97
115
|
|
@@ -99,3 +117,8 @@ def run_client_as_json(template)
|
|
99
117
|
eval_template = run_client(template)
|
100
118
|
JSON.pretty_generate(eval_template)
|
101
119
|
end
|
120
|
+
|
121
|
+
def run_client_as_yaml(template)
|
122
|
+
eval_template = run_client(template)
|
123
|
+
YAML.dump(eval_template)
|
124
|
+
end
|
@@ -2,9 +2,9 @@ require 'abstract_unit'
|
|
2
2
|
require 'kumogata/template/elasticbeanstalk'
|
3
3
|
|
4
4
|
class ElasticbeantalkTest < Minitest::Test
|
5
|
-
def
|
5
|
+
def test_elasticbeanstalk_options
|
6
6
|
template = <<-EOS
|
7
|
-
Test
|
7
|
+
Test _elasticbeanstalk_options([ name: "test", option: "test", value: "test" ])
|
8
8
|
EOS
|
9
9
|
act_template = run_client_as_json(template)
|
10
10
|
exp_template = <<-EOS
|
@@ -39,7 +39,7 @@ Test _elasticbeanstalk_configuration(application: "test", template: "test")
|
|
39
39
|
|
40
40
|
def test_elasticbeanstalk_tier
|
41
41
|
template = <<-EOS
|
42
|
-
Test _elasticbeanstalk_tier(
|
42
|
+
Test _elasticbeanstalk_tier("test")
|
43
43
|
EOS
|
44
44
|
act_template = run_client_as_json(template)
|
45
45
|
exp_template = <<-EOS
|