template/master-fullstack-with-lambda-warmers.yaml [3199:3396]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Type: S3
      Stages:
        - Name: Source
          Actions:
            - Name: Source
              InputArtifacts: []
              ActionTypeId:
                Version: '1'
                Category: Source
                Owner: AWS
                Provider: CodeCommit
              Configuration:
                BranchName: master
                RepositoryName: !Sub '${ProjectName}-WebAssets'
              OutputArtifacts:
                - Name: !Sub '${ProjectName}-SourceArtifact'
        - Name: Build
          Actions:
            - Name: build-and-deploy
              InputArtifacts:
                - Name: !Sub '${ProjectName}-SourceArtifact'
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: '1'
                Provider: CodeBuild
              OutputArtifacts:
                - Name: !Sub '${ProjectName}-BuildArtifact'
              Configuration:
                ProjectName: !Sub '${ProjectName}-build'
              RunOrder: 1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: bd7060e4-3e26-442c-9c4e-141ca61a9590
    DependsOn:
      - PipelineArtifactsBucket
  SeederFunction:
    Properties:
      Code:
        S3Bucket: !FindInMap 
          - S3Buckets
          - !Ref 'AWS::Region'
          - SeederFunctionBucket
        S3Key: !FindInMap 
         - Constants
         - S3Keys
         - SeederFunctionCode
      Description: CodeCommit repository seeder
      Handler: seeder.SeedRepositoryHandler
      MemorySize: 3008
      Role:
        'Fn::GetAtt':
          - SeederRole
          - Arn
      Runtime: java8
      Timeout: 900
    Type: 'AWS::Lambda::Function'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 6b5081a3-db00-41db-a607-c9d5f98cf394
    DependsOn:
      - AssetsCodeRepository
  CreateESRole:
    Type: 'AWS::IAM::Role'
    Properties:
      RoleName: !Sub '${ProjectName}-CreateESRole'
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action:
              - 'sts:AssumeRole'
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
      Policies:
        - PolicyName: CreateRolePolicy
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - 'iam:CreateServiceLinkedRole'
                Resource: 'arn:aws:iam::*:role/aws-service-role/es.amazonaws.com/AWSServiceRoleForAmazonElasticsearchService'
  CreateESRoleFunction:
    Properties:
      Code:
        S3Bucket: !FindInMap 
          - S3Buckets
          - !Ref 'AWS::Region'
          - Bucket
        S3Key: !FindInMap 
          - Constants
          - S3Keys
          - CreateESRoleCode
      Description: Create Elasticsearch role
      Handler: index.handler
      Role:
        'Fn::GetAtt':
          - CreateESRole
          - Arn
      Runtime: nodejs8.10
      Timeout: 300
    Type: 'AWS::Lambda::Function'
  ESRoleCreator:
    Type: 'Custom::CustomResource'
    Properties:
      ServiceToken: !GetAtt CreateESRoleFunction.Arn
      ParameterOne: Parameter to pass into Custom Lambda Function
      DependsOn: CreateESRoleFunction
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 63b08124-fccb-4874-ab13-ce6cfe6ce885
  UpdateConfigFunction:
    Properties:
      Code:
        S3Bucket: !FindInMap 
          - S3Buckets
          - !Ref 'AWS::Region'
          - Bucket
        S3Key: !FindInMap 
          - Constants
          - S3Keys
          - UpdateConfigCode
      Description: Update config for CodeCommit repository
      Handler: index.handler
      Role:
        'Fn::GetAtt':
          - SeederRole
          - Arn
      Runtime: nodejs8.10
      Timeout: 300
      Environment:
        Variables:
          API_URL: !Sub 'https://${AppApi}.execute-api.${AWS::Region}.amazonaws.com/prod'
          BRANCH_NAME: master
          REGION: !Ref 'AWS::Region'
          REPOSITORY_NAME: !Sub '${ProjectName}-WebAssets'
          USER_POOL_ID: !Ref UserPool
          APP_CLIENT_ID: !Ref UserPoolClient
          IDENTITY_POOL_ID: !Ref IdentityPool
    Type: 'AWS::Lambda::Function'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 00cdcc4b-3885-4a51-bdad-776ac697419c
    DependsOn:
      - AssetsCodeRepository
      - SeederFunction
      - RepositorySeeder
      - AppApi
      - UserPool
      - UserPoolClient
      - IdentityPool
  SeederRole:
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action:
              - 'sts:AssumeRole'
            Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
        Version: 2012-10-17
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
      Policies:
        - PolicyDocument:
            Statement:
              - Action:
                  - 'codecommit:GetRepository'
                  - 'codecommit:GitPush'
                  - 'codecommit:GetBranch'
                  - 'codecommit:PutFile'
                Effect: Allow
                Resource: !GetAtt AssetsCodeRepository.Arn
            Version: 2012-10-17
          PolicyName: SeederRolePolicy
        - PolicyDocument:
            Statement:
              - Action:
                  - 'logs:*'
                Effect: Allow
                Resource: 'arn:aws:logs:*:*:*'
            Version: 2012-10-17
          PolicyName: LogsPolicy
    Type: 'AWS::IAM::Role'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: a10d77af-fa97-40ee-a6f0-5d9988792aeb
  RepositorySeeder:
    Properties:
      ServiceToken:
        'Fn::GetAtt':
          - SeederFunction
          - Arn
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



