{
  "Resources": {
    "MyPipelineArtifactsBucket727923DD": {
      "Type": "AWS::S3::Bucket",
      "DeletionPolicy": "Retain"
    },
    "MyPipelineRoleC0D47CA4": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": "sts:AssumeRole",
              "Effect": "Allow",
              "Principal": {
                "Service": "codepipeline.amazonaws.com"
              }
            }
          ],
          "Version": "2012-10-17"
        }
      }
    },
    "MyPipelineRoleDefaultPolicy34F09EFA": {
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyDocument": {
          "Statement": [
            {
              "Action": [
                "s3:GetObject*",
                "s3:GetBucket*",
                "s3:List*",
                "s3:PutObject*",
                "s3:DeleteObject*",
                "s3:Abort*"
              ],
              "Effect": "Allow",
              "Resource": [
                {
                  "Fn::GetAtt": [
                    "MyPipelineArtifactsBucket727923DD",
                    "Arn"
                  ]
                },
                {
                  "Fn::Join": [
                    "",
                    [
                      {
                        "Fn::GetAtt": [
                          "MyPipelineArtifactsBucket727923DD",
                          "Arn"
                        ]
                      },
                      "/",
                      "*"
                    ]
                  ]
                }
              ]
            },
            {
              "Action": [
                "codecommit:GetBranch",
                "codecommit:GetCommit",
                "codecommit:UploadArchive",
                "codecommit:GetUploadArchiveStatus",
                "codecommit:CancelUploadArchive"
              ],
              "Effect": "Allow",
              "Resource": {
                "Fn::GetAtt": [
                  "CodeCommitRepoDC6A41F9",
                  "Arn"
                ]
              }
            },
            {
              "Action": [
                "codebuild:BatchGetBuilds",
                "codebuild:StartBuild",
                "codebuild:StopBuild"
              ],
              "Effect": "Allow",
              "Resource": {
                "Fn::GetAtt": [
                  "BuildProject097C5DB7",
                  "Arn"
                ]
              }
            }
          ],
          "Version": "2012-10-17"
        },
        "PolicyName": "MyPipelineRoleDefaultPolicy34F09EFA",
        "Roles": [
          {
            "Ref": "MyPipelineRoleC0D47CA4"
          }
        ]
      }
    },
    "MyPipelineAED38ECF": {
      "Type": "AWS::CodePipeline::Pipeline",
      "Properties": {
        "ArtifactStore": {
          "Location": {
            "Ref": "MyPipelineArtifactsBucket727923DD"
          },
          "Type": "S3"
        },
        "RoleArn": {
          "Fn::GetAtt": [
            "MyPipelineRoleC0D47CA4",
            "Arn"
          ]
        },
        "Stages": [
          {
            "Actions": [
              {
                "ActionTypeId": {
                  "Category": "Source",
                  "Owner": "AWS",
                  "Provider": "CodeCommit",
                  "Version": "1"
                },
                "Configuration": {
                  "RepositoryName": {
                    "Fn::GetAtt": [
                      "CodeCommitRepoDC6A41F9",
                      "Name"
                    ]
                  },
                  "BranchName": "master",
                  "PollForSourceChanges": true
                },
                "InputArtifacts": [],
                "Name": "CodeCommitSource",
                "OutputArtifacts": [
                  {
                    "Name": "Source"
                  }
                ],
                "RunOrder": 1
              }
            ],
            "Name": "Source"
          },
          {
            "Actions": [
              {
                "ActionTypeId": {
                  "Category": "Build",
                  "Owner": "AWS",
                  "Provider": "CodeBuild",
                  "Version": "1"
                },
                "Configuration": {
                  "ProjectName": {
                    "Ref": "BuildProject097C5DB7"
                  }
                },
                "InputArtifacts": [
                  {
                    "Name": "Source"
                  }
                ],
                "Name": "CodeBuildAction",
                "OutputArtifacts": [],
                "RunOrder": 1
              }
            ],
            "Name": "Build"
          }
        ]
      },
      "DependsOn": [
        "MyPipelineRoleC0D47CA4",
        "MyPipelineRoleDefaultPolicy34F09EFA"
      ]
    },
    "MyPipelineOnPipelineStateChangeA017E4B1": {
      "Type": "AWS::Events::Rule",
      "Properties": {
        "EventPattern": {
          "detail-type": [
            "CodePipeline Pipeline Execution State Change"
          ],
          "source": [
            "aws.codepipeline"
          ],
          "resources": [
            {
              "Fn::Join": [
                "",
                [
                  "arn",
                  ":",
                  {
                    "Ref": "AWS::Partition"
                  },
                  ":",
                  "codepipeline",
                  ":",
                  {
                    "Ref": "AWS::Region"
                  },
                  ":",
                  {
                    "Ref": "AWS::AccountId"
                  },
                  ":",
                  {
                    "Ref": "MyPipelineAED38ECF"
                  }
                ]
              ]
            }
          ]
        },
        "State": "ENABLED",
        "Targets": [
          {
            "Arn": {
              "Ref": "MyTopic86869434"
            },
            "Id": "MyTopic",
            "InputTransformer": {
              "InputPathsMap": {
                "pipeline": "$.detail.pipeline",
                "state": "$.detail.state"
              },
              "InputTemplate": "\"Pipeline <pipeline> changed state to <state>\""
            }
          }
        ]
      }
    },
    "MyPipelineOnSourceStateChange7DC39EE9": {
      "Type": "AWS::Events::Rule",
      "Properties": {
        "EventPattern": {
          "detail-type": [
            "CodePipeline Stage Execution State Change"
          ],
          "source": [
            "aws.codepipeline"
          ],
          "resources": [
            {
              "Fn::Join": [
                "",
                [
                  "arn",
                  ":",
                  {
                    "Ref": "AWS::Partition"
                  },
                  ":",
                  "codepipeline",
                  ":",
                  {
                    "Ref": "AWS::Region"
                  },
                  ":",
                  {
                    "Ref": "AWS::AccountId"
                  },
                  ":",
                  {
                    "Ref": "MyPipelineAED38ECF"
                  }
                ]
              ]
            }
          ],
          "detail": {
            "stage": [
              "Source"
            ]
          }
        },
        "State": "ENABLED",
        "Targets": [
          {
            "Arn": {
              "Ref": "MyTopic86869434"
            },
            "Id": "MyTopic"
          }
        ]
      }
    },
    "MyPipelineOnActionStateChange3B9E6332": {
      "Type": "AWS::Events::Rule",
      "Properties": {
        "EventPattern": {
          "detail-type": [
            "CodePipeline Stage Execution State Change"
          ],
          "source": [
            "aws.codepipeline"
          ],
          "resources": [
            {
              "Fn::Join": [
                "",
                [
                  "arn",
                  ":",
                  {
                    "Ref": "AWS::Partition"
                  },
                  ":",
                  "codepipeline",
                  ":",
                  {
                    "Ref": "AWS::Region"
                  },
                  ":",
                  {
                    "Ref": "AWS::AccountId"
                  },
                  ":",
                  {
                    "Ref": "MyPipelineAED38ECF"
                  }
                ]
              ]
            }
          ],
          "detail": {
            "stage": [
              "Source"
            ],
            "action": [
              "CodeCommitSource"
            ],
            "state": [
              "STARTED"
            ]
          }
        },
        "State": "ENABLED",
        "Targets": [
          {
            "Arn": {
              "Ref": "MyTopic86869434"
            },
            "Id": "MyTopic"
          }
        ]
      }
    },
    "CodeCommitRepoDC6A41F9": {
      "Type": "AWS::CodeCommit::Repository",
      "Properties": {
        "RepositoryName": "foo",
        "Triggers": []
      }
    },
    "BuildProjectRoleAA92C755": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": "sts:AssumeRole",
              "Effect": "Allow",
              "Principal": {
                "Service": "codebuild.amazonaws.com"
              }
            }
          ],
          "Version": "2012-10-17"
        }
      }
    },
    "BuildProjectRoleDefaultPolicy3E9F248C": {
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyDocument": {
          "Statement": [
            {
              "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
              ],
              "Effect": "Allow",
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn",
                      ":",
                      {
                        "Ref": "AWS::Partition"
                      },
                      ":",
                      "logs",
                      ":",
                      {
                        "Ref": "AWS::Region"
                      },
                      ":",
                      {
                        "Ref": "AWS::AccountId"
                      },
                      ":",
                      "log-group",
                      ":",
                      {
                        "Fn::Join": [
                          "",
                          [
                            "/aws/codebuild/",
                            {
                              "Ref": "BuildProject097C5DB7"
                            }
                          ]
                        ]
                      }
                    ]
                  ]
                },
                {
                  "Fn::Join": [
                    "",
                    [
                      {
                        "Fn::Join": [
                          "",
                          [
                            "arn",
                            ":",
                            {
                              "Ref": "AWS::Partition"
                            },
                            ":",
                            "logs",
                            ":",
                            {
                              "Ref": "AWS::Region"
                            },
                            ":",
                            {
                              "Ref": "AWS::AccountId"
                            },
                            ":",
                            "log-group",
                            ":",
                            {
                              "Fn::Join": [
                                "",
                                [
                                  "/aws/codebuild/",
                                  {
                                    "Ref": "BuildProject097C5DB7"
                                  }
                                ]
                              ]
                            }
                          ]
                        ]
                      },
                      ":*"
                    ]
                  ]
                }
              ]
            },
            {
              "Action": [
                "s3:GetObject*",
                "s3:GetBucket*",
                "s3:List*",
                "s3:PutObject*",
                "s3:DeleteObject*",
                "s3:Abort*"
              ],
              "Effect": "Allow",
              "Resource": [
                {
                  "Fn::GetAtt": [
                    "MyPipelineArtifactsBucket727923DD",
                    "Arn"
                  ]
                },
                {
                  "Fn::Join": [
                    "",
                    [
                      {
                        "Fn::GetAtt": [
                          "MyPipelineArtifactsBucket727923DD",
                          "Arn"
                        ]
                      },
                      "/",
                      "*"
                    ]
                  ]
                }
              ]
            }
          ],
          "Version": "2012-10-17"
        },
        "PolicyName": "BuildProjectRoleDefaultPolicy3E9F248C",
        "Roles": [
          {
            "Ref": "BuildProjectRoleAA92C755"
          }
        ]
      }
    },
    "BuildProject097C5DB7": {
      "Type": "AWS::CodeBuild::Project",
      "Properties": {
        "Source": {
          "Type": "CODEPIPELINE"
        },
        "Artifacts": {
          "Type": "CODEPIPELINE"
        },
        "ServiceRole": {
          "Fn::GetAtt": [
            "BuildProjectRoleAA92C755",
            "Arn"
          ]
        },
        "Environment": {
          "Type": "LINUX_CONTAINER",
          "PrivilegedMode": false,
          "Image": "aws/codebuild/ubuntu-base:14.04",
          "ComputeType": "BUILD_GENERAL1_SMALL"
        }
      }
    },
    "MyTopic86869434": {
      "Type": "AWS::SNS::Topic"
    },
    "MyTopicbenisraeBF3B2D80": {
      "Type": "AWS::SNS::Subscription",
      "Properties": {
        "Endpoint": "benisrae@amazon.com",
        "Protocol": "email",
        "TopicArn": {
          "Ref": "MyTopic86869434"
        }
      }
    },
    "MyTopicPolicy12A5EC17": {
      "Type": "AWS::SNS::TopicPolicy",
      "Properties": {
        "PolicyDocument": {
          "Statement": [
            {
              "Action": "sns:Publish",
              "Effect": "Allow",
              "Principal": {
                "Service": "events.amazonaws.com"
              },
              "Resource": {
                "Ref": "MyTopic86869434"
              },
              "Sid": "0"
            }
          ],
          "Version": "2012-10-17"
        },
        "Topics": [
          {
            "Ref": "MyTopic86869434"
          }
        ]
      }
    }
  }
}