Is it possible to Add codeCommit this template?
raviitsoft opened this issue · 1 comments
Hi!
Can you help me! How can add codeCommit instead for GitHub?
this is my version of "deployment-pipeline.json" to work with codecommit:
{ "AWSTemplateFormatVersion": "2010-09-09", "Parameters": { "BranchName": { "Description": "CodeCommit branch name", "Type": "String" }, "RepositoryName": { "Description": "CodeCommit repository name", "Type": "String" }, "Cluster": { "Type": "String" }, "Service": { "Type": "String" } }, "Resources": { "CodeBuildServiceRole": { "Type": "AWS::IAM::Role", "Properties": { "Path": "/", "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "codebuild.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser" ], "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Resource": "*", "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "ecr:GetAuthorizationToken" ] }, { "Resource": { "Fn::Sub": "arn:aws:s3:::${ArtifactBucket}/*" }, "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:GetObjectVersion" ] } ] } } ] } }, "CodePipelineServiceRole": { "Type": "AWS::IAM::Role", "Properties": { "Path": "/", "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "codepipeline.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codecommit:CancelUploadArchive", "codecommit:GetBranch", "codecommit:GetCommit", "codecommit:GetUploadArchiveStatus", "codecommit:UploadArchive" ], "Resource": "*" }, { "Resource": [ { "Fn::Sub": "arn:aws:s3:::${ArtifactBucket}/*" } ], "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:GetObjectVersion", "s3:GetBucketVersioning" ] }, { "Resource": "*", "Effect": "Allow", "Action": [ "ecs:DescribeServices", "ecs:DescribeTaskDefinition", "ecs:DescribeTasks", "ecs:ListTasks", "ecs:RegisterTaskDefinition", "ecs:UpdateService", "codebuild:StartBuild", "codebuild:BatchGetBuilds", "iam:PassRole" ] } ] } } ] } }, "CloudWatchEvenServiceRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "events.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] }, "Path": "/", "Policies": [ { "PolicyName": "CloudWatchEventNestedAccessPolicy", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "codepipeline:StartPipelineExecution", "Resource": { "Fn::Sub": "arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${Pipeline}" } } ] } } ] } }, "AmazonCloudWatchEventRule": { "Type": "AWS::Events::Rule", "Properties": { "EventPattern": { "source": [ "aws.codecommit" ], "detail-type": [ "CodeCommit Repository State Change" ], "resources": [ { "Fn::Sub": "arn:aws:codecommit:${AWS::Region}:${AWS::AccountId}:${RepositoryName}" } ], "detail": { "event": [ "referenceCreated", "referenceUpdated" ], "referenceType": [ "branch" ], "referenceName": [ { "Ref": "BranchName" } ] } }, "Targets": [ { "Arn": { "Fn::Sub": "arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${Pipeline}" }, "RoleArn": { "Fn::GetAtt": [ "CloudWatchEvenServiceRole", "Arn" ] }, "Id": "codepipeline-AppPipeline" } ] } }, "ArtifactBucket": { "Type": "AWS::S3::Bucket", "DeletionPolicy": "Retain", "Properties": { "BucketName": { "Fn::Sub": "codepipeline-${AWS::Region}-${AWS::AccountId}" } } }, "CodeBuildProject": { "Type": "AWS::CodeBuild::Project", "Properties": { "Name": { "Ref": "AWS::StackName" }, "ServiceRole": { "Ref": "CodeBuildServiceRole" }, "Artifacts": { "Type": "CODEPIPELINE" }, "Source": { "Type": "CODEPIPELINE" }, "Environment": { "ComputeType": "BUILD_GENERAL1_SMALL", "Image": "aws/codebuild/docker:18.09.0", "Type": "LINUX_CONTAINER", "EnvironmentVariables": [ ] } } }, "Pipeline": { "Type": "AWS::CodePipeline::Pipeline", "Properties": { "Name": { "Fn::Sub": "${AWS::StackName}-${BranchName}" }, "RoleArn": { "Fn::GetAtt": [ "CodePipelineServiceRole", "Arn" ] }, "ArtifactStore": { "Type": "S3", "Location": { "Ref": "ArtifactBucket" } }, "Stages": [ { "Name": "Source", "Actions": [ { "Name": "App", "ActionTypeId": { "Category": "Source", "Owner": "AWS", "Version": 1, "Provider": "CodeCommit" }, "Configuration": { "BranchName": { "Ref": "BranchName" }, "RepositoryName": { "Ref": "RepositoryName" }, "PollForSourceChanges": false }, "OutputArtifacts": [ { "Name": "SourceOutput" } ], "RunOrder": 1 } ] }, { "Name": "Build", "Actions": [ { "Name": "Build", "ActionTypeId": { "Category": "Build", "Owner": "AWS", "Version": 1, "Provider": "CodeBuild" }, "Configuration": { "ProjectName": { "Ref": "CodeBuildProject" } }, "InputArtifacts": [ { "Name": "SourceOutput" } ], "OutputArtifacts": [ { "Name": "BuildOutput" } ], "RunOrder": 1 } ] }, { "Name": "Deploy", "Actions": [ { "Name": "Deploy", "ActionTypeId": { "Category": "Deploy", "Owner": "AWS", "Version": 1, "Provider": "ECS" }, "Configuration": { "ClusterName": { "Ref": "Cluster" }, "ServiceName": { "Ref": "Service" }, "FileName": "images.json" }, "InputArtifacts": [ { "Name": "BuildOutput" } ], "RunOrder": 1 } ] } ] } } }, "Outputs": { "PipelineUrl": { "Value": { "Fn::Sub": "https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${Pipeline}" } } } }