<commit_before>---
AWSTemplateFormatVersion: '2010-09-09'

# Any code, applications, scripts, templates, proofs of concept,
# documentation and other items are provided for illustration purposes only.
#
# Copyright 2017 Amazon Web Services
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.  # You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


Parameters:

  TemplateBucket:
    Type: String

  Repo404Branch:
    Type: String
    Default: "master"

  RepoPhpHelloBranch:
    Type: String
    Default: "master"

  Service404DesiredCount:
    Type: Number
    Default: 2

  ServicePhpHelloDesiredCount:
    Type: Number
    Default: 2

  GitHubToken:
    Type: String

  GitHubUser:
    Type: String
    Default: "rnzsgh"

  BuildDockerImage:
    Type: String
    Default: "aws/codebuild/docker:1.12.1"

  LogRetentionInDays:
    Type: Number
    Default: 7

Resources:

  Vpc:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/vpc.cfn.yml"

  CiRepository:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/ci-repository.cfn.yml"

  Bastion:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/bastion.cfn.yml"
      Parameters:
        VpcStackName: !GetAtt Vpc.Outputs.Name
    DependsOn:
      - Vpc

  ApplicationLoadBalancer:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/load-balancer.cfn.yml"
      Parameters:
        VpcStackName: !GetAtt Vpc.Outputs.Name
    DependsOn:
      - Vpc

  EcsCluster:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/ecs-cluster.cfn.yml"
      Parameters:
        VpcStackName: !GetAtt Vpc.Outputs.Name
        AlbStackName: !GetAtt ApplicationLoadBalancer.Outputs.Name
        BastionStackName: !GetAtt Bastion.Outputs.Name
    DependsOn:
      - Vpc
      - ApplicationLoadBalancer
      - Bastion

  SystemKinesis:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/system-kinesis.cfn.yml"

  TaskRoles:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/task-roles.cfn.yml"
      Parameters:
        SystemKinesisStackName: !GetAtt SystemKinesis.Outputs.Name
    DependsOn:
      - SystemKinesis

  Service404CiCd:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/deployment-pipeline.cfn.yml"
      Parameters:
        SystemKinesisStackName: !GetAtt SystemKinesis.Outputs.Name
        GitHubSourceRepo: 404
        GitHubBranch: !Ref Repo404Branch
        DesiredCount: !Ref Service404DesiredCount
        GitHubToken: !Ref GitHubToken
        GitHubUser: !Ref GitHubUser
        BuildDockerImage: !Ref BuildDockerImage
        TemplateBucket: !Ref TemplateBucket
        EcsClusterStackName: !GetAtt EcsCluster.Outputs.Name
        TaskRoleStackName: !GetAtt TaskRoles.Outputs.Name
        LogRetentionInDays: !Ref LogRetentionInDays
        VpcStackName: !GetAtt Vpc.Outputs.Name
        AlbStackName: !GetAtt ApplicationLoadBalancer.Outputs.Name
        CiRepositoryStackName: !GetAtt CiRepository.Outputs.Name
    DependsOn:
      - Vpc
      - CiRepository
      - ApplicationLoadBalancer
      - TaskRoles
      - EcsCluster

  ServicePhpHelloCiCd:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/deployment-pipeline.cfn.yml"
      Parameters:
        SystemKinesisStackName: !GetAtt SystemKinesis.Outputs.Name
        GitHubSourceRepo: php-hello
        GitHubBranch: !Ref RepoPhpHelloBranch
        DesiredCount: !Ref ServicePhpHelloDesiredCount
        GitHubToken: !Ref GitHubToken
        GitHubUser: !Ref GitHubUser
        BuildDockerImage: !Ref BuildDockerImage
        TemplateBucket: !Ref TemplateBucket
        EcsClusterStackName: !GetAtt EcsCluster.Outputs.Name
        TaskRoleStackName: !GetAtt TaskRoles.Outputs.Name
        LogRetentionInDays: !Ref LogRetentionInDays
        VpcStackName: !GetAtt Vpc.Outputs.Name
        AlbStackName: !GetAtt ApplicationLoadBalancer.Outputs.Name
        CiRepositoryStackName: !GetAtt CiRepository.Outputs.Name
    DependsOn:
      - Vpc
      - CiRepository
      - ApplicationLoadBalancer
      - TaskRoles
      - EcsCluster

Outputs:

  VpcStackName:
    Value: !GetAtt Vpc.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-vpc-stack-name"

  CiRepositoryStackName:
    Value: !GetAtt CiRepository.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-ci-repository-stack-name"

  BastionStackName:
    Value: !GetAtt Bastion.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-bastion-stack-name"

  ApplicationLoadBalancerStackName:
    Value: !GetAtt ApplicationLoadBalancer.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-alb-stack-name"

  EcsClusterStackName:
    Value: !GetAtt EcsCluster.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-ecs-cluster-stack-name"

  SystemKinesisStackName:
    Value: !GetAtt SystemKinesis.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-system-kinesis-stack-name"

  TaskRolesStackName:
    Value: !GetAtt TaskRoles.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-task-roles-stack-name"
<commit_msg>Pass the ssh key around<commit_after>---
AWSTemplateFormatVersion: '2010-09-09'

# Any code, applications, scripts, templates, proofs of concept,
# documentation and other items are provided for illustration purposes only.
#
# Copyright 2017 Amazon Web Services
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.  # You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


