sdlf-utils/ingestion-examples/sqoop/sdlf-pipeline/nested-stacks/template-statemachine.yaml [1:218]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AWSTemplateFormatVersion: 2010-09-09
Description: CodePipeline templates for the Lambda functions

Parameters:
  pAppName:
    Type: String
  pArtifactoryStore:
    Type: String
  pBranchName:
    Type: String
  pBuildDatalakeLibrary:
    Type: AWS::SSM::Parameter::Value<String>
  pCloudWatchRepositoryTriggerRoleArn:
    Type: AWS::SSM::Parameter::Value<String>
  pCodePipelineRoleArn:
    Type: AWS::SSM::Parameter::Value<String>
  pDatasetBucket:
    Type: String
  pEnv:
    Type: String
  pKMSInfraKeyId:
    Type: AWS::SSM::Parameter::Value<String>
  pKMSDataKeyId:
    Type: AWS::SSM::Parameter::Value<String>
  pOrgName:
    Type: String
  pPipeline:
    Type: String
  pPermissionsBoundaryManagedPolicy:
    Type: AWS::SSM::Parameter::Value<String>
  pRepositoryName:
    Type: String
  pSNSTopic:
    Type: AWS::SSM::Parameter::Value<String>
  pSharedDevOpsAccountId:
    Type: String
  pStageBucket:
    Type: String
  pTeamName:
    Type: String
  pTransformValidateCodeBuildJob:
    Type: AWS::SSM::Parameter::Value<String>
  pEnableTracing:
    Type: String
  pEMRsubnet:
    Type: String
    Default: none

Resources:
  ######## STATE MACHINE PIPELINES ########
  rStateMachinePipeline:
    Type: AWS::CodePipeline::Pipeline
    Properties:
      RoleArn: !Ref pCodePipelineRoleArn
      Stages:
        -
          Name: Source
          Actions:
            -
              Name: Source
              RoleArn: !Sub arn:aws:iam::${pSharedDevOpsAccountId}:role/sdlf-cicd-team-codecommit-${pEnv}-${pTeamName}
              ActionTypeId:
                Category: Source
                Owner: AWS
                Version: '1'
                Provider: CodeCommit
              OutputArtifacts:
                - Name: SourceArtifact
              Configuration:
                RepositoryName: !Ref pRepositoryName
                BranchName: !Ref pBranchName
                PollForSourceChanges: false
              RunOrder: 1
        -
          Name: Build
          Actions:
            -
              Name: Build
              InputArtifacts:
              - Name: SourceArtifact
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: '1'
                Provider: CodeBuild
              OutputArtifacts:
                - Name: BuildArtifact
              Configuration:
                ProjectName: !Ref pTransformValidateCodeBuildJob
              RunOrder: 1
        -
          Name: Deploy
          Actions:
            -
              Name: Deploy
              InputArtifacts:
              - Name: BuildArtifact
              ActionTypeId:
                Category: Deploy
                Owner: AWS
                Version: '1'
                Provider: CloudFormation
              Configuration:
                ActionMode: CREATE_UPDATE
                Capabilities: CAPABILITY_IAM,CAPABILITY_AUTO_EXPAND,CAPABILITY_NAMED_IAM
                RoleArn: !Ref pCodePipelineRoleArn
                StackName: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}
                TemplateConfiguration: "BuildArtifact::tags.json"
                TemplatePath: "BuildArtifact::template.yaml"
                ParameterOverrides: !Sub
                - |+
                  {
                    "pDatasetBucket" : "${BucketName}",
                    "pStageBucket": "${StageBucket}",
                    "pApp": "${Application}",
                    "pOrg": "${Organization}",
                    "pTeamName": "${Team}",
                    "pPermissionsBoundaryManagedPolicy": "${PermissionsBoundary}",
                    "pPipeline": "${PipelineName}",
                    "pEnv": "${Environment}",
                    "pDatalakeLibLayer": "${DatalakeLayerArn}",
                    "pPipLibLayer": "${PipLayerArn}",
                    "pKMSInfraKeyId": "${KMSInfraKeyId}",
                    "pKMSDataKeyId": "${KMSDataKeyId}",
                    "pStatesExecutionRole": "${StatesExecutionRole}",
                    "pSNSTopic": "${SNSTopic}",
                    "pEnableTracing": "${EnableTracing}",
                    "pEMRsubnet": "${EMRsubnet}"
                  }
                - { "BucketName": !Ref pDatasetBucket,
                "StageBucket": !Ref pStageBucket,
                "Application": !Ref pAppName,
                "Organization": !Ref pOrgName,
                "Team": !Ref pTeamName,
                "PermissionsBoundary": !Ref pPermissionsBoundaryManagedPolicy,
                "PipelineName": !Ref pPipeline,
                "Environment": !Ref pEnv,
                "DatalakeLayerArn": !Sub "/SDLF/Lambda/${pTeamName}/LatestDatalakeLibraryLayer",
                "PipLayerArn": !Sub "/SDLF/Lambda/${pTeamName}/LatestDefaultPipLibraryLayer",
                "KMSInfraKeyId": !Ref pKMSInfraKeyId,
                "KMSDataKeyId": !Ref pKMSDataKeyId,
                "StatesExecutionRole": !Sub "/SDLF/IAM/${pTeamName}/StatesExecutionRoleArn",
                "SNSTopic": !Ref pSNSTopic,
                "EnableTracing": !Ref pEnableTracing,
                "EMRsubnet": !Ref pEMRsubnet}
              RunOrder: 1
      ArtifactStore:
        Type: S3
        EncryptionKey:
          Id: !Ref pKMSInfraKeyId
          Type: KMS
        Location: !Ref pArtifactoryStore

  rPipelineTriggerEventRule:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub "Run ${pTeamName} ${pPipeline} Pipeline on ${pRepositoryName} repository update"
      EventPattern:
        source:
          - aws.codecommit
        detail-type:
          - CodeCommit Repository State Change
        resources:
          - !Sub arn:aws:codecommit:${AWS::Region}:${pSharedDevOpsAccountId}:${pRepositoryName}
        detail:
          event:
            - referenceCreated
            - referenceUpdated
          referenceType:
            - branch
          referenceName:
            - !Ref pBranchName
      Targets:
        - Arn: !Sub arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${rStateMachinePipeline}
          Id: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}-trigger
          RoleArn: !Ref pCloudWatchRepositoryTriggerRoleArn

  rPipelineTriggerOnLayerUpdate:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub "Update ${pTeamName} ${pPipeline} Pipeline on layer update"
      EventPattern:
        source:
          - aws.codebuild
        detail-type:
          - CodeBuild Build State Change
        detail:
          build-status:
            - SUCCEEDED
          project-name:
            - !Ref pBuildDatalakeLibrary
      Targets:
        - Arn: !Sub arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${rStateMachinePipeline}
          Id: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}-update
          RoleArn: !Ref pCloudWatchRepositoryTriggerRoleArn

  rPipelineFailedRule:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub "Notify ${pTeamName} team of ${pPipeline} pipeline failure"
      EventPattern:
        source:
          - aws.codepipeline
        detail-type:
          - CodePipeline Pipeline Execution State Change
        detail:
          state:
            - FAILED
          pipeline:
            - !Ref rStateMachinePipeline
      State: ENABLED
      Targets:
        - Arn: !Ref pSNSTopic
          Id: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}-failure
          InputTransformer:
            InputTemplate: !Sub '"The Pipeline <pipeline> has failed. Go to https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${rStateMachinePipeline}"'
            InputPathsMap:
              pipeline: $.detail.pipeline
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



