<commit_before>{  
  "AWSTemplateFormatVersion":"2010-09-09",
  "Description":"Kubernetes AWS CloudFormation Sample Template: Create a Kubernetes cluster with an Amazon EC2 instance as the master node and an AutoScalingGroup with two more EC2 instances that join the Kubernetes cluster as nodes. The AMI is chosen based on the region in which the stack is run. This example creates an EC2 security group for all instances to give you SSH access. **WARNING** This template creates three Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template. **CREDIT** This template is provided courtesy of Heptio (https://www.heptio.com/), by <NAME> and <NAME>.",
  "Parameters":{  
    "KeyName":{  
      "Description":"Name of an existing EC2 KeyPair to enable SSH access to the instance",
      "Type":"AWS::EC2::KeyPair::KeyName",
      "ConstraintDescription":"must be the name of an existing EC2 KeyPair."
    },
    "ClusterKey":{  
      "Description":"Generate this key locally (requires Python) with: python -c 'import random; print \"%0x.%0x\" % (random.SystemRandom().getrandbits(3*8), random.SystemRandom().getrandbits(8*8))'",
      "Type":"String",
      "ConstraintDescription":"must be a secure string, which will be used as the key for this cluster, of the format <6 character string>.<16 character string>."
    },
    "InstanceType":{  
      "Description":"EC2 instance type for the cluster",
      "Type":"String",
      "Default":"t2.medium",
      "AllowedValues":[  
        "t1.micro",
        "t2.nano",
        "t2.micro",
        "t2.small",
        "t2.medium",
        "t2.large",
        "m1.small",
        "m1.medium",
        "m1.large",
        "m1.xlarge",
        "m2.xlarge",
        "m2.2xlarge",
        "m2.4xlarge",
        "m3.medium",
        "m3.large",
        "m3.xlarge",
        "m3.2xlarge",
        "m4.large",
        "m4.xlarge",
        "m4.2xlarge",
        "m4.4xlarge",
        "m4.10xlarge",
        "c1.medium",
        "c1.xlarge",
        "c3.large",
        "c3.xlarge",
        "c3.2xlarge",
        "c3.4xlarge",
        "c3.8xlarge",
        "c4.large",
        "c4.xlarge",
        "c4.2xlarge",
        "c4.4xlarge",
        "c4.8xlarge",
        "g2.2xlarge",
        "g2.8xlarge",
        "r3.large",
        "r3.xlarge",
        "r3.2xlarge",
        "r3.4xlarge",
        "r3.8xlarge",
        "i2.xlarge",
        "i2.2xlarge",
        "i2.4xlarge",
        "i2.8xlarge",
        "d2.xlarge",
        "d2.2xlarge",
        "d2.4xlarge",
        "d2.8xlarge",
        "hi1.4xlarge",
        "hs1.8xlarge",
        "cr1.8xlarge",
        "cc2.8xlarge",
        "cg1.4xlarge"
      ],
      "ConstraintDescription":"must be a valid EC2 instance type."
    },
    "SSHLocation":{  
      "Description":"The IP address range that can be used to SSH to the EC2 instances",
      "Type":"String",
      "MinLength":"9",
      "MaxLength":"18",
      "Default":"0.0.0.0/0",
      "AllowedPattern":"(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
      "ConstraintDescription":"must be a valid IP CIDR range of the form x.x.x.x/x."
    },
    "K8sNodeCapacity":{  
      "Default":"2",
      "Description":"The initial number of K8sServer instances",
      "Type":"Number",
      "MinValue":"1",
      "MaxValue":"3",
      "ConstraintDescription":"must be between 1 and 3 EC2 instances."
    }
  },
  "Mappings":{  
    "RegionMap":{  
      "ap-northeast-1":{  
        "64":"ami-18afc47f"
      },
      "ap-northeast-2":{  
        "64":"ami-93d600fd"
      },
      "ap-south-1":{  
        "64":"ami-dd3442b2"
      },
      "ap-southeast-1":{  
        "64":"ami-87b917e4"
      },
      "ap-southeast-2":{  
        "64":"ami-e6b58e85"
      },
      "ca-central-1":{  
        "64":"ami-7112a015"
      },
      "eu-central-1":{  
        "64":"ami-fe408091"
      },
      "eu-west-1":{  
        "64":"ami-ca80a0b9"
      },
      "eu-west-2":{  
        "64":"ami-ede2e889"
      },
      "sa-east-1":{  
        "64":"ami-e075ed8c"
      },
      "us-east-1":{  
        "64":"ami-9dcfdb8a"
      },
      "us-east-2":{  
        "64":"ami-fcc19b99"
      },
      "us-west-1":{  
        "64":"ami-b05203d0"
      },
      "us-west-2":{  
        "64":"ami-b2d463d2"
      }
    }
  },
  "Resources":{  
    "K8sMasterInstance":{  
      "Type":"AWS::EC2::Instance",
      "Properties":{  
        "InstanceType":{  
          "Ref":"InstanceType"
        },
        "KeyName":{  
          "Ref":"KeyName"
        },
        "SecurityGroups":[  
          "default",
          {  
            "Ref":"allow22"
          }
        ],
        "Tags":[  
          {  
            "Key":"Name",
            "Value":"k8s-master"
          }
        ],
        "UserData":{  
          "Fn::Base64":{  
            "Fn::Join":[  
              "",
              [  
                "#!/bin/bash -v\n",
                "# Get repository key\n",
                "curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -\n",
                "# Append key to sources file\n",
                "cat <<EOF > /etc/apt/sources.list.d/kubernetes.list\n",
                "deb http://apt.kubernetes.io/ kubernetes-xenial main\n",
                "EOF\n",
                "# Update package lists\n",
                "apt-get update\n",
                "# Install docker if you don't have it already.\n",
                "apt-get install -y docker.io\n",
                "# Install kubernetes tools\n",
                "apt-get install -y kubelet kubeadm kubectl kubernetes-cni\n",
                "# reset kubeadm (workaround for kubelet package presence)\n",
                "kubeadm reset\n",
                "# Initialize master node\n",
                "kubeadm init --token=",
                {  
                  "Ref":"ClusterKey"
                },
                "\n",
                "# Add-on for network Weave (https://github.com/weaveworks/weave-kube)\n",
                "# so pods can communicate\n",
                "kubectl apply -f https://git.io/weave-kube\n"
              ]
            ]
          }
        },
        "ImageId":{  
          "Fn::FindInMap":[  
            "RegionMap",
            {  
              "Ref":"AWS::Region"
            },
            "64"
          ]
        }
      }
    },
    "K8sNodeGroup":{  
      "Type":"AWS::AutoScaling::AutoScalingGroup",
      "Properties":{  
        "AvailabilityZones":{  
          "Fn::GetAZs":""
        },
        "DesiredCapacity":{  
          "Ref":"K8sNodeCapacity"
        },
        "LaunchConfigurationName":{  
          "Ref":"LaunchConfig"
        },
        "MinSize":"1",
        "MaxSize":"3",
        "Tags":[  
          {  
            "Key":"Name",
            "Value":"k8s-node",
            "PropagateAtLaunch":"true"
          }
        ]
      },
      "UpdatePolicy":{  
        "AutoScalingRollingUpdate":{  
          "MinInstancesInService":"1",
          "MaxBatchSize":"1"
        }
      }
    },
    "LaunchConfig":{  
      "Type":"AWS::AutoScaling::LaunchConfiguration",
      "Properties":{  
        "ImageId":{  
          "Fn::FindInMap":[  
            "RegionMap",
            {  
              "Ref":"AWS::Region"
            },
            "64"
          ]
        },
        "InstanceType":{  
          "Ref":"InstanceType"
        },
        "KeyName":{  
          "Ref":"KeyName"
        },
        "SecurityGroups":[  
          "default",
          {  
            "Ref":"allow22"
          }
        ],
        "UserData":{  
          "Fn::Base64":{  
            "Fn::Join":[  
              "",
              [  
                "#!/bin/bash -v\n",
                "# Get repository key\n",
                "curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -\n",
                "# Append key to sources file\n",
                "cat <<EOF > /etc/apt/sources.list.d/kubernetes.list\n",
                "deb http://apt.kubernetes.io/ kubernetes-xenial main\n",
                "EOF\n",
                "# Update package lists\n",
                "apt-get update\n",
                "# Install docker if you don't have it already.\n",
                "apt-get install -y docker.io\n",
                "# Install kubernetes tools\n",
                "apt-get install -y kubelet kubeadm kubectl kubernetes-cni\n",
                "# reset kubeadm (workaround for kubelet package presence)\n",
                "kubeadm reset\n",
                "# Join master node\n",
                "kubeadm join --token=",
                {  
                  "Ref":"ClusterKey"
                },
                " ",
                {  
                  "Fn::GetAtt":[  
                    "K8sMasterInstance",
                    "PrivateIp"
                  ]
                },
                "\n"
              ]
            ]
          }
        },
        "ImageId":{  
          "Fn::FindInMap":[  
            "RegionMap",
            {  
              "Ref":"AWS::Region"
            },
            "64"
          ]
        }
      }
    },
    "allow22":{  
      "Type":"AWS::EC2::SecurityGroup",
      "Properties":{  
        "GroupDescription":"Enable SSH access via port 22",
        "SecurityGroupIngress":[  
          {  
            "IpProtocol":"tcp",
            "FromPort":"22",
            "ToPort":"22",
            "CidrIp":{  
              "Ref":"SSHLocation"
            }
          }
        ]
      }
    }
  },
  "Outputs":{  
    "MasterInstanceId":{  
      "Description":"InstanceId of the master EC2 instance",
      "Value":{  
        "Ref":"K8sMasterInstance"
      }
    },
    "MasterAZ":{  
      "Description":"Availability Zone of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "AvailabilityZone"
        ]
      }
    },
    "MasterPublicDNS":{  
      "Description":"Public DNSName of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "PublicDnsName"
        ]
      }
    },
    "MasterPublicIP":{  
      "Description":"Public IP address of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "PublicIp"
        ]
      }
    },
    "MasterPrivateIP":{  
      "Description":"Private IP address of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "PrivateIp"
        ]
      }
    },
    "NodeGroupInstanceId":{  
      "Description":"InstanceId of the newly created NodeGroup",
      "Value":{  
        "Ref":"K8sNodeGroup"
      }
    },
    "ClusterKey":{  
      "Description":"Key that allows nodes to join this cluster; keep secret",
      "Value":{  
        "Ref":"ClusterKey"
      }
    }
  }
}<commit_msg>pretty outputs and auto recovery<commit_after>{  
  "AWSTemplateFormatVersion":"2010-09-09",
  "Description":"Kubernetes AWS CloudFormation Template: Create a Kubernetes cluster. The master node is an auto-recovering Amazon EC2 instance. Two more EC2 instances in an AutoScalingGroup join the Kubernetes cluster as nodes. The AMI is chosen based on the region in which the stack is run. This example creates an EC2 security group for all instances to give you SSH access. Next steps: http://jump.heptio.com/aws-qs-next **WARNING** This template creates three Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template. **CREDIT** This template is provided courtesy of Heptio (https://www.heptio.com/), by <NAME> and <NAME>.",
  "Parameters":{  
    "KeyName":{  
      "Description":"Existing EC2 KeyPair for SSH access",
      "Type":"AWS::EC2::KeyPair::KeyName",
      "ConstraintDescription":"must be the name of an existing EC2 KeyPair."
    },
    "ClusterKey":{  
      "Description":"Generate this key (requires Python): python -c 'import random; print \"%0x.%0x\" % (random.SystemRandom().getrandbits(3*8), random.SystemRandom().getrandbits(8*8))'",
      "Type":"String",
      "ConstraintDescription":"must be a secure string, which will be used as the key for this cluster, of the format <6 character string>.<16 character string>."
    },
    "InstanceType":{  
      "Description":"EC2 instance type for the cluster",
      "Type":"String",
      "Default":"t2.medium",
      "AllowedValues":[  
        "t1.micro",
        "t2.nano",
        "t2.micro",
        "t2.small",
        "t2.medium",
        "t2.large",
        "m1.small",
        "m1.medium",
        "m1.large",
        "m1.xlarge",
        "m2.xlarge",
        "m2.2xlarge",
        "m2.4xlarge",
        "m3.medium",
        "m3.large",
        "m3.xlarge",
        "m3.2xlarge",
        "m4.large",
        "m4.xlarge",
        "m4.2xlarge",
        "m4.4xlarge",
        "m4.10xlarge",
        "c1.medium",
        "c1.xlarge",
        "c3.large",
        "c3.xlarge",
        "c3.2xlarge",
        "c3.4xlarge",
        "c3.8xlarge",
        "c4.large",
        "c4.xlarge",
        "c4.2xlarge",
        "c4.4xlarge",
        "c4.8xlarge",
        "g2.2xlarge",
        "g2.8xlarge",
        "r3.large",
        "r3.xlarge",
        "r3.2xlarge",
        "r3.4xlarge",
        "r3.8xlarge",
        "i2.xlarge",
        "i2.2xlarge",
        "i2.4xlarge",
        "i2.8xlarge",
        "d2.xlarge",
        "d2.2xlarge",
        "d2.4xlarge",
        "d2.8xlarge",
        "hi1.4xlarge",
        "hs1.8xlarge",
        "cr1.8xlarge",
        "cc2.8xlarge",
        "cg1.4xlarge"
      ],
      "ConstraintDescription":"must be a valid EC2 instance type."
    },
    "SSHLocation":{  
      "Description":"IP address range that can be used to SSH to the EC2 instances",
      "Type":"String",
      "MinLength":"9",
      "MaxLength":"18",
      "Default":"0.0.0.0/0",
      "AllowedPattern":"(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
      "ConstraintDescription":"must be a valid IP CIDR range of the form x.x.x.x/x."
    },
    "K8sNodeCapacity":{  
      "Default":"2",
      "Description":"Initial number of nodes",
      "Type":"Number",
      "MinValue":"1",
      "MaxValue":"3",
      "ConstraintDescription":"must be between 1 and 3 EC2 instances."
    }
  },
  "Mappings":{  
    "RegionMap":{  
      "ap-northeast-1":{  
        "64":"ami-18afc47f"
      },
      "ap-northeast-2":{  
        "64":"ami-93d600fd"
      },
      "ap-south-1":{  
        "64":"ami-dd3442b2"
      },
      "ap-southeast-1":{  
        "64":"ami-87b917e4"
      },
      "ap-southeast-2":{  
        "64":"ami-e6b58e85"
      },
      "ca-central-1":{  
        "64":"ami-7112a015"
      },
      "eu-central-1":{  
        "64":"ami-fe408091"
      },
      "eu-west-1":{  
        "64":"ami-ca80a0b9"
      },
      "eu-west-2":{  
        "64":"ami-ede2e889"
      },
      "sa-east-1":{  
        "64":"ami-e075ed8c"
      },
      "us-east-1":{  
        "64":"ami-9dcfdb8a"
      },
      "us-east-2":{  
        "64":"ami-fcc19b99"
      },
      "us-west-1":{  
        "64":"ami-b05203d0"
      },
      "us-west-2":{  
        "64":"ami-b2d463d2"
      }
    }
  },
  "Resources":{  
    "K8sMasterInstance":{  
      "Type":"AWS::EC2::Instance",
      "Properties":{  
        "InstanceType":{  
          "Ref":"InstanceType"
        },
        "KeyName":{  
          "Ref":"KeyName"
        },
        "SecurityGroups":[  
          "default",
          {  
            "Ref":"allow22"
          }
        ],
        "Tags":[  
          {  
            "Key":"Name",
            "Value":"k8s-master"
          }
        ],
        "UserData":{  
          "Fn::Base64":{  
            "Fn::Join":[  
              "",
              [  
                "#!/bin/bash -v\n",
                "# Get repository key\n",
                "curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -\n",
                "# Append key to sources file\n",
                "cat <<EOF > /etc/apt/sources.list.d/kubernetes.list\n",
                "deb http://apt.kubernetes.io/ kubernetes-xenial main\n",
                "EOF\n",
                "# Update package lists\n",
                "apt-get update\n",
                "# Install docker if you don't have it already.\n",
                "apt-get install -y docker.io\n",
                "# Install kubernetes tools\n",
                "apt-get install -y kubelet kubeadm kubectl kubernetes-cni\n",
                "# reset kubeadm (workaround for kubelet package presence)\n",
                "kubeadm reset\n",
                "# Initialize master node\n",
                "kubeadm init --token=",
                {  
                  "Ref":"ClusterKey"
                },
                "\n",
                "# Add-on for network Weave (https://github.com/weaveworks/weave-kube)\n",
                "# so pods can communicate\n",
                "kubectl apply -f https://git.io/weave-kube\n"
              ]
            ]
          }
        },
        "ImageId":{  
          "Fn::FindInMap":[  
            "RegionMap",
            {  
              "Ref":"AWS::Region"
            },
            "64"
          ]
        }
      }
    },
    "RecoveryTestAlarm":{  
      "Type":"AWS::CloudWatch::Alarm",
      "Properties":{  
        "AlarmDescription":"Trigger a recovery when instance status check fails for 5 consecutive minutes.",
        "Namespace":"AWS/EC2",
        "MetricName":"StatusCheckFailed_System",
        "Statistic":"Minimum",
        "Period":"60",
        "EvaluationPeriods":"5",
        "ComparisonOperator":"GreaterThanThreshold",
        "Threshold":"0",
        "AlarmActions":[  
          {  
            "Fn::Join":[  
              "",
              [  
                "arn:aws:automate:",
                {  
                  "Ref":"AWS::Region"
                },
                ":ec2:recover"
              ]
            ]
          }
        ],
        "Dimensions":[  
          {  
            "Name":"InstanceId",
            "Value":{  
              "Ref":"K8sMasterInstance"
            }
          }
        ]
      }
    },
    "K8sNodeGroup":{  
      "Type":"AWS::AutoScaling::AutoScalingGroup",
      "Properties":{  
        "AvailabilityZones":{  
          "Fn::GetAZs":""
        },
        "DesiredCapacity":{  
          "Ref":"K8sNodeCapacity"
        },
        "LaunchConfigurationName":{  
          "Ref":"LaunchConfig"
        },
        "MinSize":"1",
        "MaxSize":"3",
        "Tags":[  
          {  
            "Key":"Name",
            "Value":"k8s-node",
            "PropagateAtLaunch":"true"
          }
        ]
      },
      "UpdatePolicy":{  
        "AutoScalingRollingUpdate":{  
          "MinInstancesInService":"1",
          "MaxBatchSize":"1"
        }
      }
    },
    "LaunchConfig":{  
      "Type":"AWS::AutoScaling::LaunchConfiguration",
      "Properties":{  
        "ImageId":{  
          "Fn::FindInMap":[  
            "RegionMap",
            {  
              "Ref":"AWS::Region"
            },
            "64"
          ]
        },
        "InstanceType":{  
          "Ref":"InstanceType"
        },
        "KeyName":{  
          "Ref":"KeyName"
        },
        "SecurityGroups":[  
          "default",
          {  
            "Ref":"allow22"
          }
        ],
        "UserData":{  
          "Fn::Base64":{  
            "Fn::Join":[  
              "",
              [  
                "#!/bin/bash -v\n",
                "# Get repository key\n",
                "curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -\n",
                "# Append key to sources file\n",
                "cat <<EOF > /etc/apt/sources.list.d/kubernetes.list\n",
                "deb http://apt.kubernetes.io/ kubernetes-xenial main\n",
                "EOF\n",
                "# Update package lists\n",
                "apt-get update\n",
                "# Install docker if you don't have it already.\n",
                "apt-get install -y docker.io\n",
                "# Install kubernetes tools\n",
                "apt-get install -y kubelet kubeadm kubectl kubernetes-cni\n",
                "# reset kubeadm (workaround for kubelet package presence)\n",
                "kubeadm reset\n",
                "# Join master node\n",
                "kubeadm join --token=",
                {  
                  "Ref":"ClusterKey"
                },
                " ",
                {  
                  "Fn::GetAtt":[  
                    "K8sMasterInstance",
                    "PrivateIp"
                  ]
                },
                "\n"
              ]
            ]
          }
        },
        "ImageId":{  
          "Fn::FindInMap":[  
            "RegionMap",
            {  
              "Ref":"AWS::Region"
            },
            "64"
          ]
        }
      }
    },
    "allow22":{  
      "Type":"AWS::EC2::SecurityGroup",
      "Properties":{  
        "GroupDescription":"Enable SSH access via port 22",
        "SecurityGroupIngress":[  
          {  
            "IpProtocol":"tcp",
            "FromPort":"22",
            "ToPort":"22",
            "CidrIp":{  
              "Ref":"SSHLocation"
            }
          }
        ]
      }
    }
  },
  "Outputs":{  
    "MasterInstanceId":{  
      "Description":"InstanceId of the master EC2 instance",
      "Value":{  
        "Ref":"K8sMasterInstance"
      }
    },
    "MasterAZ":{  
      "Description":"Availability Zone of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "AvailabilityZone"
        ]
      }
    },
    "MasterPublicDNS":{  
      "Description":"Public DNSName of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "PublicDnsName"
        ]
      }
    },
    "MasterPublicIP":{  
      "Description":"Public IP address of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "PublicIp"
        ]
      }
    },
    "MasterPrivateIP":{  
      "Description":"Private IP address of the master",
      "Value":{  
        "Fn::GetAtt":[  
          "K8sMasterInstance",
          "PrivateIp"
        ]
      }
    },
    "NodeGroupInstanceId":{  
      "Description":"InstanceId of the newly created NodeGroup",
      "Value":{  
        "Ref":"K8sNodeGroup"
      }
    },
    "ClusterKey":{  
      "Description":"Key that allows nodes to join this cluster; keep secret",
      "Value":{  
        "Ref":"ClusterKey"
      }
    },
    "JoinNodes":{  
      "Description":"Command to join more nodes to this cluster",
      "Value":{  
        "Fn::Join":[  
          "",
          [  
            "kubeadm join --token=",
            {  
              "Ref":"ClusterKey"
            },
            " ",
            {  
              "Fn::GetAtt":[  
                "K8sMasterInstance",
                "PrivateIp"
              ]
            }
          ]
        ]
      }
    },
    "NextSteps":{  
      "Description":"Verify your cluster and deploy a test application. Instructions at http://jump.heptio.com/aws-qs-next",
      "Value":"http://jump.heptio.com/aws-qs-next"
    }
  }
}
{'fraction_non_alphanumeric': 0.156906552094522, 'fraction_numerical': 0.025005370569280344, 'mean_word_length': 1.3575407677504305, 'pattern_counts': {'":': 348, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4803806', 'n_tokens_mistral': 7698, 'n_tokens_neox': 7241, 'n_words': 1300}