Parameters:

  TemplateBucket:
    Type: String

  Repo404Branch:
    Type: String
    Default: "master"

  RepoPhpHelloBranch:
    Type: String
    Default: "master"

  Service404DesiredCount:
    Type: Number
    Default: 2

  ServicePhpHelloDesiredCount:
    Type: Number
    Default: 2

  GitHubToken:
    Type: String

  GitHubUser:
    Type: String

  BuildDockerImage:
    Type: String
    Default: "aws/codebuild/docker:1.12.1"

  LogRetentionInDays:
    Type: Number
    Default: 7

  InstanceKeyName:
    Description: "EC2 key pair name for bastion host and ECS instance SSH access"
    Type: String
    MinLength: 1
    MaxLength: 255
    AllowedPattern: "[\\x20-\\x7E]*"
    ConstraintDescription: "Key pair name can contain only ASCII characters"

Resources:

  Vpc:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/vpc.cfn.yml"

  CiRepository:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/ci-repository.cfn.yml"

  Bastion:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/bastion.cfn.yml"
      Parameters:
        VpcStackName: !GetAtt Vpc.Outputs.Name
        InstanceKeyName: !Ref InstanceKeyName
    DependsOn:
      - Vpc

  ApplicationLoadBalancer:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/load-balancer.cfn.yml"
      Parameters:
        VpcStackName: !GetAtt Vpc.Outputs.Name
    DependsOn:
      - Vpc

  EcsCluster:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/ecs-cluster.cfn.yml"
      Parameters:
        VpcStackName: !GetAtt Vpc.Outputs.Name
        AlbStackName: !GetAtt ApplicationLoadBalancer.Outputs.Name
        BastionStackName: !GetAtt Bastion.Outputs.Name
        InstanceKeyName: !Ref InstanceKeyName
    DependsOn:
      - Vpc
      - ApplicationLoadBalancer
      - Bastion

  SystemKinesis:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/system-kinesis.cfn.yml"

  TaskRoles:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/task-roles.cfn.yml"
      Parameters:
        SystemKinesisStackName: !GetAtt SystemKinesis.Outputs.Name
    DependsOn:
      - SystemKinesis

  Service404CiCd:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/deployment-pipeline.cfn.yml"
      Parameters:
        SystemKinesisStackName: !GetAtt SystemKinesis.Outputs.Name
        GitHubSourceRepo: 404
        GitHubBranch: !Ref Repo404Branch
        DesiredCount: !Ref Service404DesiredCount
        GitHubToken: !Ref GitHubToken
        GitHubUser: !Ref GitHubUser
        BuildDockerImage: !Ref BuildDockerImage
        TemplateBucket: !Ref TemplateBucket
        EcsClusterStackName: !GetAtt EcsCluster.Outputs.Name
        TaskRoleStackName: !GetAtt TaskRoles.Outputs.Name
        LogRetentionInDays: !Ref LogRetentionInDays
        VpcStackName: !GetAtt Vpc.Outputs.Name
        AlbStackName: !GetAtt ApplicationLoadBalancer.Outputs.Name
        CiRepositoryStackName: !GetAtt CiRepository.Outputs.Name
    DependsOn:
      - Vpc
      - CiRepository
      - ApplicationLoadBalancer
      - TaskRoles
      - EcsCluster

  ServicePhpHelloCiCd:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub "https://s3.amazonaws.com/${TemplateBucket}/templates/deployment-pipeline.cfn.yml"
      Parameters:
        SystemKinesisStackName: !GetAtt SystemKinesis.Outputs.Name
        GitHubSourceRepo: php-hello
        GitHubBranch: !Ref RepoPhpHelloBranch
        DesiredCount: !Ref ServicePhpHelloDesiredCount
        GitHubToken: !Ref GitHubToken
        GitHubUser: !Ref GitHubUser
        BuildDockerImage: !Ref BuildDockerImage
        TemplateBucket: !Ref TemplateBucket
        EcsClusterStackName: !GetAtt EcsCluster.Outputs.Name
        TaskRoleStackName: !GetAtt TaskRoles.Outputs.Name
        LogRetentionInDays: !Ref LogRetentionInDays
        VpcStackName: !GetAtt Vpc.Outputs.Name
        AlbStackName: !GetAtt ApplicationLoadBalancer.Outputs.Name
        CiRepositoryStackName: !GetAtt CiRepository.Outputs.Name
    DependsOn:
      - Vpc
      - CiRepository
      - ApplicationLoadBalancer
      - TaskRoles
      - EcsCluster

Outputs:

  VpcStackName:
    Value: !GetAtt Vpc.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-vpc-stack-name"

  CiRepositoryStackName:
    Value: !GetAtt CiRepository.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-ci-repository-stack-name"

  BastionStackName:
    Value: !GetAtt Bastion.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-bastion-stack-name"

  ApplicationLoadBalancerStackName:
    Value: !GetAtt ApplicationLoadBalancer.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-alb-stack-name"

  EcsClusterStackName:
    Value: !GetAtt EcsCluster.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-ecs-cluster-stack-name"

  SystemKinesisStackName:
    Value: !GetAtt SystemKinesis.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-system-kinesis-stack-name"

  TaskRolesStackName:
    Value: !GetAtt TaskRoles.Outputs.Name
    Export:
      Name: !Sub "${AWS::StackName}-task-roles-stack-name"

{'fraction_non_alphanumeric': 0.0944944625926221, 'fraction_numerical': 0.008604892040474862, 'mean_word_length': 3.266485384092454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 18, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '3573129', 'n_tokens_mistral': 3975, 'n_tokens_neox': 3864, 'n_words': 829}