aws-must-templates 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +390 -0
  3. data/lib/aws-must-templates.rb +2 -0
  4. data/lib/tasks/cross-ref.rb +78 -0
  5. data/lib/tasks/suite.rake +292 -0
  6. data/lib/test-suites/test_suites.rb +115 -0
  7. data/mustache/commonCfnSignal.mustache +34 -0
  8. data/mustache/commonCreationPolicy.mustache +33 -0
  9. data/mustache/commonDependsOn.mustache +25 -0
  10. data/mustache/commonInstanceType.mustache +27 -0
  11. data/mustache/commonKeyValue.mustache +28 -0
  12. data/mustache/commonStackRef.mustache +23 -0
  13. data/mustache/commonValue.mustache +34 -0
  14. data/mustache/initializeCFinit.mustache +27 -0
  15. data/mustache/initializeCFtools.mustache +27 -0
  16. data/mustache/initializeCfnInitHupFiles.mustache +85 -0
  17. data/mustache/initializeInstallAwsCli.mustache +32 -0
  18. data/mustache/initializeInstallChef.mustache +37 -0
  19. data/mustache/initializeProvisionChefZero.mustache +36 -0
  20. data/mustache/initializeStartCfnHup.mustache +25 -0
  21. data/mustache/mapping.mustache +27 -0
  22. data/mustache/mappingSubnetConfig.mustache +27 -0
  23. data/mustache/mappings.mustache +71 -0
  24. data/mustache/output.mustache +38 -0
  25. data/mustache/parameter.mustache +35 -0
  26. data/mustache/resource.mustache +51 -0
  27. data/mustache/resourceInstance.mustache +52 -0
  28. data/mustache/resourceInstanceInitialize.mustache +120 -0
  29. data/mustache/resourceInstanceMetadata.mustache +65 -0
  30. data/mustache/resourceInstanceProfile.mustache +34 -0
  31. data/mustache/resourceInternetGateway.mustache +87 -0
  32. data/mustache/resourcePolicy.mustache +50 -0
  33. data/mustache/resourceProvisionChef.mustache +38 -0
  34. data/mustache/resourceRole.mustache +40 -0
  35. data/mustache/resourceS3Bucket.mustache +39 -0
  36. data/mustache/resourceSecurityGroup.mustache +46 -0
  37. data/mustache/resourceStack.mustache +45 -0
  38. data/mustache/resourceSubnet.mustache +41 -0
  39. data/mustache/resourceUser.mustache +58 -0
  40. data/mustache/resourceVPC.mustache +44 -0
  41. data/mustache/resourceWait.mustache +39 -0
  42. data/mustache/resources.mustache +65 -0
  43. data/mustache/root.mustache +244 -0
  44. data/mustache/tag.mustache +27 -0
  45. data/pics/test-suites.jpg +0 -0
  46. metadata +146 -0
