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,117 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AutoscalingLaunchConfigurationTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_autoscaling_launch_configuration "test", image: "test", ref_instance_type: "test", key_name: "test", instance_monitoring: false
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestAutoscalingLaunchConfiguration": {
|
12
|
+
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
13
|
+
"Properties": {
|
14
|
+
"AssociatePublicIpAddress": "false",
|
15
|
+
"ImageId": {
|
16
|
+
"Fn::FindInMap": [
|
17
|
+
"AWSRegionArch2AMITest",
|
18
|
+
{
|
19
|
+
"Ref": "AWS::Region"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"Fn::FindInMap": [
|
23
|
+
"AWSInstanceType2Arch",
|
24
|
+
{
|
25
|
+
"Ref": "TestInstanceType"
|
26
|
+
},
|
27
|
+
"Arch"
|
28
|
+
]
|
29
|
+
}
|
30
|
+
]
|
31
|
+
},
|
32
|
+
"InstanceMonitoring": "false",
|
33
|
+
"InstanceType": {
|
34
|
+
"Ref": "TestInstanceType"
|
35
|
+
},
|
36
|
+
"KeyName": "test",
|
37
|
+
"UserData": {
|
38
|
+
"Fn::Base64": "#!/bin/bash\\n\\n"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
EOS
|
44
|
+
assert_equal exp_template.chomp, act_template
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_aws
|
48
|
+
template = <<-EOS
|
49
|
+
_autoscaling_launch_configuration "test", ref_key_name: "test", ref_security_groups: %w( test ), ref_instance_type: "test", block_device: [ { device: "/dev/sda1", size: 50, type: "io1", iops: 200 }, { device: "/dev/sdm", size: 100, delete: true } ], ref_user_data: "web server port"
|
50
|
+
EOS
|
51
|
+
act_template = run_client_as_json(template)
|
52
|
+
exp_template = <<-EOS
|
53
|
+
{
|
54
|
+
"TestAutoscalingLaunchConfiguration": {
|
55
|
+
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
56
|
+
"Properties": {
|
57
|
+
"AssociatePublicIpAddress": "false",
|
58
|
+
"BlockDeviceMappings": [
|
59
|
+
{
|
60
|
+
"DeviceName": "/dev/sda1",
|
61
|
+
"Ebs": {
|
62
|
+
"DeleteOnTermination": "true",
|
63
|
+
"Iops": "200",
|
64
|
+
"VolumeSize": "50",
|
65
|
+
"VolumeType": "io1"
|
66
|
+
}
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"DeviceName": "/dev/sdm",
|
70
|
+
"Ebs": {
|
71
|
+
"DeleteOnTermination": "true",
|
72
|
+
"VolumeSize": "100",
|
73
|
+
"VolumeType": "gp2"
|
74
|
+
}
|
75
|
+
}
|
76
|
+
],
|
77
|
+
"ImageId": {
|
78
|
+
"Fn::FindInMap": [
|
79
|
+
"AWSRegionArch2AMIAmazonLinuxOfficial",
|
80
|
+
{
|
81
|
+
"Ref": "AWS::Region"
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"Fn::FindInMap": [
|
85
|
+
"AWSInstanceType2Arch",
|
86
|
+
{
|
87
|
+
"Ref": "TestInstanceType"
|
88
|
+
},
|
89
|
+
"Arch"
|
90
|
+
]
|
91
|
+
}
|
92
|
+
]
|
93
|
+
},
|
94
|
+
"InstanceMonitoring": "true",
|
95
|
+
"InstanceType": {
|
96
|
+
"Ref": "TestInstanceType"
|
97
|
+
},
|
98
|
+
"KeyName": {
|
99
|
+
"Ref": "TestKeyName"
|
100
|
+
},
|
101
|
+
"SecurityGroups": [
|
102
|
+
{
|
103
|
+
"Ref": "TestSecurityGroup"
|
104
|
+
}
|
105
|
+
],
|
106
|
+
"UserData": {
|
107
|
+
"Fn::Base64": {
|
108
|
+
"Ref": "WebServerPortUserData"
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
EOS
|
115
|
+
assert_equal exp_template.chomp, act_template
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AutoscalingLifecycleHookTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_autoscaling_lifecycle_hook "test", ref_autoscaling: "test", ref_topic: "test", ref_role: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestAutoscalingLifecycleHook": {
|
12
|
+
"Type": "AWS::AutoScaling::LifecycleHook",
|
13
|
+
"Properties": {
|
14
|
+
"AutoScalingGroupName": {
|
15
|
+
"Ref": "TestAutoscalingGroup"
|
16
|
+
},
|
17
|
+
"LifecycleTransition": "autoscaling::EC2_INSTANCE_TERMINATING",
|
18
|
+
"NotificationTargetARN": {
|
19
|
+
"Ref": "TestTopic"
|
20
|
+
},
|
21
|
+
"RoleARN": {
|
22
|
+
"Fn::GetAtt": [
|
23
|
+
"TestRole",
|
24
|
+
"Arn"
|
25
|
+
]
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
EOS
|
31
|
+
assert_equal exp_template.chomp, act_template
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AutoscalingScalingPolicyTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_autoscaling_scaling_policy "test", ref_autoscaling: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestAutoscalingScalingPolicy": {
|
12
|
+
"Type": "AWS::AutoScaling::ScalingPolicy",
|
13
|
+
"Properties": {
|
14
|
+
"AdjustmentType": "ChangeInCapacity",
|
15
|
+
"AutoScalingGroupName": {
|
16
|
+
"Ref": "TestAutoscalingGroup"
|
17
|
+
},
|
18
|
+
"PolicyType": "SimpleScaling",
|
19
|
+
"ScalingAdjustment": "1"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
EOS
|
24
|
+
assert_equal exp_template.chomp, act_template
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AutoscalingScheduledActionTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_autoscaling_scheduled_action "test", ref_autoscaling: "test", max: "1", min: "1", recurrence: "0 19 * * *"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestAutoscalingScheduledAction": {
|
12
|
+
"Type": "AWS::AutoScaling::ScheduledAction",
|
13
|
+
"Properties": {
|
14
|
+
"AutoScalingGroupName": {
|
15
|
+
"Ref": "TestAutoscalingGroup"
|
16
|
+
},
|
17
|
+
"MaxSize": "1",
|
18
|
+
"MinSize": "1",
|
19
|
+
"Recurrence": "0 19 * * *"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
EOS
|
24
|
+
assert_equal exp_template.chomp, act_template
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class CloudtrailTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_cloudtrail "test", depends: %w( test ), s3_bucket: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestTrail": {
|
12
|
+
"DependsOn": [
|
13
|
+
"test"
|
14
|
+
],
|
15
|
+
"Type": "AWS::CloudTrail::Trail",
|
16
|
+
"Properties": {
|
17
|
+
"EnableLogFileValidation": "false",
|
18
|
+
"IncludeGlobalServiceEvents": "false",
|
19
|
+
"IsLogging": "true",
|
20
|
+
"S3BucketName": "test",
|
21
|
+
"Tags": [
|
22
|
+
{
|
23
|
+
"Key": "Name",
|
24
|
+
"Value": {
|
25
|
+
"Fn::Join": [
|
26
|
+
"-",
|
27
|
+
[
|
28
|
+
{
|
29
|
+
"Ref": "Service"
|
30
|
+
},
|
31
|
+
"test"
|
32
|
+
]
|
33
|
+
]
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"Key": "Service",
|
38
|
+
"Value": {
|
39
|
+
"Ref": "Service"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"Key": "Version",
|
44
|
+
"Value": {
|
45
|
+
"Ref": "Version"
|
46
|
+
}
|
47
|
+
}
|
48
|
+
]
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
EOS
|
53
|
+
assert_equal exp_template.chomp, act_template
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class CloudWatchAlarmTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_cloudwatch_alarm "test", actions: "test", alarm_name: "test", namespace: "test", operator: "<", metric: "test", dimensions: [ { name: "test", value: "test" } ]
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestAlarm": {
|
12
|
+
"Type": "AWS::CloudWatch::Alarm",
|
13
|
+
"Properties": {
|
14
|
+
"ActionsEnabled": "true",
|
15
|
+
"AlarmActions": [
|
16
|
+
"test"
|
17
|
+
],
|
18
|
+
"AlarmName": "test",
|
19
|
+
"ComparisonOperator": "LessThanOrEqualToThreshold",
|
20
|
+
"Dimensions": [
|
21
|
+
{
|
22
|
+
"Name": "test",
|
23
|
+
"Value": "test"
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"EvaluationPeriods": "3",
|
27
|
+
"MetricName": "test",
|
28
|
+
"Namespace": "test",
|
29
|
+
"Period": "60",
|
30
|
+
"Statistic": "Average",
|
31
|
+
"Threshold": "60"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
EOS
|
36
|
+
assert_equal exp_template.chomp, act_template
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class CodedeploApplicationTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_codedeploy_application "test", application: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestCodedeployApplication": {
|
12
|
+
"Type": "AWS::CodeDeploy::Application",
|
13
|
+
"Properties": {
|
14
|
+
"ApplicationName": "test"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
EOS
|
19
|
+
assert_equal exp_template.chomp, act_template
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class CodedeployDeploymentConfigTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_codedeploy_deployment_config "test", deployment: "test",
|
7
|
+
minimum: { type: "fleet_percent", value: "75" }
|
8
|
+
EOS
|
9
|
+
act_template = run_client_as_json(template)
|
10
|
+
exp_template = <<-EOS
|
11
|
+
{
|
12
|
+
"TestDeploymentConfig": {
|
13
|
+
"Type": "AWS::CodeDeploy::DeploymentConfig",
|
14
|
+
"Properties": {
|
15
|
+
"DeploymentConfigName": "test",
|
16
|
+
"MinimumHealthyHosts": {
|
17
|
+
"Type": "FLEET_PERCENT",
|
18
|
+
"Value": "75"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
EOS
|
24
|
+
assert_equal exp_template.chomp, act_template
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class CodedeployDeploymentGroupTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
deployment = { description: "test", revision: { s3: { bucket: "test", key: "test", version: "test" } } }
|
7
|
+
_codedeploy_deployment_group "test", ref_application: "test",
|
8
|
+
ref_autoscalings: %w( test ),
|
9
|
+
deployment: deployment,
|
10
|
+
ref_service: "test"
|
11
|
+
EOS
|
12
|
+
act_template = run_client_as_json(template)
|
13
|
+
exp_template = <<-EOS
|
14
|
+
{
|
15
|
+
"TestDeploymentGroup": {
|
16
|
+
"Type": "AWS::CodeDeploy::DeploymentGroup",
|
17
|
+
"Properties": {
|
18
|
+
"ApplicationName": {
|
19
|
+
"Ref": "TestCodedeployApplication"
|
20
|
+
},
|
21
|
+
"AutoScalingGroups": [
|
22
|
+
{
|
23
|
+
"Ref": "TestAutoscalingGroup"
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"Deployment": {
|
27
|
+
"Description": "test",
|
28
|
+
"IgnoreApplicationStopFailures": "true",
|
29
|
+
"Revision": {
|
30
|
+
"RevisionType": "S3",
|
31
|
+
"S3Location": {
|
32
|
+
"Bucket": "test",
|
33
|
+
"Key": "test",
|
34
|
+
"BundleType": "Zip",
|
35
|
+
"Version": "test"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
},
|
39
|
+
"ServiceRoleArn": {
|
40
|
+
"Ref": "TestServiceRole"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
EOS
|
46
|
+
assert_equal exp_template.chomp, act_template
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,358 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class DatapipelinePipelineTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
parameter_objects = [ { test: { attributes: { test: "test" } } } ]
|
7
|
+
parameter_values = { test: "test" }
|
8
|
+
fields = { test: { ref: "test", string: "test" } }
|
9
|
+
pipeline_objects = [ test: { name: "test", fields: fields } ]
|
10
|
+
pipeline_tags = { test: "test" }
|
11
|
+
_datapipeline_pipeline "test", parameter_objects: parameter_objects, parameter_values: parameter_values,
|
12
|
+
objects: pipeline_objects, tags: pipeline_tags
|
13
|
+
EOS
|
14
|
+
act_template = run_client_as_json(template)
|
15
|
+
exp_template = <<-EOS
|
16
|
+
{
|
17
|
+
"TestPipeline": {
|
18
|
+
"Type": "AWS::DataPipeline::Pipeline",
|
19
|
+
"Properties": {
|
20
|
+
"Activate": "true",
|
21
|
+
"Name": {
|
22
|
+
"Fn::Join": [
|
23
|
+
"-",
|
24
|
+
[
|
25
|
+
{
|
26
|
+
"Ref": "Service"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"Ref": "Name"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
]
|
33
|
+
},
|
34
|
+
"ParameterObjects": [
|
35
|
+
{
|
36
|
+
"Attributes": [
|
37
|
+
{
|
38
|
+
"Key": "test",
|
39
|
+
"StringValue": "test"
|
40
|
+
}
|
41
|
+
],
|
42
|
+
"Id": "test"
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"ParameterValues": [
|
46
|
+
{
|
47
|
+
"Id": "test",
|
48
|
+
"StringValue": "test"
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"PipelineObjects": [
|
52
|
+
{
|
53
|
+
"Fields": [
|
54
|
+
{
|
55
|
+
"Key": "test",
|
56
|
+
"RefValue": "test",
|
57
|
+
"StringValue": "test"
|
58
|
+
}
|
59
|
+
],
|
60
|
+
"Id": "test",
|
61
|
+
"Name": "test"
|
62
|
+
}
|
63
|
+
],
|
64
|
+
"PipelineTags": [
|
65
|
+
{
|
66
|
+
"Key": "test",
|
67
|
+
"Value": "test"
|
68
|
+
}
|
69
|
+
]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
EOS
|
74
|
+
assert_equal exp_template.chomp, act_template
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_aws
|
78
|
+
template = <<-'EOS'
|
79
|
+
description = "Pipeline to backup DynamoDB data to S3"
|
80
|
+
parameter_objects = [
|
81
|
+
{ "myDDBReadThroughputRatio": { attributes: { description: "DynamoDB read throughput ratio",
|
82
|
+
type: "Double",
|
83
|
+
default: 0.2 } } },
|
84
|
+
{ "myOutputS3Loc": { attributes: { description: "S3 output bucket",
|
85
|
+
type: "AWS::S3::ObjectKey",
|
86
|
+
default: _{ Fn__Join [ "", [ "s3://", _{ Ref "S3OutputLoc" } ] ] } } } },
|
87
|
+
{ "myDDBTableName": { attributes: { description: "DynamoDB Table Name",
|
88
|
+
type: "String" } } },
|
89
|
+
]
|
90
|
+
parameter_values = {
|
91
|
+
myDDBTableName: _{ Ref "TableName" }
|
92
|
+
}
|
93
|
+
fields1 = { type: { string: "S3DataNode" }, dataFormat: { ref: "DDBExportFormat"}, directoryPath: { string: '#{myOutputS3Loc}/#{format(@scheduledStartTime, \'YYYY-MM-dd-HH-mm-ss\')}' } }
|
94
|
+
fields2 = { type: { string: "DynamoDBDataNode" } , tableName: { string: '#{myDDBTableName}' }, dataFormat: { ref: "DDBExportFormat" }, readThroughputPercent: { string: '#{myDDBReadThroughputRatio}' } }
|
95
|
+
fields3 = { type: { string: "DynamoDBExportDataFormat" } }
|
96
|
+
fields4 = { type: { string: "HiveCopyActivity" }, resizeClusterBeforeRunning: { string: true }, input: { ref: "DDBSourceTable" }, runsOn: { ref: "EmrClusterForBackup" }, output: { ref: "S3BackupLocation" } }
|
97
|
+
fields5 = { type: { string: "Schedule" }, occurrences: { string: 1 }, startAt: { string: "FIRST_ACTIVATION_DATE_TIME" }, period: { string: "1 Day" } }
|
98
|
+
fields6 = { type: { string: "Default" }, scheduleType: { string: "cron" }, failureAndRerunMode: { string: "CASCADE" }, role: { string: "DataPipelineDefaultRole" }, resourceRole: { string: "DataPipelineDefaultResourceRole" }, schedule: { ref: "DefaultSchedule" } }
|
99
|
+
fields7 = { type: { string: "EmrCluster" }, terminateAfter: { string: "2 Hours" }, amiVersion: { string: "3.3.2" }, masterInstanceType: { string: "m1.medium" }, coreInstanceType: { string: "m1.medium" }, coreInstanceCount: { string: 1 } }
|
100
|
+
objects = [
|
101
|
+
{ S3BackupLocation: { name: "Copy data to this S3 location", fields: fields1 } },
|
102
|
+
{ DDBSourceTable: { name: "DDBSourceTable", fields: fields2 } },
|
103
|
+
{ DDBExportFormat: { name: "DDBExportFormat", fields: fields3 } },
|
104
|
+
{ TableBackupActivity: { name: "TableBackupActivity", fields: fields4 } },
|
105
|
+
{ DefaultSchedule: { name: "RunOnce", fields: fields5 } },
|
106
|
+
{ Default: { name: "Default", fields: fields6 } },
|
107
|
+
{ EmrClusterForBackup: { name: "EmrClusterForBackup" ,fields: fields7 } },
|
108
|
+
]
|
109
|
+
tags = []
|
110
|
+
_datapipeline_pipeline "dynamo d b input s3 output hive",
|
111
|
+
{ pl_name: "DynamoDBInputS3OutputHive",
|
112
|
+
description: description,
|
113
|
+
parameter_objects: parameter_objects, parameter_values: parameter_values,
|
114
|
+
objects: objects, tags: tags }
|
115
|
+
EOS
|
116
|
+
act_template = run_client_as_json(template)
|
117
|
+
exp_template = <<-'EOS'
|
118
|
+
{
|
119
|
+
"DynamoDBInputS3OutputHivePipeline": {
|
120
|
+
"Type": "AWS::DataPipeline::Pipeline",
|
121
|
+
"Properties": {
|
122
|
+
"Activate": "true",
|
123
|
+
"Description": "Pipeline to backup DynamoDB data to S3",
|
124
|
+
"Name": "DynamoDBInputS3OutputHive",
|
125
|
+
"ParameterObjects": [
|
126
|
+
{
|
127
|
+
"Attributes": [
|
128
|
+
{
|
129
|
+
"Key": "description",
|
130
|
+
"StringValue": "DynamoDB read throughput ratio"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"Key": "type",
|
134
|
+
"StringValue": "Double"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"Key": "default",
|
138
|
+
"StringValue": "0.2"
|
139
|
+
}
|
140
|
+
],
|
141
|
+
"Id": "myDDBReadThroughputRatio"
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"Attributes": [
|
145
|
+
{
|
146
|
+
"Key": "description",
|
147
|
+
"StringValue": "S3 output bucket"
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"Key": "type",
|
151
|
+
"StringValue": "AWS::S3::ObjectKey"
|
152
|
+
},
|
153
|
+
{
|
154
|
+
"Key": "default",
|
155
|
+
"StringValue": {
|
156
|
+
"Fn::Join": [
|
157
|
+
"",
|
158
|
+
[
|
159
|
+
"s3://",
|
160
|
+
{
|
161
|
+
"Ref": "S3OutputLoc"
|
162
|
+
}
|
163
|
+
]
|
164
|
+
]
|
165
|
+
}
|
166
|
+
}
|
167
|
+
],
|
168
|
+
"Id": "myOutputS3Loc"
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"Attributes": [
|
172
|
+
{
|
173
|
+
"Key": "description",
|
174
|
+
"StringValue": "DynamoDB Table Name"
|
175
|
+
},
|
176
|
+
{
|
177
|
+
"Key": "type",
|
178
|
+
"StringValue": "String"
|
179
|
+
}
|
180
|
+
],
|
181
|
+
"Id": "myDDBTableName"
|
182
|
+
}
|
183
|
+
],
|
184
|
+
"ParameterValues": [
|
185
|
+
{
|
186
|
+
"Id": "myDDBTableName",
|
187
|
+
"StringValue": {
|
188
|
+
"Ref": "TableName"
|
189
|
+
}
|
190
|
+
}
|
191
|
+
],
|
192
|
+
"PipelineObjects": [
|
193
|
+
{
|
194
|
+
"Fields": [
|
195
|
+
{
|
196
|
+
"Key": "type",
|
197
|
+
"StringValue": "S3DataNode"
|
198
|
+
},
|
199
|
+
{
|
200
|
+
"Key": "dataFormat",
|
201
|
+
"RefValue": "DDBExportFormat"
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"Key": "directoryPath",
|
205
|
+
"StringValue": "#{myOutputS3Loc}/#{format(@scheduledStartTime, 'YYYY-MM-dd-HH-mm-ss')}"
|
206
|
+
}
|
207
|
+
],
|
208
|
+
"Id": "S3BackupLocation",
|
209
|
+
"Name": "Copy data to this S3 location"
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"Fields": [
|
213
|
+
{
|
214
|
+
"Key": "type",
|
215
|
+
"StringValue": "DynamoDBDataNode"
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"Key": "tableName",
|
219
|
+
"StringValue": "#{myDDBTableName}"
|
220
|
+
},
|
221
|
+
{
|
222
|
+
"Key": "dataFormat",
|
223
|
+
"RefValue": "DDBExportFormat"
|
224
|
+
},
|
225
|
+
{
|
226
|
+
"Key": "readThroughputPercent",
|
227
|
+
"StringValue": "#{myDDBReadThroughputRatio}"
|
228
|
+
}
|
229
|
+
],
|
230
|
+
"Id": "DDBSourceTable",
|
231
|
+
"Name": "DDBSourceTable"
|
232
|
+
},
|
233
|
+
{
|
234
|
+
"Fields": [
|
235
|
+
{
|
236
|
+
"Key": "type",
|
237
|
+
"StringValue": "DynamoDBExportDataFormat"
|
238
|
+
}
|
239
|
+
],
|
240
|
+
"Id": "DDBExportFormat",
|
241
|
+
"Name": "DDBExportFormat"
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"Fields": [
|
245
|
+
{
|
246
|
+
"Key": "type",
|
247
|
+
"StringValue": "HiveCopyActivity"
|
248
|
+
},
|
249
|
+
{
|
250
|
+
"Key": "resizeClusterBeforeRunning",
|
251
|
+
"StringValue": "true"
|
252
|
+
},
|
253
|
+
{
|
254
|
+
"Key": "input",
|
255
|
+
"RefValue": "DDBSourceTable"
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"Key": "runsOn",
|
259
|
+
"RefValue": "EmrClusterForBackup"
|
260
|
+
},
|
261
|
+
{
|
262
|
+
"Key": "output",
|
263
|
+
"RefValue": "S3BackupLocation"
|
264
|
+
}
|
265
|
+
],
|
266
|
+
"Id": "TableBackupActivity",
|
267
|
+
"Name": "TableBackupActivity"
|
268
|
+
},
|
269
|
+
{
|
270
|
+
"Fields": [
|
271
|
+
{
|
272
|
+
"Key": "type",
|
273
|
+
"StringValue": "Schedule"
|
274
|
+
},
|
275
|
+
{
|
276
|
+
"Key": "occurrences",
|
277
|
+
"StringValue": "1"
|
278
|
+
},
|
279
|
+
{
|
280
|
+
"Key": "startAt",
|
281
|
+
"StringValue": "FIRST_ACTIVATION_DATE_TIME"
|
282
|
+
},
|
283
|
+
{
|
284
|
+
"Key": "period",
|
285
|
+
"StringValue": "1 Day"
|
286
|
+
}
|
287
|
+
],
|
288
|
+
"Id": "DefaultSchedule",
|
289
|
+
"Name": "RunOnce"
|
290
|
+
},
|
291
|
+
{
|
292
|
+
"Fields": [
|
293
|
+
{
|
294
|
+
"Key": "type",
|
295
|
+
"StringValue": "Default"
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"Key": "scheduleType",
|
299
|
+
"StringValue": "cron"
|
300
|
+
},
|
301
|
+
{
|
302
|
+
"Key": "failureAndRerunMode",
|
303
|
+
"StringValue": "CASCADE"
|
304
|
+
},
|
305
|
+
{
|
306
|
+
"Key": "role",
|
307
|
+
"StringValue": "DataPipelineDefaultRole"
|
308
|
+
},
|
309
|
+
{
|
310
|
+
"Key": "resourceRole",
|
311
|
+
"StringValue": "DataPipelineDefaultResourceRole"
|
312
|
+
},
|
313
|
+
{
|
314
|
+
"Key": "schedule",
|
315
|
+
"RefValue": "DefaultSchedule"
|
316
|
+
}
|
317
|
+
],
|
318
|
+
"Id": "Default",
|
319
|
+
"Name": "Default"
|
320
|
+
},
|
321
|
+
{
|
322
|
+
"Fields": [
|
323
|
+
{
|
324
|
+
"Key": "type",
|
325
|
+
"StringValue": "EmrCluster"
|
326
|
+
},
|
327
|
+
{
|
328
|
+
"Key": "terminateAfter",
|
329
|
+
"StringValue": "2 Hours"
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"Key": "amiVersion",
|
333
|
+
"StringValue": "3.3.2"
|
334
|
+
},
|
335
|
+
{
|
336
|
+
"Key": "masterInstanceType",
|
337
|
+
"StringValue": "m1.medium"
|
338
|
+
},
|
339
|
+
{
|
340
|
+
"Key": "coreInstanceType",
|
341
|
+
"StringValue": "m1.medium"
|
342
|
+
},
|
343
|
+
{
|
344
|
+
"Key": "coreInstanceCount",
|
345
|
+
"StringValue": "1"
|
346
|
+
}
|
347
|
+
],
|
348
|
+
"Id": "EmrClusterForBackup",
|
349
|
+
"Name": "EmrClusterForBackup"
|
350
|
+
}
|
351
|
+
]
|
352
|
+
}
|
353
|
+
}
|
354
|
+
}
|
355
|
+
EOS
|
356
|
+
assert_equal exp_template.chomp, act_template
|
357
|
+
end
|
358
|
+
end
|