kumogata-template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +54 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/README.md +204 -0
- data/Rakefile +23 -0
- data/bin/kumogata-template +9 -0
- data/kumogata-template.gemspec +26 -0
- data/lib/kumogata/template.rb +17 -0
- data/lib/kumogata/template/autoscaling.rb +77 -0
- data/lib/kumogata/template/cloudwatch.rb +28 -0
- data/lib/kumogata/template/codedeploy.rb +85 -0
- data/lib/kumogata/template/const.rb +175 -0
- data/lib/kumogata/template/datapipeline.rb +90 -0
- data/lib/kumogata/template/dynamodb.rb +111 -0
- data/lib/kumogata/template/ec2.rb +165 -0
- data/lib/kumogata/template/ecs.rb +119 -0
- data/lib/kumogata/template/elasticbeanstalk.rb +33 -0
- data/lib/kumogata/template/elb.rb +132 -0
- data/lib/kumogata/template/emr.rb +166 -0
- data/lib/kumogata/template/events.rb +25 -0
- data/lib/kumogata/template/ext/argument_parser.rb +8 -0
- data/lib/kumogata/template/ext/kumogata.rb +103 -0
- data/lib/kumogata/template/helper.rb +211 -0
- data/lib/kumogata/template/iam.rb +96 -0
- data/lib/kumogata/template/lambda.rb +34 -0
- data/lib/kumogata/template/s3.rb +223 -0
- data/lib/kumogata/template/sns.rb +25 -0
- data/lib/kumogata/template/version.rb +1 -0
- data/template/_template.rb +25 -0
- data/template/autoscaling-group.rb +47 -0
- data/template/autoscaling-launch-configuration.rb +54 -0
- data/template/autoscaling-lifecycle-hook.rb +27 -0
- data/template/autoscaling-scaling-policy.rb +33 -0
- data/template/autoscaling-scheduled-action.rb +37 -0
- data/template/cloudtrail.rb +39 -0
- data/template/cloudwatch-alarm.rb +45 -0
- data/template/codedeploy-application.rb +15 -0
- data/template/codedeploy-deployment-config.rb +23 -0
- data/template/codedeploy-deployment-group.rb +35 -0
- data/template/datapipeline-pipeline.rb +28 -0
- data/template/dynamodb-table.rb +33 -0
- data/template/ec2-eip-association.rb +23 -0
- data/template/ec2-eip.rb +17 -0
- data/template/ec2-instance.rb +65 -0
- data/template/ec2-internet-gateway.rb +15 -0
- data/template/ec2-nat-gateway.rb +17 -0
- data/template/ec2-network-acl-entry.rb +30 -0
- data/template/ec2-network-acl.rb +17 -0
- data/template/ec2-route-table.rb +17 -0
- data/template/ec2-route.rb +27 -0
- data/template/ec2-security-group.rb +24 -0
- data/template/ec2-subnet-network-acl-association.rb +17 -0
- data/template/ec2-subnet-route-table-association.rb +17 -0
- data/template/ec2-subnet.rb +23 -0
- data/template/ec2-volume-attachment.rb +19 -0
- data/template/ec2-volume.rb +31 -0
- data/template/ec2-vpc-endpoint.rb +23 -0
- data/template/ec2-vpc-gateway-attachment.rb +19 -0
- data/template/ec2-vpc.rb +24 -0
- data/template/ecs-cluster.rb +11 -0
- data/template/ecs-service.rb +24 -0
- data/template/ecs-task-definition.rb +18 -0
- data/template/elasticache-cache-cluster.rb +63 -0
- data/template/elasticache-parameter-group.rb +20 -0
- data/template/elasticache-replication-group.rb +58 -0
- data/template/elasticache-subnet-group.rb +17 -0
- data/template/elasticbeanstalk-application-version.rb +24 -0
- data/template/elasticbeanstalk-application.rb +17 -0
- data/template/elasticbeanstalk-configuration-template.rb +31 -0
- data/template/elasticbeanstalk-environment.rb +44 -0
- data/template/elb-loadbalancer.rb +46 -0
- data/template/emr-cluster.rb +39 -0
- data/template/emr-instance-group-config.rb +33 -0
- data/template/emr-step.rb +22 -0
- data/template/events-rule.rb +28 -0
- data/template/iam-access-key.rb +19 -0
- data/template/iam-group.rb +20 -0
- data/template/iam-instance-profile.rb +17 -0
- data/template/iam-managed-policy.rb +28 -0
- data/template/iam-policy.rb +26 -0
- data/template/iam-role.rb +21 -0
- data/template/iam-user-to-group-addition.rb +17 -0
- data/template/iam-user.rb +24 -0
- data/template/lambda-alias.rb +21 -0
- data/template/lambda-event-source-mapping.rb +24 -0
- data/template/lambda-function.rb +34 -0
- data/template/lambda-permission.rb +26 -0
- data/template/lambda-version.rb +19 -0
- data/template/mappings-ec2.rb +85 -0
- data/template/output-access-key.rb +6 -0
- data/template/output-arn.rb +6 -0
- data/template/output-autoscaling.rb +6 -0
- data/template/output-az.rb +6 -0
- data/template/output-dynamodb.rb +6 -0
- data/template/output-ec2.rb +8 -0
- data/template/output-elasticache.rb +30 -0
- data/template/output-elb.rb +12 -0
- data/template/output-emr.rb +6 -0
- data/template/output-rds.rb +10 -0
- data/template/output-redshift.rb +10 -0
- data/template/output-s3.rb +8 -0
- data/template/output-security-group.rb +5 -0
- data/template/output-sqs.rb +5 -0
- data/template/output-topic.rb +6 -0
- data/template/output-vpc.rb +10 -0
- data/template/output.rb +29 -0
- data/template/parameter-ec2.rb +22 -0
- data/template/parameter-elasticache.rb +9 -0
- data/template/parameter-rds.rb +9 -0
- data/template/parameter-redshift.rb +9 -0
- data/template/parameter.rb +20 -0
- data/template/rds-db-cluster-parameter-group.rb +22 -0
- data/template/rds-db-cluster.rb +47 -0
- data/template/rds-db-instance.rb +82 -0
- data/template/rds-db-parameter-group.rb +21 -0
- data/template/rds-db-subnet-group.rb +19 -0
- data/template/rds-event-subscription.rb +42 -0
- data/template/rds-option-group.rb +23 -0
- data/template/redshift-cluster-parameter-group.rb +19 -0
- data/template/redshift-cluster-subnet-group.rb +17 -0
- data/template/redshift-cluster.rb +60 -0
- data/template/s3-bucket-policy.rb +20 -0
- data/template/s3-bucket.rb +42 -0
- data/template/sns-topic.rb +20 -0
- data/template/sqs-queue.rb +27 -0
- data/test/_template.rb +26 -0
- data/test/abstract_unit.rb +101 -0
- data/test/autoscaling_test.rb +109 -0
- data/test/codedeploy_test.rb +117 -0
- data/test/datapipeline_test.rb +142 -0
- data/test/dynamodb_test.rb +184 -0
- data/test/ec2_test.rb +286 -0
- data/test/ecs_test.rb +135 -0
- data/test/elasticbeanstalk_test.rb +56 -0
- data/test/elb_test.rb +147 -0
- data/test/emr_test.rb +193 -0
- data/test/events_test.rb +22 -0
- data/test/helper_test.rb +547 -0
- data/test/iam_test.rb +93 -0
- data/test/lambda_test.rb +41 -0
- data/test/s3_test.rb +195 -0
- data/test/sns_test.rb +27 -0
- data/test/template/autoscaling-group_test.rb +177 -0
- data/test/template/autoscaling-launch-configuration_test.rb +117 -0
- data/test/template/autoscaling-lifecycle-hook_test.rb +33 -0
- data/test/template/autoscaling-scaling-policy_test.rb +26 -0
- data/test/template/autoscaling-scheduled-action_test.rb +26 -0
- data/test/template/cloudtrail_test.rb +55 -0
- data/test/template/cloudwatch-alarm_test.rb +38 -0
- data/test/template/codedeploy-application_test.rb +21 -0
- data/test/template/codedeploy-deployment-config_test.rb +26 -0
- data/test/template/codedeploy-deployment-group_test.rb +48 -0
- data/test/template/datapipeline-pipeline_test.rb +358 -0
- data/test/template/dynamodb-table_test.rb +94 -0
- data/test/template/ec2-eip-association_test.rb +22 -0
- data/test/template/ec2-eip_test.rb +21 -0
- data/test/template/ec2-instance_test.rb +95 -0
- data/test/template/ec2-internet-gateway_test.rb +48 -0
- data/test/template/ec2-nat-gateway_test.rb +22 -0
- data/test/template/ec2-network-acl-entry_test.rb +61 -0
- data/test/template/ec2-network-acl_test.rb +51 -0
- data/test/template/ec2-route-table_test.rb +49 -0
- data/test/template/ec2-route_test.rb +21 -0
- data/test/template/ec2-security-group_test.rb +50 -0
- data/test/template/ec2-subnet-netwokr-acl-association_test.rb +26 -0
- data/test/template/ec2-subnet-route-table-association_test.rb +22 -0
- data/test/template/ec2-subnet_test.rb +51 -0
- data/test/template/ec2-volume-attachment_test.rb +24 -0
- data/test/template/ec2-volume_test.rb +52 -0
- data/test/template/ec2-vpc-gateway-attachment_test.rb +23 -0
- data/test/template/ec2-vpc_test.rb +102 -0
- data/test/template/ecs-cluster_test.rb +18 -0
- data/test/template/ecs-service_test.rb +29 -0
- data/test/template/ecs-task-definition_test.rb +143 -0
- data/test/template/elasticache-cache-cluster_test.rb +77 -0
- data/test/template/elasticache-parameter-group_test.rb +25 -0
- data/test/template/elasticache-replication-group_test.rb +45 -0
- data/test/template/elasticache-subnet-group_test.rb +26 -0
- data/test/template/elasticbeanstalk-application-version_test.rb +27 -0
- data/test/template/elasticbeanstalk-application_test.rb +21 -0
- data/test/template/elasticbeanstalk-configuration-template_test.rb +23 -0
- data/test/template/elasticbeanstalk-environment_test.rb +56 -0
- data/test/template/elasticbeanstalk-template_test.rb +33 -0
- data/test/template/elb-loadbalancer_test.rb +94 -0
- data/test/template/emr-cluster_test.rb +147 -0
- data/test/template/emr-instance-group-config_test.rb +65 -0
- data/test/template/emr-step_test.rb +82 -0
- data/test/template/events-rule_test.rb +34 -0
- data/test/template/iam-access-key_test.rb +22 -0
- data/test/template/iam-group_test.rb +21 -0
- data/test/template/iam-instance-profile_test.rb +24 -0
- data/test/template/iam-managed-policy_test.rb +35 -0
- data/test/template/iam-policy_test.rb +52 -0
- data/test/template/iam-role_test.rb +37 -0
- data/test/template/iam-user-to-group-addition_test.rb +24 -0
- data/test/template/iam-user_test.rb +21 -0
- data/test/template/lambda-alias_test.rb +46 -0
- data/test/template/lambda-event-source-mapping_test.rb +36 -0
- data/test/template/lambda-function_test.rb +34 -0
- data/test/template/lambda-permission_test.rb +32 -0
- data/test/template/lambda-version_test.rb +27 -0
- data/test/template/mappings-ec2_test.rb +92 -0
- data/test/template/output-access-key_test.rb +30 -0
- data/test/template/output-arn_test.rb +30 -0
- data/test/template/output-autoscaling_test.rb +27 -0
- data/test/template/output-az_test.rb +31 -0
- data/test/template/output-dynamodb_test.rb +21 -0
- data/test/template/output-ec2_test.rb +82 -0
- data/test/template/output-elasticache_test.rb +107 -0
- data/test/template/output-elb_test.rb +48 -0
- data/test/template/output-emr_test.rb +30 -0
- data/test/template/output-rds_test.rb +39 -0
- data/test/template/output-redshift_test.rb +39 -0
- data/test/template/output-s3_test.rb +52 -0
- data/test/template/output-security-group_test.rb +21 -0
- data/test/template/output-sqs_test.rb +21 -0
- data/test/template/output-topic_test.rb +30 -0
- data/test/template/output-vpc_test.rb +48 -0
- data/test/template/output_test.rb +87 -0
- data/test/template/parameter-ec2_test.rb +44 -0
- data/test/template/parameter-elasticache_test.rb +30 -0
- data/test/template/parameter-rds_test.rb +30 -0
- data/test/template/parameter-redshift_test.rb +30 -0
- data/test/template/parameter_test.rb +40 -0
- data/test/template/rds-db-cluster-parameter-group_test.rb +53 -0
- data/test/template/rds-db-cluster_test.rb +84 -0
- data/test/template/rds-db-instance_test.rb +93 -0
- data/test/template/rds-db-parameter-group_test.rb +53 -0
- data/test/template/rds-db-subnet-group.rb +54 -0
- data/test/template/rds-event-subscription_test.rb +48 -0
- data/test/template/rds-option-group_test.rb +56 -0
- data/test/template/redshift-cluster-parameter-group_test.rb +28 -0
- data/test/template/redshift-cluster-subnet-group_test.rb +26 -0
- data/test/template/redshift-cluster_test.rb +47 -0
- data/test/template/s3-bucket-policy_test.rb +40 -0
- data/test/template/s3-bucket_test.rb +127 -0
- data/test/template/sns-topic_test.rb +42 -0
- data/test/template/sqs-queue_test.rb +25 -0
- metadata +468 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
#
|
2
|
+
# Output rds
|
3
|
+
#
|
4
|
+
|
5
|
+
_output "#{args[:name]} db instance",
|
6
|
+
ref_value: "#{args[:name]} db instance"
|
7
|
+
_output "#{args[:name]} db instance address",
|
8
|
+
ref_value: [ "#{args[:name]} db instance", "Endpoint.Address" ]
|
9
|
+
_output "#{args[:name]} db instance port",
|
10
|
+
ref_value: [ "#{args[:name]} db instance", "Endpoint.Port" ]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#
|
2
|
+
# Output redshift
|
3
|
+
#
|
4
|
+
|
5
|
+
_output "#{args[:name]} redshift cluster",
|
6
|
+
ref_value: "#{args[:name]} redshift cluster"
|
7
|
+
_output "#{args[:name]} redshift cluster address",
|
8
|
+
ref_value: [ "#{args[:name]} redshift cluster", "Endpoint.Address" ]
|
9
|
+
_output "#{args[:name]} redshift cluster port",
|
10
|
+
ref_value: [ "#{args[:name]} redshift cluster", "Endpoint.Port" ]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#
|
2
|
+
# Output VPC
|
3
|
+
#
|
4
|
+
|
5
|
+
vpc = "#{args[:name]} vpc"
|
6
|
+
|
7
|
+
_output "#{args[:name]} vpc", ref_value: vpc
|
8
|
+
_output "#{args[:name]} vpc cidr block", ref_value: [ vpc, "CidrBlock" ]
|
9
|
+
_output "#{args[:name]} vpc network acl", ref_value: [ vpc, "DefaultNetworkAcl" ]
|
10
|
+
_output "#{args[:name]} vpc security group", ref_value: [ vpc, "DefaultSecurityGroup" ]
|
data/template/output.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Output resource
|
3
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name])
|
8
|
+
value =
|
9
|
+
if args.key? :value
|
10
|
+
if args[:value].is_a?(Array) and args[:value].length == 2
|
11
|
+
_attr_string(args[:value][0], args[:value][1])
|
12
|
+
else
|
13
|
+
args[:value]
|
14
|
+
end
|
15
|
+
elsif args.key? :ref_value
|
16
|
+
if args[:ref_value].is_a?(Array) and args[:ref_value].length == 2
|
17
|
+
_attr_string(args[:ref_value][0], args[:ref_value][1])
|
18
|
+
else
|
19
|
+
_ref_string("", { ref_: args[:ref_value] })
|
20
|
+
end
|
21
|
+
else
|
22
|
+
name
|
23
|
+
end
|
24
|
+
description = args[:description] || "description of #{name}"
|
25
|
+
|
26
|
+
_(name) do
|
27
|
+
Description description
|
28
|
+
Value value
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# EC2 parameter
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
_parameter "#{args[:name]} instance type",
|
7
|
+
default: args[:instance] || EC2_DEFAULT_INSTANCE_TYPE,
|
8
|
+
description: "#{args[:name]} instance type",
|
9
|
+
allowed_values: EC2_INSTANCE_TYPES
|
10
|
+
|
11
|
+
_parameter "#{args[:name]} iam instance profile",
|
12
|
+
default: args[:iam_instance] || "",
|
13
|
+
description: "#{args[:name]} iam instance profile"
|
14
|
+
|
15
|
+
_parameter "#{args[:name]} data volume size",
|
16
|
+
default: args[:size] || 100,
|
17
|
+
description: "#{args[:name]} data volume size"
|
18
|
+
|
19
|
+
_parameter "#{args[:name]} key name",
|
20
|
+
default: args[:key],
|
21
|
+
description: "#{args[:name]} key name",
|
22
|
+
type: "AWS::EC2::KeyPair::KeyName"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#
|
2
|
+
# Elasticache parameter
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
_parameter "#{args[:name]} cache node types",
|
7
|
+
default: args[:cache_node] || ELASTICACHE_DEFAULT_NODE_TYPE,
|
8
|
+
description: "#{args[:name]} cache node types",
|
9
|
+
allowed_values: ELASTICACHE_NODE_TYPES
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#
|
2
|
+
# RDS instance parameter
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
_parameter "#{args[:name]} db instance classes",
|
7
|
+
default: args[:instance_class] || RDS_DEFAULT_INSTANCE_CLASS,
|
8
|
+
description: "#{args[:name]} db instance classes",
|
9
|
+
allowed_values: RDS_INSTANCE_CLASSES
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#
|
2
|
+
# Redshift parameter
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
_parameter "#{args[:name]} redshift cluster node types",
|
7
|
+
default: args[:node_type] || REDSHIFT_DEFAULT_NODE_TYPE,
|
8
|
+
description: "#{args[:name]} redshift cluster node types",
|
9
|
+
allowed_values: REDSHIFT_NODE_TYPES
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# Parameter resource
|
3
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name])
|
8
|
+
type = args[:type] || "String"
|
9
|
+
default = args[:default] || ""
|
10
|
+
allowed_values = args[:allowed_values] || []
|
11
|
+
description = args[:description] || ""
|
12
|
+
no_echo = args[:no_echo] || nil
|
13
|
+
|
14
|
+
_(name) do
|
15
|
+
Type type
|
16
|
+
Default default
|
17
|
+
AllowedValues allowed_values unless allowed_values.empty?
|
18
|
+
Description description
|
19
|
+
NoEcho true unless no_echo.nil?
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# RDS DBClusterParameterGroup resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbclusterparametergroup.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "db cluster parameter group")
|
8
|
+
description = args[:description] || "#{args[:name]} db cluster parameter group description"
|
9
|
+
family = _ref_string("family", args, "db parameter group")
|
10
|
+
family = "aurora5.6" if family.empty?
|
11
|
+
parameters = args[:parameters]
|
12
|
+
tags = _tags(args)
|
13
|
+
|
14
|
+
_(name) do
|
15
|
+
Type "AWS::RDS::DBClusterParameterGroup"
|
16
|
+
Properties do
|
17
|
+
Description description
|
18
|
+
Family family
|
19
|
+
Parameters parameters
|
20
|
+
Tags tags
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# RDS DBCluster resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "db cluster")
|
8
|
+
az = _availability_zone(args)
|
9
|
+
backup_retention = args[:backup_retention] || 7
|
10
|
+
db_name = _ref_name("database", args, "database")
|
11
|
+
parameter = _ref_string("parameter", args, "db cluster parameter group")
|
12
|
+
parameter = "default.aurora5.6" if parameter.empty?
|
13
|
+
subnet_group = _ref_string("subnet_group", args, "db subnet group")
|
14
|
+
engine = "aurora"
|
15
|
+
engine_version = RDS_DEFAULT_ENGINE_VERSION[:aurora]
|
16
|
+
user_name = _ref_string("user_name", args, "db master user name")
|
17
|
+
user_password = _ref_string("user_password", args, "db master user password")
|
18
|
+
port = args[:port] || 3306
|
19
|
+
backup_window = _window_time("rds", args[:backup_start] || DEFAULT_SNAPSHOT_TIME[:rds])
|
20
|
+
maintenance = _maintenance_window("rds", args[:maintenance] || DEFAULT_MAINTENANCE_TIME[:rds])
|
21
|
+
snapshot = args[:snapshot] || ""
|
22
|
+
encrypted = _bool("encrypted", args, false)
|
23
|
+
tags = _tags(args)
|
24
|
+
security_groups = _ref_array("security_groups", args, "security group")
|
25
|
+
|
26
|
+
_(name) do
|
27
|
+
Type "AWS::RDS::DBCluster"
|
28
|
+
Properties do
|
29
|
+
AvailabilityZone az unless az.empty?
|
30
|
+
BackupRetentionPeriod backup_retention if 0 < backup_retention
|
31
|
+
DatabaseName db_name
|
32
|
+
DBClusterParameterGroupName parameter
|
33
|
+
DBSubnetGroupName subnet_group
|
34
|
+
Engine engine
|
35
|
+
EngineVersion engine_version
|
36
|
+
#KmsKeyId
|
37
|
+
MasterUsername user_name
|
38
|
+
MasterUserPassword user_password
|
39
|
+
Port port
|
40
|
+
PreferredBackupWindow backup_window
|
41
|
+
PreferredMaintenanceWindow maintenance
|
42
|
+
SnapshotIdentifier snapshot unless snapshot.empty?
|
43
|
+
StorageEncrypted encrypted if encrypted == true
|
44
|
+
Tags tags
|
45
|
+
VpcSecurityGroupIds security_groups unless security_groups.empty?
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# RDS DBInstance resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "db instance")
|
8
|
+
engine = _valid_values(args[:engine],
|
9
|
+
%w( mysql mariadb
|
10
|
+
oracle-se1 oracle-se oracle-ee
|
11
|
+
sqlserver-ee sqlserver-se sqlserver-ex sqlserver-web
|
12
|
+
postgres aurora ), RDS_DEFAULT_ENGINE)
|
13
|
+
allocated = args[:allocated] || 5
|
14
|
+
allow = _bool("allow", args, true)
|
15
|
+
auto = _bool("auto", args, true)
|
16
|
+
az = _availability_zone(args, false)
|
17
|
+
backup_retention = args[:backup_retention] || 7
|
18
|
+
character = args[:character] || ""
|
19
|
+
cluster = _ref_string("cluster", args, "db cluster")
|
20
|
+
instance_class = _ref_string("instance_class", args, "db instance classes")
|
21
|
+
instance_class = _valid_values(instance_class, RDS_INSTANCE_CLASSES, RDS_DEFAULT_INSTANCE_CLASS) unless instance_class.is_a? Hash
|
22
|
+
instance_id = _ref_name("instance_id", args, "db instance id")
|
23
|
+
db_name = _ref_string("db_name", args, "db name")
|
24
|
+
parameter = _ref_string("parameter", args, "db parameter group")
|
25
|
+
parameter = "default.mysql5.7" if parameter.empty?
|
26
|
+
security = _ref_array("security_groups", args, "security group")
|
27
|
+
subnet_group = _ref_string("subnet_group", args, "db subnet group")
|
28
|
+
snapshot = _ref_string("snapshot", args, "db snapshot")
|
29
|
+
engine_version = _ref_string("engine_version", args, "db engine version")
|
30
|
+
engine_version = RDS_DEFAULT_ENGINE_VERSION[engine.to_sym] if engine_version.empty?
|
31
|
+
iops = args[:iops] || ""
|
32
|
+
user_name = _ref_string("user_name", args, "db master user name")
|
33
|
+
user_password = _ref_string("user_password", args, "db master user password")
|
34
|
+
multi_az = _bool("multi_az", args, false)
|
35
|
+
option = _ref_string("option", args, "db option group")
|
36
|
+
port = _ref_string("port", args, "db port")
|
37
|
+
port = PORT[args[:engine]] if port.empty?
|
38
|
+
backup_window = _window_time("rds", args[:backup_start] || DEFAULT_SNAPSHOT_TIME[:rds])
|
39
|
+
maintenance = _maintenance_window("rds", args[:maintenance] || DEFAULT_MAINTENANCE_TIME[:rds])
|
40
|
+
publicly = _bool("publicly", args, false)
|
41
|
+
source_db = _ref_string("source_db", args, "db source db")
|
42
|
+
storage_encrypted = _bool("encrypted", args, false)
|
43
|
+
tags = _tags(args)
|
44
|
+
security_groups = _ref_array("security_groups", args, "security group")
|
45
|
+
|
46
|
+
_(name) do
|
47
|
+
Type "AWS::RDS::DBInstance"
|
48
|
+
Properties do
|
49
|
+
AllocatedStorage allocated
|
50
|
+
AllowMajorVersionUpgrade allow
|
51
|
+
AutoMinorVersionUpgrade auto
|
52
|
+
AvailabilityZone az unless multi_az
|
53
|
+
BackupRetentionPeriod backup_retention if 0 < backup_retention
|
54
|
+
CharacterSetName character if !character.empty? and engine =~ /^oracle.*$/
|
55
|
+
DBClusterIdentifier cluster if engine == "aurora" and !cluster.empty?
|
56
|
+
DBInstanceClass instance_class
|
57
|
+
DBInstanceIdentifier instance_id
|
58
|
+
DBName db_name if snapshot.empty?
|
59
|
+
DBParameterGroupName parameter unless parameter.empty?
|
60
|
+
DBSecurityGroups security if security_groups.empty?
|
61
|
+
DBSnapshotIdentifier snapshot unless snapshot.empty?
|
62
|
+
DBSubnetGroupName subnet_group
|
63
|
+
Engine engine
|
64
|
+
EngineVersion engine_version
|
65
|
+
Iops iops unless iops.empty?
|
66
|
+
#KmsKeyId
|
67
|
+
#LicenseModel
|
68
|
+
MasterUsername user_name
|
69
|
+
MasterUserPassword user_password
|
70
|
+
MultiAZ multi_az
|
71
|
+
OptionGroupName option unless option.empty?
|
72
|
+
Port port
|
73
|
+
PreferredBackupWindow backup_window
|
74
|
+
PreferredMaintenanceWindow maintenance
|
75
|
+
PubliclyAccessible publicly
|
76
|
+
SourceDBInstanceIdentifier source_db unless source_db.empty?
|
77
|
+
StorageEncrypted storage_encrypted if storage_encrypted == true
|
78
|
+
#StorageType
|
79
|
+
Tags tags
|
80
|
+
VPCSecurityGroups security_groups unless security_groups.empty?
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# RDS DBParameterGroup resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-dbparametergroup.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "db parameter group")
|
8
|
+
description = args[:description] || "#{args[:name]} db parameter group description"
|
9
|
+
family = args[:family] || "mysql5.7"
|
10
|
+
parameters = args[:parameters]
|
11
|
+
tags = _tags(args)
|
12
|
+
|
13
|
+
_(name) do
|
14
|
+
Type "AWS::RDS::DBParameterGroup"
|
15
|
+
Properties do
|
16
|
+
Description description
|
17
|
+
Family family
|
18
|
+
Parameters parameters
|
19
|
+
Tags tags
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# RDS DBSubnetGroup resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbsubnet-group.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "db subnet group")
|
8
|
+
description = args[:description] || "#{args[:name]} db subnet group description"
|
9
|
+
subnets = _ref_array("subnets", args, "subnet")
|
10
|
+
tags = _tags(args)
|
11
|
+
|
12
|
+
_(name) do
|
13
|
+
Type "AWS::RDS::DBSubnetGroup"
|
14
|
+
Properties do
|
15
|
+
DBSubnetGroupDescription description
|
16
|
+
SubnetIds subnets
|
17
|
+
Tags tags
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# RDS EventSubscription resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-eventsubscription.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "event subscription")
|
8
|
+
enabled = _bool("enabled", args, true)
|
9
|
+
event_categories = args[:categories] ||
|
10
|
+
%w( availability backup configuration\ change creation deletion
|
11
|
+
failover failure low\ storage maintenance notification
|
12
|
+
read\ replica recovery restoration )
|
13
|
+
sns = _ref_attr_string("sns", "Arn", args, "role")
|
14
|
+
sns = _ref_string("sns_arn", args) if sns.empty?
|
15
|
+
sources = _ref_array("sources", args, "db instance")
|
16
|
+
source_type = _valid_values(args[:source_type],
|
17
|
+
%w( db-instance db-parameter-group
|
18
|
+
db-security-group db-snapshot ),
|
19
|
+
"db-instance")
|
20
|
+
source_prefix =
|
21
|
+
case source_type
|
22
|
+
when "db-instance"
|
23
|
+
"db instance"
|
24
|
+
when "db-parameter-group"
|
25
|
+
"db parameter group"
|
26
|
+
when "db-security-group"
|
27
|
+
"security group"
|
28
|
+
when "db-snapshot"
|
29
|
+
""
|
30
|
+
end
|
31
|
+
sources = _ref_array("sources", args, source_prefix)
|
32
|
+
|
33
|
+
_(name) do
|
34
|
+
Type "AWS::RDS::EventSubscription"
|
35
|
+
Properties do
|
36
|
+
Enabled enabled
|
37
|
+
EventCategories event_categories
|
38
|
+
SnsTopicArn sns
|
39
|
+
SourceIds sources
|
40
|
+
SourceType source_type
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# RDS OptionGroup resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-optiongroup.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "option group")
|
8
|
+
engine = args[:engine] || "mysql"
|
9
|
+
major = args[:major] || "5.7"
|
10
|
+
description = args[:description] || "#{args[:name]} option group description"
|
11
|
+
configurations = args[:configurations]
|
12
|
+
tags = _tags(args)
|
13
|
+
|
14
|
+
_(name) do
|
15
|
+
Type "AWS::RDS::OptionGroup"
|
16
|
+
Properties do
|
17
|
+
EngineName engine
|
18
|
+
MajorEngineVersion major
|
19
|
+
OptionGroupDescription description
|
20
|
+
OptionGroupConfigurations configurations
|
21
|
+
Tags tags
|
22
|
+
end
|
23
|
+
end
|