@@ -0,0 +1,85 @@
1
+
2
+ {{!
3
+
4
+
5
+ +++start+++
6
+
7
+ ## <a id="initializeCfnInitHupFiles.mustache"></a>initializeCfnInitHupFiles.mustache <a class='navigator' href='#top'>[top]</a>
8
+
9
+ Cfn-init configuration to create files needed by
10
+ cfn-hup. Confiugration defines polling interval, CloudFormation path
11
+ to monitor, action to take, and the credentials needed for the
12
+ operation.
13
+
14
+
15
+ **Attributes**:
16
+
17
+ * `CfnUserKey`: reference name to user to retrieve `AWSAccessKeyId`
18
+ and `AWSSecretKey` in `/etc/cfn/cfn-credentials`
19
+ * `CfnResource` : resource which cfn-hup monitors for changes in `Metadata.cfn-hup`
20
+ * `CfnAction` : actions to trigger, when cfn-hup triggered, possibly starting `CfScript`
21
+ * `CfnScript` : script code for CfnAction (optional)
22
+
23
+ +++close+++
24
+
25
+ }}
26
+
27
+ {{! +++fold-on+++ }}
28
+
29
+
30
+ "/etc/cfn/cfn-hup.conf":{
31
+ "content":{
32
+ "Fn::Join":["", [
33
+ "[main]\n",
34
+ "stack=", {"Ref":"AWS::StackName"}, "\n",
35
+ "credential-file=/etc/cfn/cfn-credentials\n",
36
+ "interval=1\n",
37
+ "region=", {"Ref":"AWS::Region"}, "\n"
38
+ ]]
39
+ },
40
+ "mode":"000400",
41
+ "owner":"root",
42
+ "group":"root"
43
+ }
44
+
45
+ , "/etc/cfn/cfn-credentials":{
46
+ "content":{
47
+ "Fn::Join":["", [
48
+ "AWSAccessKeyId=", {"Ref":"{{CfnUserKey}}"}, "\n",
49
+ "AWSSecretKey=", {"Fn::GetAtt":["{{CfnUserKey}}", "SecretAccessKey"]}, "\n"
50
+ ]]
51
+ },
52
+ "mode":"000400",
53
+ "owner":"root",
54
+ "group":"root"
55
+ }
56
+
57
+ , "/etc/cfn/hooks.d/cfn-auto-reloader.conf":{
58
+ "content":{
59
+ "Fn::Join":["", [
60
+ "[cfn-auto-reloader-hook]\n",
61
+ "triggers=post.update\n",
62
+ "path=Resources.{{CfnResource}}.Metadata.CfnHup\n",
63
+ "action={{CfnAction}}\n",
64
+ "runas=root\n"
65
+ ]]
66
+ }
67
+ }
68
+
69
+ {{# CfnScript.length }}
70
+ , "{{CfnAction}}":{
71
+ "content":{
72
+ "Fn::Join":["", [ {{# CfnScript }}"{{{.}}}\n",
73
+ {{/ CfnScript }}
74
+ "\n"
75
+ ]]
76
+ },
77
+ "mode":"000555",
78
+ "owner":"root",
79
+ "group":"root"
80
+
81
+ }
82
+ {{/ CfnScript.length }}
83
+
84
+
85
+ {{! +++fold-off+++ }}
@@ -0,0 +1,32 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+
7
+ ## <a id="initializeInstallAwsCli.mustache"></a>initializeInstallAwsCli.mustache<a class='navigator' href='#top'> [top]</a>
8
+
9
+ UserData -script to install AwsCli
10
+
11
+ **Attributes**: context= `./resources/Instance/InstallChef`
12
+
13
+ * None
14
+
15
+
16
+ +++close+++
17
+
18
+ }}
19
+
20
+
21
+ {{! +++fold-on+++ }}
22
+
23
+ , "TMP_ZIP=awscli-bundle.zip\n"
24
+ , "curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o $TMP_ZIP\n"
25
+ , "sudo apt-get install unzip\n"
26
+ , "unzip $TMP_ZIP -d /tmp\n"
27
+ , "cd /tmp\n"
28
+ , "sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws \n"
29
+ , "echo $(date): awscli installed successfully \n"
30
+
31
+
32
+ {{! +++fold-off+++ }}
@@ -0,0 +1,37 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+
7
+ ## <a id="initializeInstallChef.mustache"></a>initializeInstallChef.mustache<a class='navigator' href='#top'> [top]</a>
8
+
9
+ UserData -script to install Chef
10
+
11
+ **Attributes**:
12
+
13
+ * `Version`: Chef version to install
14
+
15
+ +++close+++
16
+
17
+ }}
18
+
19
+ {{! +++fold-on+++ }}
20
+
21
+ {{# Version}}
22
+ {{# Ref}}
23
+ , "CHEF_VERSION='", { "Ref": "{{Ref}}" }, "'\n"
24
+ {{/ Ref}}
25
+ {{^ Ref}}
26
+ , "CHEF_VERSION={{Version}}\n"
27
+ {{/ Ref}}
28
+ {{/ Version}}
29
+ , "echo $(date): starting to install chef \n"
30
+ , "curl -L https://www.chef.io/chef/install.sh | sudo bash -s -- -v $CHEF_VERSION \n"
31
+ , "echo $(date): chef installed successfully \n"
32
+
33
+
34
+
35
+
36
+
37
+ {{! +++fold-off+++ }}
@@ -0,0 +1,36 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+
7
+ ## <a id="initializeProvisionChefZero.mustache"></a>initializeProvisionChefZero.mustache<a class='navigator' href='#top'> [top]</a>
8
+
9
+ Read Chef kithen from S3 bucket && launch chef zero
10
+
11
+ **Attributes**: context= `./resources/Instance/LaunchChefZero`
12
+
13
+ * `BucketName`: S3 bucket containing kitchen to provision
14
+
15
+
16
+ +++close+++
17
+
18
+ }}
19
+
20
+ {{! +++fold-on+++ }}
21
+
22
+ , "KITCHEN=/tmp/setup\n"
23
+ , "echo $(date): copy s3 bucket {{BucketName}} to $KITCHEN \n"
24
+ , "aws s3 cp --recursive --region $(aws s3api get-bucket-location --bucket {{BucketName}} --output text) s3://{{BucketName}}/setup/ $KITCHEN\n"
25
+ , "echo $(date): install chef-zero \n"
26
+ , "sudo apt-get install -y chef-zero \n"
27
+ , "echo $(date): start ChefZero in the background\n"
28
+ , "chef-zero --host 0.0.0.0 -d\n"
29
+ , "echo $(date): upload kithchen \n"
30
+ , "cd $KITCHEN && knife upload .\n"
31
+ , "echo $(date): kitchen uploaded \n"
32
+
33
+
34
+
35
+
36
+ {{! +++fold-off+++ }}
@@ -0,0 +1,25 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+
7
+ ## <a id="initializeStartCfnHup.mustache"></a>initializeStartCfnHup.mustache<a class='navigator' href='#top'> [top]</a>
8
+
9
+ Launch cfn-hup helper, which is a daemon that detects changes in
10
+ resource metadata and runs user-specified actions when a change is
11
+ detected
12
+
13
+ **Attributes**:
14
+
15
+
16
+ +++close+++
17
+
18
+ }}
19
+
20
+
21
+ {{! +++fold-on+++ }}
22
+ , "cfn-hup \n"
23
+
24
+
25
+ {{! +++fold-off+++ }}
@@ -0,0 +1,27 @@
1
+ {{!
2
+
3
+ mapping.mustache
4
+
5
+ +++start+++
6
+
7
+ ## <a id="mapping.mustache"></a>mapping.mustache <a class='navigator' href='#top'>[top]</a>
8
+
9
+
10
+ Dispatches mapping sub-type templates based mapping Type propertys
11
+
12
+ **Attributes**: context= `./mappings`
13
+
14
+ * `SubnetConfig`:
15
+
16
+ +++close+++
17
+
18
+
19
+ }}
20
+
21
+
22
+ {{! +++fold-on+++ }}
23
+
24
+ {{# SubnetConfig }}{{> mappingSubnetConfig }}{{/ SubnetConfig }}
25
+
26
+
27
+ {{! +++fold-off+++ }}
@@ -0,0 +1,27 @@
1
+ {{!
2
+
3
+ +++start+++
4
+
5
+
6
+ ## <a id="mappingSubnetConfig.mustache"></a>mappingSubnetConfig.mustache <a class='navigator' href='#top'>[top]</a>
7
+
8
+ Creates a subnet config mapping to map VPC/Public/Private key to CIDR
9
+ subnet block.
10
+
11
+ **Attributes**:
12
+
13
+ * `Name`: of the mapping
14
+
15
+ +++close+++
16
+
17
+ }}
18
+
19
+ {{! +++fold-on+++ }}
20
+
21
+ "{{Name}}" : {
22
+ "VPC" : { "CIDR" : "10.44.0.0/16" },
23
+ "Public" : { "CIDR" : "10.44.0.0/24" },
24
+ "Private" : { "CIDR" : "10.44.1.0/24" }
25
+ }{{_comma}}
26
+
27
+ {{! +++fold-off+++ }}
@@ -0,0 +1,71 @@
1
+ {{!
2
+
3
+ +++start+++
4
+
5
+ ## <a id="mappings.mustache"></a>mappings.mustache <a class='navigator' href='#top'>[top]</a>
6
+
7
+
8
+ Create fixed lookup tables `AWSInstanceType2Arch` and
9
+ `AWSRegionArch2AMI` implementing the table below
10
+
11
+ <code><pre>
12
+ ap-northeast-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-90815290 hvm
13
+ ap-southeast-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-0accf458 hvm
14
+ ap-southeast-2 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-1dc8b127 hvm
15
+ cn-north-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-eae27fd3 hvm
16
+ eu-central-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-3248712f hvm
17
+ eu-west-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-d74437a0 hvm
18
+ sa-east-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-0f6ced12 hvm
19
+ us-east-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-83c525e8 hvm
20
+ us-gov-west-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-51513172 hvm
21
+ us-west-1 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-61b25925 hvm
22
+ us-west-2 trusty 14.04 LTS amd64 hvm:ebs-ssd 20150528 ami-57e8d767 hvm
23
+ </pre></code>
24
+
25
+
26
+ **Attributes**: context= `.`
27
+
28
+ * none
29
+
30
+
31
+ **Actions**:
32
+
33
+ * **AWSInstanceType2Arch**: fixed key/value mapping, currently only
34
+ **t2.micro** --> **64bit**
35
+
36
+ * **AWSRegionArch2AMI**: fixed key/value mapping created, currently
37
+ architectures only for **64bits**
38
+
39
+
40
+ +++close+++
41
+
42
+
43
+ ==================================================================
44
+ The template
45
+ ==================================================================
46
+
47
+ }}
48
+
49
+
50
+ {{! +++fold-on+++ }}
51
+
52
+ "AWSInstanceType2Arch" : {
53
+ "t2.micro" : { "Arch" : "64" }
54
+ },
55
+ "AWSRegionArch2AMI" : {
56
+ "ap-northeast-1" : { "64" : "ami-90815290" },
57
+ "ap-southeast-1" : { "64" : "ami-0accf458" },
58
+ "ap-southeast-2" : { "64" : "ami-1dc8b127" },
59
+ "cn-north-1" : { "64" : "ami-eae27fd3" },
60
+ "eu-central-1" : { "64" : "ami-3248712f" },
61
+ "eu-west-1" : { "64" : "ami-d74437a0" },
62
+ "sa-east-1" : { "64" : "ami-0f6ced12" },
63
+ "us-east-1" : { "64" : "ami-83c525e8" },
64
+ "us-west-1" : { "64" : "ami-61b25925" },
65
+ "us-gov-west-1" : { "64" : "ami-51513172" },
66
+ "us-west-2" : { "64" : "ami-57e8d767" }
67
+ }
68
+
69
+
70
+
71
+ {{! +++fold-off+++ }}
@@ -0,0 +1,38 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+ ## <a id="output.mustache"></a>output.mustache <a class='navigator' href='#top'>[top]</a>
7
+
8
+ Create one output entry to CloudFormation JSON output section
9
+
10
+ **Attributes**: context= `./outputs`
11
+
12
+ * `Name` : of the ouput entry
13
+ * `Description`: of the output entry
14
+ * one of **Value**, **Ref**, **Attr**
15
+ * `Value`: of the output parameter
16
+ * `Ref`: name of refernece
17
+ * `Attr`
18
+ * `Ref`: name of attribute reference
19
+ * `Name`: name of the attribute
20
+
21
+
22
+ +++close+++
23
+
24
+ }}
25
+
26
+ {{! +++fold-on+++ }}
27
+
28
+ "{{Name}}": {
29
+ "Description" : "{{Description}}"
30
+ {{#Value}}, "Value" : "{{Value}}"{{/Value}}
31
+ {{#Ref}}, "Value" : { "Ref" : "{{Ref}}" }{{/Ref}}
32
+ {{#Attr}}, "Value" : { "Fn::GetAtt" : [ "{{Ref}}", "{{Name}}" ] }{{/Attr}}
33
+ }{{_comma}}
34
+
35
+
36
+
37
+ {{! +++fold-off+++ }}
38
+
@@ -0,0 +1,35 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+ ## <a id="parameter.mustache"></a>parameter.mustache <a class='navigator' href='#top'>[top]</a>
7
+
8
+ Create one parameter entry to CloudFormation JSON parameter section
9
+
10
+ **Attributes**: context= `./parameters`
11
+
12
+ * `Name` : of the ouput entry
13
+ * `Description`: of the parameter entry
14
+ * One of
15
+ * `Value`: value of the parameter
16
+ * `NestedValue`:
17
+ * `Stack` : resource name of the nested stack
18
+ * `Output`: name of output variable in nested stack
19
+
20
+
21
+ +++close+++
22
+
23
+ }}
24
+
25
+
26
+
27
+ {{! +++fold-on+++ }}
28
+
29
+ "{{Name}}": {
30
+ "Description" : "{{Description}}{{^Description}}No description given{{/Description}}"
31
+ , "Type": "{{Type}}"
32
+ {{#Value}}, "Default" : "{{Value}}"{{/Value}}
33
+ }{{_comma}}
34
+
35
+ {{! +++fold-off+++ }}
@@ -0,0 +1,51 @@
1
+ {{!
2
+
3
+ resource.mustache
4
+
5
+ +++start+++
6
+
7
+ ## <a id="resource.mustache"></a>resource.mustache <a class='navigator' href='#top'>[top]</a>
8
+
9
+
10
+ Dispatches resource sub-type templates based resource Type propertys
11
+
12
+ **Attributes**: context= `./resources`
13
+
14
+ * `Instance`: sub-document defining an EC instance
15
+ * `SecurityGroup`: sub-document defining an <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html">AWS::EC2::SecurityGroup</a>
16
+ * `S3Bucket`:
17
+ * `Role`:
18
+ * `Policy`:
19
+ * `InstanceProfile`:
20
+ * `Stack`:
21
+ * `Wait`:
22
+ * `VPC`:
23
+ * `InternetGateway`:
24
+ * `Subnet`:
25
+ * `User`: creates [User](#resourceUser.mustache)
26
+
27
+
28
+ +++close+++
29
+
30
+
31
+ }}
32
+
33
+
34
+ {{! +++fold-on+++ }}
35
+
36
+ {{# Instance }}{{> resourceInstance}}{{/ Instance }}
37
+ {{# SecurityGroup }}{{> resourceSecurityGroup}}{{/ SecurityGroup }}
38
+ {{# S3Bucket }}{{> resourceS3Bucket }}{{/ S3Bucket }}
39
+ {{# Role }}{{> resourceRole }}{{/ Role }}
40
+ {{# Policy }}{{> resourcePolicy }}{{/ Policy }}
41
+ {{# InstanceProfile }}{{> resourceInstanceProfile }}{{/ InstanceProfile }}
42
+ {{# Stack }}{{> resourceStack }}{{/ Stack }}
43
+ {{# Wait }}{{> resourceWait }}{{/ Wait }}
44
+ {{# VPC }}{{> resourceVPC }}{{/ VPC }}
45
+ {{# Subnet }}{{> resourceSubnet }}{{/ Subnet }}
46
+ {{# InternetGateway }}{{> resourceInternetGateway }}{{/ InternetGateway }}
47
+ {{# User }}{{> resourceUser }}{{/ User }}
48
+
49
+
50
+
51
+ {{! +++fold-off+++ }}
@@ -0,0 +1,52 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+
7
+ ## <a id="resourceInstance.mustache"></a>resourceInstance.mustache <a class='navigator' href='#top'>[top]</a>
8
+
9
+ Create an EC2 instance
10
+
11
+ **Attributes**: context= `./resources/Instance`
12
+
13
+ * `Name`: name of the EC2 instance to create
14
+ * Instance type (mandatory)
15
+ * `InstanceType` : The instance type, such as t2.micro.
16
+ * `InstanceTyperef` : Reference to instance type
17
+ * `tags` : array of tag sub-documents for EC2 instance
18
+ * `SecurityGroupIds`: array of [commonValue.mustache](#commonValue.mustache)
19
+
20
+
21
+ +++close+++
22
+
23
+ }}
24
+
25
+ {{! +++fold-on+++ }}
26
+
27
+ "{{Name}}" : {
28
+ "Type" : "AWS::EC2::Instance"
29
+ {{> commonCreationPolicy }}
30
+ , "Metadata": {
31
+ {{> resourceInstanceMetadata }}
32
+
33
+ } {{! metadata }}
34
+ , "Properties" : {
35
+ "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
36
+ { "Fn::FindInMap" : [ "AWSInstanceType2Arch", {{> commonInstanceType }}, "Arch" ] } ] }
37
+ , "InstanceType" : {{> commonInstanceType}} {{! InstanceType OR InstanceTypeRef }}
38
+ , "Tags" : [ {{#tags}}{{>tag}}{{/tags}} ]
39
+ , "SecurityGroupIds" : [
40
+ {{# SecurityGroupIds }}
41
+ {{> commonValue }}{{_comma}}
42
+ {{/ SecurityGroupIds }}
43
+ ]
44
+ {{#IamInstanceProfile}}, "IamInstanceProfile" : { "Ref" : "{{IamInstanceProfile}}" }{{/ IamInstanceProfile}}
45
+ {{# SubnetId }}, "SubnetId": {{> commonValue }} {{/ SubnetId }}
46
+ {{#KeyName}}, "KeyName" : { "Ref" : "{{KeyName}}" }{{/KeyName}}
47
+ , "UserData": {{> resourceInstanceInitialize }}
48
+ }
49
+ }{{_comma}}
50
+
51
+
52
+ {{! +++fold-off+++ }}
@@ -0,0 +1,120 @@
1
+ {{!
2
+
3
+
4
+ +++start+++
5
+
6
+ ## <a id="resourceInstanceInitialize.mustache"></a>resourceInstanceInitialize.mustache <a class='navigator' href='#top'>[top]</a>
7
+
8
+ user-data script
9
+
10
+ **Attributes**:
11
+
12
+ * `CreationPolicy`: in the end send cfn-signal to `../Name` -resource in current stack
13
+ * `InitializeWait`: name of wait resource (for successfull script)
14
+ * `Initialize` : array of
15
+ * `InstallCFtools`:
16
+ * `ProvisionChef`:
17
+ * `InstallChef`: add UserData to install Chef
18
+ * `InstallAwsCli`: add UserData to install awscli
19
+ * `LaunchChefZero`:
20
+ * `StartCfnInit`: [Launch cfn-init](#initializeCFinit.mustache)
21
+ * `StartCfnHup`: [launch cfn-hup helper](#initializeStartCfnHup.mustache)
22
+
23
+
24
+ +++close+++
25
+
26
+ }}
27
+
28
+ {{! +++fold-on+++ }}
29
+
30
+
31
+ { "Fn::Base64": { "Fn::Join": [ "\n",
32
+ [
33
+ "#!/bin/bash\n"
34
+ , "set -x\n"
35
+ , "set -e\n"
36
+ , "set -o pipefail\n"
37
+ , "LOG=/tmp/install.log\n"
38
+ , "echo $(date): User data script started > $LOG\n"
39
+ , "echo $(date): User data script started\n"
40
+ , "function finish() {\n"
41
+ , " echo \"$(date): installation finished\" \n"
42
+ , " echo \"$(date): installation finished\" >> $LOG \n"
43
+ {{# CreationPolicy}}
44
+ , " STACK='", { "Ref" : "AWS::StackName" }, "'\n"
45
+ , " REGION='", { "Ref" : "AWS::Region" }, "'\n"
46
+ , " RESOURCE='{{Name}}'\n"
47
+ , " type cfn-signal && sudo cfn-signal --success true --reason \"UserData script success\" --stack $STACK --resource $RESOURCE --region $REGION \n"
48
+ {{/ CreationPolicy}}
49
+ {{# InitializeWait}}
50
+ , " HANDLE='", { "Ref" : "{{InitializeWait}}" }, "'\n"
51
+ , " type cfn-signal && sudo cfn-signal --success true --reason \"UserData script success\" $HANDLE \n"
52
+ {{/ InitializeWait}}
53
+
54
+ , "}\n"
55
+ , "function error() {\n"
56
+ , " local lineno=$1\n"
57
+ , " local error=1\n"
58
+ , " echo \"$(date): installation finished in ERROR $error on line $lineno\" \n"
59
+ , " echo \"$(date): installation finished in ERROR $error on line $lineno\" >> $LOG \n"
60
+ {{# CreationPolicy}}
61
+ , " STACK='", { "Ref" : "AWS::StackName" }, "'\n"
62
+ , " REGION='", { "Ref" : "AWS::Region" }, "'\n"
63
+ , " RESOURCE='{{Name}}'\n"
64
+ , " type cfn-signal && sudo cfn-signal --exit-code $error --reason \"installation finished in ERROR on line $lineno\" --stack $STACK --resource $RESOURCE --region $REGION \n"
65
+ {{/ CreationPolicy}}
66
+ {{# InitializeWait}}
67
+ , " HANDLE='", { "Ref" : "{{InitializeWait}}" }, "'\n"
68
+ , " type cfn-signal && sudo cfn-signal --exit-code $error --reason \"installation finished in ERROR on line $lineno\" $HANDLE \n"
69
+ {{/ InitializeWait}}
70
+ , " exit 1\n"
71
+ , "}\n"
72
+ , "trap finish EXIT\n"
73
+ , "trap 'error ${LINENO}' ERR\n"
74
+
75
+ {{! NOTICE: check for resourceInstanceMetadata.mustache }}
76
+
77
+
78
+ {{# Initialize}}
79
+ {{# InstallCFtools }}
80
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
81
+ , "echo Install Cloudformation tools \n"
82
+ {{> initializeCFtools }}
83
+ {{/ InstallCFtools }}
84
+ {{#ProvisionChef }}
85
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
86
+ , "echo Provision chef \n"
87
+ {{> initializeProvisionChef }}
88
+ {{/ ProvisionChef }}
89
+ {{#InstallAwsCli }}
90
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
91
+ , "echo Install AWS client tools \n"
92
+ {{> initializeInstallAwsCli }}
93
+ {{/ InstallAwsCli }}
94
+ {{#InstallChef }}
95
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
96
+ , "echo Install chef \n"
97
+ {{> initializeInstallChef }}
98
+ {{/ InstallChef }}
99
+ {{#LaunchChefZero }}
100
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
101
+ , "echo Lauch ChefZero \n"
102
+ {{> initializeProvisionChefZero }}
103
+ {{/ LaunchChefZero }}
104
+ {{# StartCfnInit }}
105
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
106
+ , "echo Start cfn-init \n"
107
+ {{> initializeCFinit }}
108
+ {{/ StartCfnInit }}
109
+ {{# StartCfnHup }}
110
+ , "echo \"$(date): ------------------------------------------------------------------\" \n"
111
+ , "echo Start cfn-hup \n"
112
+ {{> initializeStartCfnHup }}
113
+ {{/ StartCfnHup }}
114
+ {{/ Initialize}}
115
+ ]
116
+
117
+ ]}
118
+ }
119
+
120
+ {{! +++fold-off+++ }}