AWSTemplateFormatVersion: 2010-09-09
Conditions:
  myCondition: !Equals [!Ref "AWS::Region", 'us-east-1']
Resources:
  TestPipeline:
    Type: AWS::CodePipeline::Pipeline
    Properties:
      Name: Test-pipeline
      ArtifactStore:
        Location: 'pipeline-bucket'
        Type: S3
      RoleArn: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/AWSCodePipelineRole"
      Stages:
        - Name: Source
          Actions:
            - Name: Github
              ActionTypeId:
                Category: Source
                Owner: ThirdParty
                Provider: GitHub
                Version: "1"
              OutputArtifacts:
                - Name: MyApp
              Configuration:
                Owner: aws-cloudformation
                Repo: cfn-python-lint
                PollForSourceChanges: true
                Branch: main
                OAuthToken: 'secret-token'
        - Name: Build
          Actions:
            - Name: CodeBuild
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: "1"
                Provider: CodeBuild
              Configuration:
                ProjectName: cfn-python-lint
              InputArtifacts:
              - Name: MyApp
        - Name: !ImportValue TestImport
          Actions:
          - Fn::If:
            - myCondition
            - Name: CodeBuild
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: !ImportValue Version  # doesn't fail on objects
                Provider: CodeBuild
              Configuration:
                ProjectName: cfn-python-lint
              InputArtifacts:
              - Name: MyApp
            - Name: CodeBuild
              ActionTypeId:
                Category: Build
                Owner: AWS
                Version: !ImportValue Version  # doesn't fail on objects
                Provider: CodeBuild
              Configuration:
                ProjectName: cfn-python-lint
              InputArtifacts:
              - Name: MyApp