sdlf-utils/pipeline-examples/event-dataset-dependencies/sdlf-engineering-pipeline/nested-stacks/template-statemachine.yaml [1:218]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AWSTemplateFormatVersion: 2010-09-09
Description: CodePipeline templates for the Lambda functions

Parameters:
  pAppName:
    Type: String
  pArtifactoryStore:
    Type: String
  pBranchName:
    Type: String
  pBuildDatalakeLibrary:
    Type: AWS::SSM::Parameter::Value<String>
  pCloudWatchRepositoryTriggerRoleArn:
    Type: AWS::SSM::Parameter::Value<String>
  pCodePipelineRoleArn:
    Type: AWS::SSM::Parameter::Value<String>
  pDatasetBucket:
    Type: String
  pEnv:
    Type: String
  pKMSInfraKeyId:
    Type: AWS::SSM::Parameter::Value<String>
  pKMSDataKeyId:
    Type: AWS::SSM::Parameter::Value<String>
  pOrgName:
    Type: String
  pPipeline:
    Type: String
  pPermissionsBoundaryManagedPolicy:
    Type: AWS::SSM::Parameter::Value<String>
  pRepositoryName:
    Type: String
  pSNSTopic:
    Type: AWS::SSM::Parameter::Value<String>
  pSharedDevOpsAccountId:
    Type: String
  pStageBucket:
    Type: String
  pTeamName:
    Type: String
  pTransformValidateCodeBuildJob:
    Type: AWS::SSM::Parameter::Value<String>
  pEnableTracing:
    Type: String
  pEMRsubnet:
    Type: String
    Default: none

