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,54 @@
|
|
1
|
+
#
|
2
|
+
# Autoscaling LaunchConfiguration
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/ec2'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "autoscaling launch configuration")
|
9
|
+
instance_type = _ref_string("instance_type", args, "instance type")
|
10
|
+
associate = _bool("associate", args, false)
|
11
|
+
block_device = (args[:block_device] || []).collect{|v| _ec2_block_device(v) }
|
12
|
+
iam_instance = _ref_string("iam_instance", args, "iam instance profile")
|
13
|
+
image = _ec2_image(instance_type, args)
|
14
|
+
instance = args[:instance] || ""
|
15
|
+
instance_monitoring = _bool("instance_monitoring", args, true)
|
16
|
+
kernel = args[:kernel] || ""
|
17
|
+
key_name = _ref_string("key_name", args, "key name")
|
18
|
+
placement = _ref_string("placement", args)
|
19
|
+
ram = args[:ram] || ""
|
20
|
+
security_groups = _ref_array("security_groups", args, "security group")
|
21
|
+
spot = args[:spot] || ""
|
22
|
+
user_data = _ref_string("user_data", args, "user data")
|
23
|
+
|
24
|
+
_(name) do
|
25
|
+
Type "AWS::AutoScaling::LaunchConfiguration"
|
26
|
+
Properties do
|
27
|
+
AssociatePublicIpAddress associate
|
28
|
+
BlockDeviceMappings block_device unless block_device.empty?
|
29
|
+
#ClassicLinkVPCId
|
30
|
+
#ClassicLinkVPCSecurityGroups
|
31
|
+
#EbsOptimized
|
32
|
+
IamInstanceProfile iam_instance unless iam_instance.empty?
|
33
|
+
ImageId image
|
34
|
+
InstanceId instance unless instance.empty?
|
35
|
+
InstanceMonitoring instance_monitoring
|
36
|
+
InstanceType instance_type
|
37
|
+
KernelId kernel unless kernel.empty?
|
38
|
+
KeyName key_name
|
39
|
+
PlacementTenancy placement unless placement.empty?
|
40
|
+
RamDiskId ram unless ram.empty?
|
41
|
+
SecurityGroups security_groups unless security_groups.empty?
|
42
|
+
SpotPrice spot unless spot.empty?
|
43
|
+
UserData do
|
44
|
+
if user_data.is_a? Hash
|
45
|
+
Fn__Base64 user_data
|
46
|
+
else
|
47
|
+
Fn__Base64 (<<-EOS).undent
|
48
|
+
#!/bin/bash
|
49
|
+
#{user_data}
|
50
|
+
EOS
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Autoscaling LifecycleHook resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-lifecyclehook.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "autoscaling lifecycle hook")
|
8
|
+
autoscaling = _ref_string("autoscaling", args, "autoscaling group")
|
9
|
+
default = args[:default] || ""
|
10
|
+
heartbeat = args[:heartbeat] || ""
|
11
|
+
lifecycle = args[:lifecycle] || "autoscaling::EC2_INSTANCE_TERMINATING"
|
12
|
+
notification_meta = args[:notificatin_meta] || ""
|
13
|
+
notification_arn = _ref_string("topic", args, "topic")
|
14
|
+
role = _ref_attr_string("role", "Arn", args, "role")
|
15
|
+
|
16
|
+
_(name) do
|
17
|
+
Type "AWS::AutoScaling::LifecycleHook"
|
18
|
+
Properties do
|
19
|
+
AutoScalingGroupName autoscaling
|
20
|
+
DefaultResult default unless default.empty?
|
21
|
+
HeartbeatTimeout heartbeat unless heartbeat.empty?
|
22
|
+
LifecycleTransition lifecycle
|
23
|
+
NotificationMetadata notification_meta unless notification_meta.empty?
|
24
|
+
NotificationTargetARN notification_arn
|
25
|
+
RoleARN role
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Autoscaling ScalingPolicy resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-policy.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "autoscaling scaling policy")
|
8
|
+
adjustment = _valid_values(args[:adjustment],
|
9
|
+
%w( ChangeInCapacity ExactCapacity PercentChangeInCapacity ),
|
10
|
+
"ChangeInCapacity")
|
11
|
+
autoscaling = _ref_string("autoscaling", args, "autoscaling group")
|
12
|
+
cooldown = args[:cooldown] || -1
|
13
|
+
estimated = args[:estimated] || ""
|
14
|
+
metric = _valid_values(args[:metric], %w( Minimum Maximum Average ), "Average")
|
15
|
+
min = args[:min] || ""
|
16
|
+
policy = _valid_values(args[:policy], %w( SimpleScaling StepScaling ), "SimpleScaling")
|
17
|
+
scaling = args[:scaling] || 1
|
18
|
+
step = args[:step] || [].collect{|v| _autoscaling_step(v) }
|
19
|
+
|
20
|
+
_(name) do
|
21
|
+
Type "AWS::AutoScaling::ScalingPolicy"
|
22
|
+
Properties do
|
23
|
+
AdjustmentType adjustment
|
24
|
+
AutoScalingGroupName autoscaling
|
25
|
+
Cooldown cooldown unless cooldown == -1
|
26
|
+
EstimatedInstanceWarmup estimated unless estimated.empty?
|
27
|
+
MetricAggregationType metric unless policy == "SimpleScaling"
|
28
|
+
MinAdjustmentMagnitude min unless min.empty?
|
29
|
+
PolicyType policy
|
30
|
+
ScalingAdjustment scaling
|
31
|
+
StepAdjustments step unless step.empty?
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Autoscaling ScheduledAction resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-scheduledaction.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "autoscaling scheduled action")
|
8
|
+
autoscaling = _ref_string("autoscaling", args, "autoscaling group")
|
9
|
+
desired = args[:desired] || ""
|
10
|
+
end_time =
|
11
|
+
if args.key? :end_time
|
12
|
+
_timestamp_utc_from_string("2016-03-18 00:00")
|
13
|
+
else
|
14
|
+
""
|
15
|
+
end
|
16
|
+
min = args[:min] || ""
|
17
|
+
max = args[:max] || ""
|
18
|
+
recurrence = args[:recurrence] || ""
|
19
|
+
start_time =
|
20
|
+
if args.key? :start_time
|
21
|
+
_timestamp_utc_from_string("2016-03-18 00:00")
|
22
|
+
else
|
23
|
+
""
|
24
|
+
end
|
25
|
+
|
26
|
+
_(name) do
|
27
|
+
Type "AWS::AutoScaling::ScheduledAction"
|
28
|
+
Properties do
|
29
|
+
AutoScalingGroupName autoscaling
|
30
|
+
DesiredCapacity desired unless desired.empty?
|
31
|
+
EndTime end_time unless end_time.empty?
|
32
|
+
MaxSize max unless max.empty?
|
33
|
+
MinSize min unless min.empty?
|
34
|
+
Recurrence recurrence unless recurrence.empty?
|
35
|
+
StartTime start_time unless start_time.empty?
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# Cloudtrail Trail resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-trail.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "trail")
|
8
|
+
depends = args[:depends] || []
|
9
|
+
group = _ref_attr_string("group", "Arn", args)
|
10
|
+
role = _ref_attr_string("role", "Arn", args)
|
11
|
+
enable = _bool("enable", args, false)
|
12
|
+
include = _bool("include", args, false)
|
13
|
+
logging = _bool("logging", args, true)
|
14
|
+
s3_bucket = _ref_string("s3_bucket", args, "bucket")
|
15
|
+
s3_key = _ref_string("s3_key", args, "key")
|
16
|
+
sns =
|
17
|
+
if args.key? :sns
|
18
|
+
_attr_string(_resource_name(args[:ref_sns], "sns"), "TopicName")
|
19
|
+
else
|
20
|
+
""
|
21
|
+
end
|
22
|
+
tags = _tags(args)
|
23
|
+
|
24
|
+
_(name) do
|
25
|
+
DependsOn depends unless depends.empty?
|
26
|
+
Type "AWS::CloudTrail::Trail"
|
27
|
+
Properties do
|
28
|
+
CloudWatchLogsLogGroupArn group unless group.empty?
|
29
|
+
CloudWatchLogsRoleArn role unless role.empty?
|
30
|
+
EnableLogFileValidation enable
|
31
|
+
IncludeGlobalServiceEvents include
|
32
|
+
IsLogging logging
|
33
|
+
#KMSkeyId
|
34
|
+
S3BucketName s3_bucket
|
35
|
+
S3KeyPrefix s3_key unless s3_key.empty?
|
36
|
+
SnsTopicName sns unless sns.empty?
|
37
|
+
Tags tags unless tags.empty?
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Cloudwatch alarm resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/cloudwatch'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "alarm")
|
9
|
+
enabled = _bool("enabled", args, true)
|
10
|
+
actions = _ref_array("actions", args)
|
11
|
+
description = args[:description] || ""
|
12
|
+
alarm_name = _ref_name("alarm_name", args)
|
13
|
+
operator = _cloudwatch_convert_operator(args[:operator])
|
14
|
+
dimensions = (args[:dimensions] || []).collect{|v| _cloudwatch_dimension(v) }
|
15
|
+
evaluation = args[:evaluation] || 3
|
16
|
+
insufficients = args[:insufficients] || []
|
17
|
+
metric = args[:metric]
|
18
|
+
namespace = args[:namespace]
|
19
|
+
ok_actions = args[:ok_actions] || []
|
20
|
+
period = args[:period] || 60
|
21
|
+
statistic = _valid_values(args[:statistic],
|
22
|
+
%w(SampleCount Average Sum Minimum Maximum), "Average")
|
23
|
+
threshold = args[:threshold] || 60
|
24
|
+
unit = _valid_values(args[:unit], %w(Seconds Microseconds Milliseconds Bytes Kilobytes Megabytes Gigabytes Terabytes Bits Kilobits Megabits Gigabits Terabits Percent Count Bytes/Second Kilobytes/Second Megabytes/Second Gigabytes/Second Terabytes/Second Bits/Second Kilobits/Second Megabits/Second Gigabits/Second Terabits/Second Count/Second None), "")
|
25
|
+
|
26
|
+
_(name) do
|
27
|
+
Type AWS::CloudWatch::Alarm
|
28
|
+
Properties do
|
29
|
+
ActionsEnabled enabled
|
30
|
+
AlarmActions actions
|
31
|
+
AlarmDescription description unless description.empty?
|
32
|
+
AlarmName alarm_name
|
33
|
+
ComparisonOperator operator
|
34
|
+
Dimensions dimensions
|
35
|
+
EvaluationPeriods evaluation
|
36
|
+
InsufficientDataActions insufficients unless insufficients.empty?
|
37
|
+
MetricName metric
|
38
|
+
Namespace namespace
|
39
|
+
OKActions ok_actions unless ok_actions.empty?
|
40
|
+
Period period
|
41
|
+
Statistic statistic
|
42
|
+
Threshold threshold
|
43
|
+
Unit unit unless unit.empty?
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Codedeploy Application resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-application.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "codedeploy application")
|
8
|
+
application = _ref_name("application", args)
|
9
|
+
|
10
|
+
_(name) do
|
11
|
+
Type "AWS::CodeDeploy::Application"
|
12
|
+
Properties do
|
13
|
+
ApplicationName application
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# CodeDeploy DeploymentConfig resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentconfig.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/codedeploy'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "deployment config")
|
9
|
+
deployment = _ref_name("deployment", args, "codedeploy deployment")
|
10
|
+
minimum =
|
11
|
+
if args.key? :minimum
|
12
|
+
_codedeploy_minimum(args[:minimum])
|
13
|
+
else
|
14
|
+
""
|
15
|
+
end
|
16
|
+
|
17
|
+
_(name) do
|
18
|
+
Type "AWS::CodeDeploy::DeploymentConfig"
|
19
|
+
Properties do
|
20
|
+
DeploymentConfigName deployment
|
21
|
+
MinimumHealthyHosts minimum unless minimum.empty?
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# CodeDeploy DeploymentGroup resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/codedeploy'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "deployment group")
|
9
|
+
application = _ref_string("application", args, "codedeploy application")
|
10
|
+
autoscalings = _ref_array("autoscalings", args, "autoscaling group")
|
11
|
+
deployment =
|
12
|
+
if args.key? :deployment
|
13
|
+
_codedeploy_deployment(args[:deployment])
|
14
|
+
else
|
15
|
+
""
|
16
|
+
end
|
17
|
+
deployment_config = args[:deplyoment_config] || ""
|
18
|
+
deployment_group = args[:deployment_group] || ""
|
19
|
+
ec2_tag = (args[:ec2_tag] || []).collect{|v| _codedeploy_tag_filters(v) }
|
20
|
+
on_premises = (args[:on_premises] || []).collect{|v| _codedeploy_tag_filters(v) }
|
21
|
+
service = _ref_string("service", args, "service role")
|
22
|
+
|
23
|
+
_(name) do
|
24
|
+
Type "AWS::CodeDeploy::DeploymentGroup"
|
25
|
+
Properties do
|
26
|
+
ApplicationName application
|
27
|
+
AutoScalingGroups autoscalings unless autoscalings.empty?
|
28
|
+
Deployment deployment unless deployment.empty?
|
29
|
+
DeploymentConfigName deployment_config unless deployment_config.empty?
|
30
|
+
DeploymentGroupName deployment_group unless deployment_group.empty?
|
31
|
+
Ec2TagFilters ec2_tag unless ec2_tag.empty?
|
32
|
+
OnPremisesInstanceTagFilters on_premises unless on_premises.empty?
|
33
|
+
ServiceRoleArn service
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# Datapipeline pipeline resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-datapipeline-pipeline.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/datapipeline'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "pipeline")
|
9
|
+
active = _bool("active", args, true)
|
10
|
+
description = args[:description] || ""
|
11
|
+
pipeline_name = _ref_name("pl_name", args)
|
12
|
+
parameter_objects = _datapipeline_parameter_objects(args)
|
13
|
+
parameter_values = _datapipeline_parameter_values(args)
|
14
|
+
pipeline_objects = _datapipeline_pipeline_objects(args)
|
15
|
+
pipeline_tags = _datapipeline_pipeline_tags(args)
|
16
|
+
|
17
|
+
_(name) do
|
18
|
+
Type "AWS::DataPipeline::Pipeline"
|
19
|
+
Properties do
|
20
|
+
Activate active
|
21
|
+
Description description unless description.empty?
|
22
|
+
Name pipeline_name
|
23
|
+
ParameterObjects parameter_objects unless parameter_objects.empty?
|
24
|
+
ParameterValues parameter_values unless parameter_values.empty?
|
25
|
+
PipelineObjects pipeline_objects
|
26
|
+
PipelineTags pipeline_tags unless pipeline_tags.empty?
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# DynamoDB Table resource
|
3
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/dynamodb'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "table")
|
9
|
+
attribute = _dynamodb_attribute(args[:attribute])
|
10
|
+
global = (args[:global] || []).collect{|v| _dynamodb_global(v) }
|
11
|
+
key_schema = _dynamodb_key_schema(args[:key_schema])
|
12
|
+
local = (args[:local] || []).collect{|v| _dynamodb_local(v) }
|
13
|
+
provisioned = _dynamodb_provisioned(args[:provisioned] || [])
|
14
|
+
stream =
|
15
|
+
if args.key? :stream
|
16
|
+
_dynamodb_stream(args[:stream])
|
17
|
+
else
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
table = _ref_name("table", args)
|
21
|
+
|
22
|
+
_(name) do
|
23
|
+
Type "AWS::DynamoDB::Table"
|
24
|
+
Properties do
|
25
|
+
AttributeDefinitions attribute
|
26
|
+
GlobalSecondaryIndexes global unless global.empty?
|
27
|
+
KeySchema key_schema
|
28
|
+
LocalSecondaryIndexes local unless local.empty?
|
29
|
+
ProvisionedThroughput provisioned
|
30
|
+
StreamSpecification stream unless stream.empty?
|
31
|
+
TableName table
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# EC2 EIP Association resource
|
3
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip-association.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "eip association")
|
8
|
+
allocation = _ref_string("allocation", args, "eip")
|
9
|
+
eip = args[:eip] || ""
|
10
|
+
instance = _ref_string("instance", args, "instance")
|
11
|
+
network = args[:network] || ""
|
12
|
+
private_ip = args[:private_ip] || ""
|
13
|
+
|
14
|
+
_(name) do
|
15
|
+
Type "AWS::EC2::EIPAssociation"
|
16
|
+
Properties do
|
17
|
+
AllocationId allocation
|
18
|
+
EIP eip
|
19
|
+
InstanceId instance unless instance.empty?
|
20
|
+
NetworkInterfaceId network unless network.empty?
|
21
|
+
PrivateIpAddress private_ip unless private_ip.empty?
|
22
|
+
end
|
23
|
+
end
|
data/template/ec2-eip.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# EC2 EIP resource
|
3
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
|
7
|
+
name = _resource_name(args[:name], "eip")
|
8
|
+
instance = _ref_string("instance", args, "instance")
|
9
|
+
domain = args[:domain] || ""
|
10
|
+
|
11
|
+
_(name) do
|
12
|
+
Type "AWS::EC2::EIP"
|
13
|
+
Properties do
|
14
|
+
InstanceId instance unless instance.empty?
|
15
|
+
Domain domain unless domain.empty?
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# EC2 Instance resource
|
3
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html
|
4
|
+
#
|
5
|
+
require 'kumogata/template/helper'
|
6
|
+
require 'kumogata/template/ec2'
|
7
|
+
|
8
|
+
name = _resource_name(args[:name], "instance")
|
9
|
+
instance_type = _ref_string("instance_type", args, "instance type")
|
10
|
+
az = _availability_zone(args)
|
11
|
+
block_device = (args[:block_device] || []).collect{|v| _ec2_block_device(v) }
|
12
|
+
disable_termination = _bool("disable_termination", args, false)
|
13
|
+
iam_instance = _ref_string("iam_instance", args, "iam instance profile")
|
14
|
+
image =_ec2_image(instance_type, args)
|
15
|
+
instance_initiated = args[:instance_initiated] || "stop"
|
16
|
+
kernel = args[:kernel] || ""
|
17
|
+
key_name = _ref_string("key_name", args, "key name")
|
18
|
+
monitoring = _bool("monitoring", args, true)
|
19
|
+
network_interfaces = (args[:network_interfaces] || []).collect{|v| _ec2_network_interface(v) }
|
20
|
+
placement = _ref_string("placement", args)
|
21
|
+
private_ip = args[:private_ip] || ""
|
22
|
+
ram_disk = args[:ram_disk] || ""
|
23
|
+
security_groups = _ref_array("security_groups", args, "security group")
|
24
|
+
source_dest = _bool("source_dest", args, true)
|
25
|
+
ssm = args[:ssm] || []
|
26
|
+
subnet = _ref_string("subnet", args, "subnet")
|
27
|
+
tags = _ec2_tags(args)
|
28
|
+
tenancy = args[:tenancy] || "default"
|
29
|
+
user_data = _ref_string("user_data", args, "user data")
|
30
|
+
volumes = args[:volumes] || ""
|
31
|
+
|
32
|
+
_(name) do
|
33
|
+
Type "AWS::EC2::Instance"
|
34
|
+
Properties do
|
35
|
+
AvailabilityZone az unless az.empty?
|
36
|
+
BlockDeviceMappings block_device
|
37
|
+
DisableApiTermination disable_termination
|
38
|
+
#EbsOptimized
|
39
|
+
IamInstanceProfile iam_instance
|
40
|
+
ImageId image
|
41
|
+
InstanceInitiatedShutdownBehavior instance_initiated
|
42
|
+
InstanceType instance_type
|
43
|
+
KernelId kernel unless kernel.empty?
|
44
|
+
KeyName key_name
|
45
|
+
Monitoring monitoring
|
46
|
+
NetworkInterfaces network_interfaces unless network_interfaces.empty?
|
47
|
+
PlacementGroupName placement unless placement.empty?
|
48
|
+
PrivateIpAddress private_ip unless private_ip.empty?
|
49
|
+
RamdiskId ram_disk unless ram_disk.empty?
|
50
|
+
#SecurityGroupIds
|
51
|
+
SecurityGroups security_groups unless security_groups.empty?
|
52
|
+
SourceDestCheck source_dest
|
53
|
+
SsmAssociations ssm unless ssm.empty?
|
54
|
+
SubnetId subnet unless subnet.empty?
|
55
|
+
Tags tags
|
56
|
+
Tenancy tenancy unless tenancy.empty?
|
57
|
+
UserData do
|
58
|
+
Fn__Base64 (<<-EOS).undent
|
59
|
+
#!/bin/bash
|
60
|
+
#{user_data}
|
61
|
+
EOS
|
62
|
+
end
|
63
|
+
Volumes volumes unless volumes.empty?
|
64
|
+
end
|
65
|
+
end
|