template/master-fullstack.yaml [2730:2927]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        Type: S3
      Stages:
        - Name: Source
          Actions:
            - Name: Source
              InputArtifacts: []
              ActionTypeId:
                Version: '1'
                Category: Source
                Owner: AWS
                Provider: CodeCommit
              Configuration:
                BranchName: master
                RepositoryName: !Sub '${ProjectName}-WebAssets'
              OutputArtifacts:
                - Name: !Sub '${ProjectName}-SourceArtifact'
        - Name: Build
          Actions:
            - Name: build-and-deploy
              InputArtifacts:
                - Name: !Sub '${ProjectName}-SourceArtifact'
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: '1'
                Provider: CodeBuild
              OutputArtifacts:
                - Name: !Sub '${ProjectName}-BuildArtifact'
              Configuration:
                ProjectName: !Sub '${ProjectName}-build'
              RunOrder: 1
    Metadata:
      'AWS::CloudFormation::Designer':
        id: bd7060e4-3e26-442c-9c4e-141ca61a9590
    DependsOn:
      - PipelineArtifactsBucket
  SeederFunction:
    Properties:
      Code:
        S3Bucket: !FindInMap
          - S3Buckets
          - !Ref 'AWS::Region'
          - SeederFunctionBucket
        S3Key: !FindInMap
         - Constants
         - S3Keys
         - SeederFunctionCode
      Description: CodeCommit repository seeder
      Handler: seeder.SeedRepositoryHandler
      MemorySize: 3008
      Role:
        'Fn::GetAtt':
          - SeederRole
          - Arn
      Runtime: java8
      Timeout: 900
    Type: 'AWS::Lambda::Function'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 6b5081a3-db00-41db-a607-c9d5f98cf394
    DependsOn:
      - AssetsCodeRepository
  CreateESRole:
    Type: 'AWS::IAM::Role'
    Properties:
      RoleName: !Sub '${ProjectName}-CreateESRole'
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action:
              - 'sts:AssumeRole'
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
      Policies:
        - PolicyName: CreateRolePolicy
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - 'iam:CreateServiceLinkedRole'
                Resource: 'arn:aws:iam::*:role/aws-service-role/es.amazonaws.com/AWSServiceRoleForAmazonElasticsearchService'
  CreateESRoleFunction:
    Properties:
      Code:
        S3Bucket: !FindInMap
          - S3Buckets
          - !Ref 'AWS::Region'
          - Bucket
        S3Key: !FindInMap
          - Constants
          - S3Keys
          - CreateESRoleCode
      Description: Create Elasticsearch role
      Handler: index.handler
      Role:
        'Fn::GetAtt':
          - CreateESRole
          - Arn
      Runtime: nodejs8.10
      Timeout: 300
    Type: 'AWS::Lambda::Function'
  ESRoleCreator:
    Type: 'Custom::CustomResource'
    Properties:
      ServiceToken: !GetAtt CreateESRoleFunction.Arn
      ParameterOne: Parameter to pass into Custom Lambda Function
      DependsOn: CreateESRoleFunction
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 63b08124-fccb-4874-ab13-ce6cfe6ce885
  UpdateConfigFunction:
    Properties:
      Code:
        S3Bucket: !FindInMap
          - S3Buckets
          - !Ref 'AWS::Region'
          - Bucket
        S3Key: !FindInMap
          - Constants
          - S3Keys
          - UpdateConfigCode
      Description: Update config for CodeCommit repository
      Handler: index.handler
      Role:
        'Fn::GetAtt':
          - SeederRole
          - Arn
      Runtime: nodejs8.10
      Timeout: 300
      Environment:
        Variables:
          API_URL: !Sub 'https://${AppApi}.execute-api.${AWS::Region}.amazonaws.com/prod'
          BRANCH_NAME: master
          REGION: !Ref 'AWS::Region'
          REPOSITORY_NAME: !Sub '${ProjectName}-WebAssets'
          USER_POOL_ID: !Ref UserPool
          APP_CLIENT_ID: !Ref UserPoolClient
          IDENTITY_POOL_ID: !Ref IdentityPool
    Type: 'AWS::Lambda::Function'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 00cdcc4b-3885-4a51-bdad-776ac697419c
    DependsOn:
      - AssetsCodeRepository
      - SeederFunction
      - RepositorySeeder
      - AppApi
      - UserPool
      - UserPoolClient
      - IdentityPool
  SeederRole:
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action:
              - 'sts:AssumeRole'
            Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
        Version: 2012-10-17
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
      Policies:
        - PolicyDocument:
            Statement:
              - Action:
                  - 'codecommit:GetRepository'
                  - 'codecommit:GitPush'
                  - 'codecommit:GetBranch'
                  - 'codecommit:PutFile'
                Effect: Allow
                Resource: !GetAtt AssetsCodeRepository.Arn
            Version: 2012-10-17
          PolicyName: SeederRolePolicy
        - PolicyDocument:
            Statement:
              - Action:
                  - 'logs:*'
                Effect: Allow
                Resource: 'arn:aws:logs:*:*:*'
            Version: 2012-10-17
          PolicyName: LogsPolicy
    Type: 'AWS::IAM::Role'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: a10d77af-fa97-40ee-a6f0-5d9988792aeb
  RepositorySeeder:
    Properties:
      ServiceToken:
        'Fn::GetAtt':
          - SeederFunction
          - Arn
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