Resources:
  ######## STATE MACHINE PIPELINES ########
  rStateMachinePipeline:
    Type: AWS::CodePipeline::Pipeline
    Properties:
      RoleArn: !Ref pCodePipelineRoleArn
      Stages:
        -
          Name: Source
          Actions:
            -
              Name: Source
              RoleArn: !Sub arn:aws:iam::${pSharedDevOpsAccountId}:role/sdlf-cicd-team-codecommit-${pEnv}-${pTeamName}
              ActionTypeId:
                Category: Source
                Owner: AWS
                Version: '1'
                Provider: CodeCommit
              OutputArtifacts:
                - Name: SourceArtifact
              Configuration:
                RepositoryName: !Ref pRepositoryName
                BranchName: !Ref pBranchName
                PollForSourceChanges: false
              RunOrder: 1
        -
          Name: Build
          Actions:
            -
              Name: Build
              InputArtifacts:
              - Name: SourceArtifact
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: '1'
                Provider: CodeBuild
              OutputArtifacts:
                - Name: BuildArtifact
              Configuration:
                ProjectName: !Ref pTransformValidateCodeBuildJob
              RunOrder: 1
        -
          Name: Deploy
          Actions:
            -
              Name: Deploy
              InputArtifacts:
              - Name: BuildArtifact
              ActionTypeId:
                Category: Deploy
                Owner: AWS
                Version: '1'
                Provider: CloudFormation
              Configuration:
                ActionMode: CREATE_UPDATE
                Capabilities: CAPABILITY_IAM,CAPABILITY_AUTO_EXPAND,CAPABILITY_NAMED_IAM
                RoleArn: !Ref pCodePipelineRoleArn
                StackName: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}
                TemplateConfiguration: "BuildArtifact::tags.json"
                TemplatePath: "BuildArtifact::template.yaml"
                ParameterOverrides: !Sub
                - |+
                  {
                    "pDatasetBucket" : "${BucketName}",
                    "pStageBucket": "${StageBucket}",
                    "pApp": "${Application}",
                    "pOrg": "${Organization}",
                    "pTeamName": "${Team}",
                    "pPermissionsBoundaryManagedPolicy": "${PermissionsBoundary}",
                    "pPipeline": "${PipelineName}",
                    "pEnv": "${Environment}",
                    "pDatalakeLibLayer": "${DatalakeLayerArn}",
                    "pPipLibLayer": "${PipLayerArn}",
                    "pKMSInfraKeyId": "${KMSInfraKeyId}",
                    "pKMSDataKeyId": "${KMSDataKeyId}",
                    "pStatesExecutionRole": "${StatesExecutionRole}",
                    "pSNSTopic": "${SNSTopic}",
                    "pEnableTracing": "${EnableTracing}",
                    "pEMRsubnet": "${EMRsubnet}"
                  }
                - { "BucketName": !Ref pDatasetBucket,
                "StageBucket": !Ref pStageBucket,
                "Application": !Ref pAppName,
                "Organization": !Ref pOrgName,
                "Team": !Ref pTeamName,
                "PermissionsBoundary": !Ref pPermissionsBoundaryManagedPolicy,
                "PipelineName": !Ref pPipeline,
                "Environment": !Ref pEnv,
                "DatalakeLayerArn": !Sub "/SDLF/Lambda/${pTeamName}/LatestDatalakeLibraryLayer",
                "PipLayerArn": !Sub "/SDLF/Lambda/${pTeamName}/LatestDefaultPipLibraryLayer",
                "KMSInfraKeyId": !Ref pKMSInfraKeyId,
                "KMSDataKeyId": !Ref pKMSDataKeyId,
                "StatesExecutionRole": !Sub "/SDLF/IAM/${pTeamName}/StatesExecutionRoleArn",
                "SNSTopic": !Ref pSNSTopic,
                "EnableTracing": !Ref pEnableTracing,
                "EMRsubnet": !Ref pEMRsubnet}
              RunOrder: 1
      ArtifactStore:
        Type: S3
        EncryptionKey:
          Id: !Ref pKMSInfraKeyId
          Type: KMS
        Location: !Ref pArtifactoryStore

  rPipelineTriggerEventRule:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub "Run ${pTeamName} ${pPipeline} Pipeline on ${pRepositoryName} repository update"
      EventPattern:
        source:
          - aws.codecommit
        detail-type:
          - CodeCommit Repository State Change
        resources:
          - !Sub arn:aws:codecommit:${AWS::Region}:${pSharedDevOpsAccountId}:${pRepositoryName}
        detail:
          event:
            - referenceCreated
            - referenceUpdated
          referenceType:
            - branch
          referenceName:
            - !Ref pBranchName
      Targets:
        - Arn: !Sub arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${rStateMachinePipeline}
          Id: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}-trigger
          RoleArn: !Ref pCloudWatchRepositoryTriggerRoleArn

  rPipelineTriggerOnLayerUpdate:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub "Update ${pTeamName} ${pPipeline} Pipeline on layer update"
      EventPattern:
        source:
          - aws.codebuild
        detail-type:
          - CodeBuild Build State Change
        detail:
          build-status:
            - SUCCEEDED
          project-name:
            - !Ref pBuildDatalakeLibrary
      Targets:
        - Arn: !Sub arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${rStateMachinePipeline}
          Id: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}-update
          RoleArn: !Ref pCloudWatchRepositoryTriggerRoleArn

  rPipelineFailedRule:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub "Notify ${pTeamName} team of ${pPipeline} pipeline failure"
      EventPattern:
        source:
          - aws.codepipeline
        detail-type:
          - CodePipeline Pipeline Execution State Change
        detail:
          state:
            - FAILED
          pipeline:
            - !Ref rStateMachinePipeline
      State: ENABLED
      Targets:
        - Arn: !Ref pSNSTopic
          Id: !Sub sdlf-${pTeamName}-${pPipeline}-${pRepositoryName}-failure
          InputTransformer:
            InputTemplate: !Sub '"The Pipeline <pipeline> has failed. Go to https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${rStateMachinePipeline}"'
            InputPathsMap:
              pipeline: $.detail.pipeline
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



