{"id":4063,"date":"2022-12-06T15:49:19","date_gmt":"2022-12-06T06:49:19","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/?p=4063"},"modified":"2022-12-06T15:49:19","modified_gmt":"2022-12-06T06:49:19","slug":"codecommit-multi-branch-trigger","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2022\/12\/06\/codecommit-multi-branch-trigger\/","title":{"rendered":"CodeCommit\u306e\u4efb\u610f\u30d6\u30e9\u30f3\u30c1\u306b\u5bfe\u3057\u3066CI\u5b9f\u884c\u3059\u308b\u57fa\u76e4\u3092AWS CDK\u3067\u4f5c\u3063\u3066\u307f\u305f"},"content":{"rendered":"

\u306f\u3058\u3081\u306b<\/h2>\n

CircleCI\u3084GitHub Actions\u306a\u3069\u3067\u306f\u7c21\u5358\u306a\u8a2d\u5b9a\u3092\u3059\u308b\u3060\u3051\u3067\u4efb\u610f\u306efeature\u30d6\u30e9\u30f3\u30c1\u306b\u5bfe\u3057\u3066\u81ea\u52d5\u3067CI\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002
\n\u4e00\u65b9\u3067AWS\u306e\u5404\u7a2e\u30b5\u30fc\u30d3\u30b9\u306e\u307f\u3067\u540c\u69d8\u306e\u3053\u3068\u3092\u5b9f\u73fe\u3057\u305f\u3044\u5834\u5408\u3001\u73fe\u72b6\u3067\u306f\u5e7e\u3064\u304b\u306e\u30de\u30cd\u30fc\u30b8\u30c9\u30b5\u30fc\u30d3\u30b9\u3092\u4f75\u305b\u3066\u4f5c\u308a\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002
\n\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\/\u6848\u4ef6\u306e\u90fd\u5408\u6b21\u7b2c\u3067\u306f\u3069\u3046\u3057\u3066\u3082AWS\u306e\u307f\u3057\u304b\u4f7f\u3048\u306a\u3044\u5834\u5408\u3082\u3042\u308a\u5f97\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3001\u4eca\u56de\u306fAWS\u306e\u5404\u7a2e\u30de\u30cd\u30fc\u30b8\u30c9\u30b5\u30fc\u30d3\u30b9\u306e\u307f\u3092\u5229\u7528\u3057\u3066CI\/CD\u3092\u5b9f\u73fe\u3059\u308b\u4e00\u4f8b\u3092\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

AWS CDK\u3068\u306f<\/h2>\n

\u69cb\u7bc9\u306b\u969b\u3057\u3066\u4eca\u56de\u306fAWS Cloud Development Kit (CDK) <\/a>\u3092\u5229\u7528\u3057\u307e\u3059\u3002
\nAWS CDK\u306fAWS\u304c\u516c\u5f0f\u306b\u958b\u767a\u3057\u3066\u3044\u308b\u5404\u7a2eAWS\u30b5\u30fc\u30d3\u30b9\u69cb\u7bc9\u7528\u306eIaC\u30c4\u30fc\u30eb\u3067\u3059\u3002
\n\u30b3\u30fc\u30c9\u306e\u8a18\u8ff0\u306b\u306fTypescript\u3084Python\u7b49\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u6642\u306b\u4f7f\u7528\u983b\u5ea6\u304c\u9ad8\u3044\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002
\nAWS CDK\u3067\u4f5c\u6210\u3055\u308c\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306fCloudFormation\u7d4c\u7531\u3067\u30c7\u30d7\u30ed\u30a4\u3055\u308c\u307e\u3059\u3002<\/p>\n

\u69cb\u6210<\/h2>\n

\"\"<\/p>\n

CodeCommit\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30d6\u30e9\u30f3\u30c1\u304c\u65b0\u305f\u306b\u4f5c\u6210\u307e\u305f\u306f\u524a\u9664\u3055\u308c\u308b\u3068EventBridge\u3067\u691c\u77e5\u3055\u308c\u308b\u3088\u3046\u306bRule\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002
\nEventBridge Rule\u3067\u306fTarget\u3068\u3057\u3066CodeBuild\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002
\n\u6307\u5b9a\u3055\u308c\u305fCodeBuild\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5185\u3067AWS CDK\u306e\u30c7\u30d7\u30ed\u30a4\u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u884c\u3055\u308c\u3001\u4f5c\u6210\u3055\u308c\u305ffeature\u30d6\u30e9\u30f3\u30c1\u5c02\u7528\u306eCodePipeline\u3092\u4f5c\u6210\u307e\u305f\u306f\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n

\u5b9f\u88c5\u5185\u5bb9<\/h2>\n

\u3053\u3053\u304b\u3089\u306f\u5b9f\u969b\u306e\u30b3\u30fc\u30c9\u3092\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

\u5171\u901a\u90e8\u5206<\/h3>\n

\u8907\u6570\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\/\u30ea\u30dd\u30b8\u30c8\u30ea\u5171\u901a\u3067\u4f7f\u3044\u307e\u308f\u305b\u308b\u5171\u901a\u90e8\u5206\u306eStack\u3067\u3059\u3002<\/p>\n

setup-pipeline-stack.ts<\/code><\/p>\n

import * as cdk from 'aws-cdk-lib';\nimport { Construct } from 'constructs';\nimport * as events from 'aws-cdk-lib\/aws-events';\nimport * as iam from 'aws-cdk-lib\/aws-iam';\nimport * as targets from "aws-cdk-lib\/aws-events-targets"\nimport * as s3 from "aws-cdk-lib\/aws-s3"\nimport * as codebuild from "aws-cdk-lib\/aws-codebuild"\nimport * as codecommit from "aws-cdk-lib\/aws-codecommit"\nimport {Duration} from "aws-cdk-lib";\n\nexport class SetupPipelineStack extends cdk.Stack {\n  constructor(scope: Construct, id: string, props?: cdk.StackProps) {\n    super(scope, id, props);\n\n    \/\/ CodePipline\u30b5\u30fc\u30d3\u30b9\u30ed\u30fc\u30eb\n    new iam.Role(this, 'CodePipelineRole', {\n      roleName: "PipelineRole",\n      assumedBy: new iam.ServicePrincipal('codepipeline.amazonaws.com'),\n      managedPolicies: [\n        iam.ManagedPolicy.fromAwsManagedPolicyName("AWSCodePipeline_FullAccess"),\n        iam.ManagedPolicy.fromAwsManagedPolicyName("AWSCodeCommitFullAccess"),\n        iam.ManagedPolicy.fromAwsManagedPolicyName("AWSCodeCommitFullAccess"),\n        iam.ManagedPolicy.fromAwsManagedPolicyName("AmazonS3FullAccess")\n      ]\n    })\n\n    \/\/ CodeBuild\u30b5\u30fc\u30d3\u30b9\u30ed\u30fc\u30eb\n    const codebuildRole = new iam.Role(this, 'CodeBuildRole', {\n      roleName: "CodeBuildRole",\n      assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),\n      managedPolicies: [\n        iam.ManagedPolicy.fromAwsManagedPolicyName("AdministratorAccess")\n      ]\n    })\n\n    \/\/ \u30a2\u30fc\u30c6\u30a3\u30d5\u30a1\u30af\u30c8\u7528S3\u30d0\u30b1\u30c3\u30c8\n    const bucket = new s3.Bucket(this, 'TemplateBucket', {\n      bucketName: `${cdk.Stack.of(this).account}-setup-pipeline-templates`\n    });\n    bucket.addToResourcePolicy(new iam.PolicyStatement({\n      effect: iam.Effect.ALLOW,\n      actions: ['s3:*'],\n      resources: [bucket.bucketArn,bucket.arnForObjects('*')],\n      principals: [new iam.AccountRootPrincipal()],\n    }));\n\n    \/\/ \u4efb\u610f\u306e\u30d6\u30e9\u30f3\u30c1\u304c\u4f5c\u6210\u30fb\u524a\u9664\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067CodePipeline\u306e\u4f5c\u6210\u30fb\u524a\u9664\u3092\u5b9f\u884c\u3059\u308bCodeBuild\n    const createCodePipelineCodebuild = new codebuild.Project(this,"CreateCodePipelineCodebuild", {\n      projectName: "SetupCodeBuild",\n      buildSpec: codebuild.BuildSpec.fromSourceFilename(".\/buildspecs\/PipelineCreationAction.yaml"),\n      source: codebuild.Source.codeCommit({\n        repository: codecommit.Repository.fromRepositoryArn(this,"CreateCodePipelineCodebuildSource",`arn:aws:codecommit:${cdk.Stack.of(this).region}:${cdk.Stack.of(this).account}:codecommit-multi-branch-trigger-test`),\n        branchOrRef: "refs\/heads\/main"\n      }),\n      environment: {\n        buildImage: codebuild.LinuxBuildImage.STANDARD_6_0,\n        computeType: codebuild.ComputeType.MEDIUM\n      },\n      role: codebuildRole,\n      timeout: Duration.minutes(15)\n    })\n\n    \/\/ \u30d6\u30e9\u30f3\u30c1\u4f5c\u6210\u30fb\u524a\u9664\u3092\u691c\u77e5\u3059\u308bEventBridge Rule\n    new events.Rule(this, 'CreatePipelineRule', {\n      ruleName: "SetupPipelineRule",\n      eventPattern: {\n        detail: {\n          event: ["referenceDeleted", "referenceCreated"],\n          referenceType: ["branch"],\n          repositoryName: ["sample-app"],\n          referenceName: [{ "anything-but": ["develop", "release"] }]\n        },\n        source: ['aws.codecommit'],\n      },\n      targets: [new targets.CodeBuildProject(createCodePipelineCodebuild, {\n         event: events.RuleTargetInput.fromObject(\n             {\n               "environmentVariablesOverride": [\n                 {\n                   "name":"BRANCH",\n                   "value":events.EventField.fromPath("$.detail.referenceName")\n                 },\n                 {\n                   "name":"REPO_NAME",\n                   "value":events.EventField.fromPath("$.detail.repositoryName")\n                 },\n                 {\n                   "name":"EVENT",\n                   "value":events.EventField.fromPath("$.detail.event")\n                 },\n                 {\n                   "name":"STACK_NAME",\n                   "value": `Pipeline-${events.EventField.fromPath("$.detail.repositoryName")}-${events.EventField.fromPath("$.detail.referenceName")}`\n                 },\n               ]\n             }\n         )\n      })],\n    })\n  }\n}<\/code><\/pre>\n

\u30ea\u30dd\u30b8\u30c8\u30ea\u4f5c\u6210 + \u958b\u767a\/\u672c\u756a\u7528\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u4f5c\u6210<\/h3>\n

CodeCommit\u30ea\u30dd\u30b8\u30c8\u30ea\u53ca\u3073\u958b\u767a\u74b0\u5883\u30fb\u672c\u756a\u74b0\u5883\u7528\u306eCodePipeline\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002
\n\u3053\u3053\u3067\u306f\u958b\u767a\u74b0\u5883\u306fdevelop\u30d6\u30e9\u30f3\u30c1\u3001\u672c\u756a\u74b0\u5883\u306frelease\u30d6\u30e9\u30f3\u30c1\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

repository-stack.ts<\/code><\/p>\n

import * as cdk from "aws-cdk-lib";\nimport {Construct} from "constructs";\nimport * as path from 'path';\nimport * as codecommit from "aws-cdk-lib\/aws-codecommit"\nimport * as codebuild from "aws-cdk-lib\/aws-codebuild"\nimport * as codepipeline from "aws-cdk-lib\/aws-codepipeline"\nimport * as codepipeline_actions from "aws-cdk-lib\/aws-codepipeline-actions"\nimport * as iam from "aws-cdk-lib\/aws-iam"\nimport * as s3 from "aws-cdk-lib\/aws-s3"\nimport {Duration} from "aws-cdk-lib";\n\ntype repositoryStack = {\n    repositoryName : string\n} & cdk.StackProps\n\nexport class RepositoryStack extends cdk.Stack {\n    constructor(scope: Construct, id: string, props: repositoryStack) {\n        super(scope, id, props);\n\n       \/\/ CodeCommit\u30ea\u30dd\u30b8\u30c8\u30ea\n        new codecommit.Repository(this, 'Repository', {\n            repositoryName: props.repositoryName,\n            code: codecommit.Code.fromDirectory(path.join(__dirname, '..\/buildspecs\/'), "develop"),\n        });\n\n        const sourceOutput = new codepipeline.Artifact('SourceArtifact');\n\n       \/\/ CodeBuild\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\n        const ciAction = new codebuild.PipelineProject(this, `CIActionBranch`, {\n            projectName: `CIAction-${props.repositoryName}`,\n            buildSpec: codebuild.BuildSpec.fromSourceFilename("CIAction.yaml"),\n            environment: {\n                buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0,\n                computeType: codebuild.ComputeType.SMALL\n            },\n            role: iam.Role.fromRoleArn(this, `CIActionServiceRole`, `arn:aws:iam::${cdk.Stack.of(this).account}:role\/CodeBuildRole`),\n            timeout: Duration.minutes(10),\n        });\n\n        const cdActionDev = new codebuild.PipelineProject(this, `CDActionDev`, {\n            projectName: `CDActionDev-${props.repositoryName}`,\n            buildSpec: codebuild.BuildSpec.fromSourceFilename("CDAction.yaml"),\n            environment: {\n                buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0,\n                computeType: codebuild.ComputeType.SMALL\n            },\n            environmentVariables: {\n                "pipeline_environment": {\n                    value: "DEV"\n                }},\n            role: iam.Role.fromRoleArn(this, "CDActionDevServiceRole", `arn:aws:iam::${cdk.Stack.of(this).account}:role\/CodeBuildRole`),\n            timeout: Duration.minutes(10)\n        });\n\n        const cdActionProd = new codebuild.PipelineProject(this, `CDActionProd`, {\n            projectName: `CDActionProd-${props.repositoryName}`,\n            buildSpec: codebuild.BuildSpec.fromSourceFilename("CDAction.yaml"),\n            environment: {\n                buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0,\n                computeType: codebuild.ComputeType.SMALL\n            },\n            environmentVariables: {\n                "pipeline_environment": {\n                    value: "PROD"\n                }},\n            role: iam.Role.fromRoleArn(this, "CDActionProdServiceRole", `arn:aws:iam::${cdk.Stack.of(this).account}:role\/CodeBuildRole`),\n            timeout: Duration.minutes(10)\n        });\n\n        \/\/ \u958b\u767a\u74b0\u5883\u30fb\u672c\u756a\u74b0\u5883\u7528CodePipeline\n        new codepipeline.Pipeline(this, 'DevPipeline', {\n            pipelineName: `${props.repositoryName}-develop`,\n            role: iam.Role.fromRoleArn(this, 'CodePipelineDevActionRole', `arn:aws:iam::${cdk.Stack.of(this).account}:role\/PipelineRole`),\n            artifactBucket: s3.Bucket.fromBucketName(this, "dev-artifact-bucket", `${cdk.Stack.of(this).account}-setup-pipeline-templates`),\n            stages: [\n                {\n                    stageName: 'Source',\n                    actions: [\n                        new codepipeline_actions.CodeCommitSourceAction({\n                            actionName: "App",\n                            repository: codecommit.Repository.fromRepositoryName(this, "fromRepositoryNameDev", props.repositoryName),\n                            branch: "develop",\n                            output: sourceOutput,\n                            runOrder: 1,\n                        })\n                    ],\n                },\n                {\n                    stageName: 'Continuous-Integration',\n                    actions: [\n                        new codepipeline_actions.CodeBuildAction({\n                            actionName: "CI-Action",\n                            input: sourceOutput,\n                            project: ciAction,\n                            runOrder: 1\n                        })\n                    ],\n                },\n                {\n                    stageName: 'Deploy-Dev',\n                    actions: [\n                        new codepipeline_actions.CodeBuildAction({\n                            actionName: "CDActionDev",\n                            input: sourceOutput,\n                            project: cdActionDev,\n                            runOrder: 1\n                        })\n                    ]\n                }\n            ]\n        });\n\n        new codepipeline.Pipeline(this, 'PrdPipeline', {\n            pipelineName: `${props.repositoryName}-release`,\n            role: iam.Role.fromRoleArn(this, 'CodePipelinePrdActionRole', `arn:aws:iam::${cdk.Stack.of(this).account}:role\/PipelineRole`),\n            artifactBucket: s3.Bucket.fromBucketName(this, "prd-artifact-bucket", `${cdk.Stack.of(this).account}-setup-pipeline-templates`),\n            stages: [\n                {\n                    stageName: 'Source',\n                    actions: [\n                        new codepipeline_actions.CodeCommitSourceAction({\n                            actionName: "App",\n                            repository: codecommit.Repository.fromRepositoryName(this, "fromRepositoryNamePrd", props.repositoryName),\n                            branch: "release",\n                            output: sourceOutput,\n                            runOrder: 1,\n                        })\n                    ],\n                },\n                {\n                    stageName: 'Continuous-Integration',\n                    actions: [\n                        new codepipeline_actions.CodeBuildAction({\n                            actionName: "CI-Action",\n                            input: sourceOutput,\n                            project: ciAction,\n                            runOrder: 1\n                        })\n                    ],\n                },\n                {\n                    stageName: 'Deploy-Prod',\n                    actions: [\n                        new codepipeline_actions.CodeBuildAction({\n                            actionName: "CDActionProd",\n                            input: sourceOutput,\n                            project: cdActionProd,\n                            runOrder: 1\n                        })\n                    ]\n                }\n            ]\n        });\n    }\n\n}\n<\/code><\/pre>\n

feature\u30d6\u30e9\u30f3\u30c1\u7528<\/h3>\n

feature\u30d6\u30e9\u30f3\u30c1\u306b\u5bfe\u3057\u3066\u4f5c\u6210\u3055\u308c\u308bCodePipeline\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

create-pipeline-for-feature-branch-stack.ts<\/code><\/p>\n

import * as cdk from "aws-cdk-lib";\nimport {Construct} from "constructs";\nimport * as codecommit from "aws-cdk-lib\/aws-codecommit"\nimport * as codebuild from "aws-cdk-lib\/aws-codebuild"\nimport * as codepipeline from "aws-cdk-lib\/aws-codepipeline"\nimport * as codepipeline_actions from "aws-cdk-lib\/aws-codepipeline-actions"\nimport * as iam from "aws-cdk-lib\/aws-iam"\nimport * as s3 from "aws-cdk-lib\/aws-s3"\n\ntype repositoryStack = {\n    repositoryName : string\n    branchName: string\n} & cdk.StackProps\n\nexport class CreatePipelineForFeatureBranchStack extends cdk.Stack {\n    constructor(scope: Construct, id: string, props: repositoryStack) {\n        super(scope, id, props)\n\n        const featureSourceOutput = new codepipeline.Artifact("FeatureSourceArtifact")\n\n        const ciActionProject = codebuild.PipelineProject.fromProjectArn(this, "CIActionProject", `arn:aws:codebuild:${cdk.Stack.of(this).region}:${cdk.Stack.of(this).account}:project\/CIAction-${props.repositoryName}`)\n\n        \/\/ \u4efb\u610f\u306efeature\u30d6\u30e9\u30f3\u30c1\u7528\u306eCodePipeline\n        new codepipeline.Pipeline(this, 'FeaturePipeline', {\n            pipelineName: props.repositoryName + "-" + props.branchName,\n            role: iam.Role.fromRoleArn(this, 'FeaturePipelineServiceRole', `arn:aws:iam::${cdk.Stack.of(this).account}:role\/PipelineRole`),\n            artifactBucket: s3.Bucket.fromBucketName(this, "artifact-bucket", `${cdk.Stack.of(this).account}-setup-pipeline-templates`),\n            stages: [\n                {\n                    stageName: 'Source',\n                    actions: [\n                        new codepipeline_actions.CodeCommitSourceAction({\n                            actionName: "App",\n                            repository: codecommit.Repository.fromRepositoryName(this, "fromRepositoryNameFeature", props.repositoryName),\n                            branch: props.branchName,\n                            output: featureSourceOutput,\n                            runOrder: 1,\n                        })\n                    ],\n                },\n                {\n                    stageName: 'Continuous-Integration',\n                    actions: [\n                        new codepipeline_actions.CodeBuildAction({\n                            actionName: "CI-Action",\n                            input: featureSourceOutput,\n                            project: ciActionProject,\n                            runOrder: 1\n                        })\n                    ],\n                },\n            ]\n        });\n    }\n}<\/code><\/pre>\n

CodeBuild\u7528\u306ebuildspec.yaml<\/h4>\n

feature\u30d6\u30e9\u30f3\u30c1\u304c\u4f5c\u6210\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u5b9f\u884c\u3055\u308c\u308bCodeBuild\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u6307\u5b9a\u3059\u308bbuildspec.yaml<\/code>\u3067\u3059\u3002
\n\u3053\u3061\u3089\u306ebuildspec.yaml<\/code>\u306b\u306fcdk deploy<\/code>\u30b3\u30de\u30f3\u30c9\u3092\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3059\u3002deploy\u30b3\u30de\u30f3\u30c9\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066feature\u30d6\u30e9\u30f3\u30c1\u7528\u306eCodePipeline\u3092\u4f5c\u6210\u3059\u308bStack\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

version: 0.2\n\nenv:\n  shell: bash\n\nphases:\n  install:\n    runtime-versions:\n      nodejs: 16.x\n    commands:\n      - npm ci\n  build:\n    commands:\n      - export REPO_NAME=$REPO_NAME\n      - export BRANCH=$BRANCH\n      - |\n        if [ "$EVENT" == "referenceCreated" ]; then\n          npx cdk deploy CreatePipelineForFeatureBranchStack --require-approval never\n        else\n          npx cdk destroy CreatePipelineForFeatureBranchStack --force\n        fi\n<\/code><\/pre>\n

\u52d5\u4f5c\u78ba\u8a8d<\/h2>\n

\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u301c\u958b\u767a\u74b0\u5883\u30fb\u672c\u756a\u74b0\u5883\u306ePipeline\u4f5c\u6210\u307e\u3067<\/h3>\n

\u307e\u305a\u3042\u3089\u304b\u3058\u3081\u4eca\u56de\u306eAWS CDK\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092CodeCommit\u306bpush\u3057\u3066\u304a\u304d\u307e\u3059\u3002
\n\"\"<\/p>\n

\u5171\u901a\u90e8\u5206<\/code>\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u4f5c\u6210 + \u958b\u767a\/\u672c\u756a\u7528\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u4f5c\u6210<\/code>\u306e\u9806\u3067\u30c7\u30d7\u30ed\u30a4\u3057\u307e\u3059\u3002<\/p>\n

$ cdk deploy SetupPipelineStack\n$ export REPO_NAME=sample-app\n$ cdk deploy RepositoryStack\n<\/code><\/pre>\n

\u3053\u306e\u6642\u70b9\u3067\u3001\u958b\u767a\u74b0\u5883\u3001\u672c\u756a\u74b0\u5883\u7528\u306eCodepipeline\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002
\n\"\"<\/p>\n

\"\"<\/p>\n

feature\u30d6\u30e9\u30f3\u30c1\u306e\u4f5c\u6210\u30fb\u524a\u9664<\/h3>\n

\u4f5c\u6210<\/h4>\n

sample-app<\/code>\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u5bfe\u3057\u3066\u4efb\u610f\u306efeature\u30d6\u30e9\u30f3\u30c1\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002
\n\"\"<\/p>\n

\u4f5c\u6210\u3057\u305f\u30d6\u30e9\u30f3\u30c1\u7528\u306eCodePipeline\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002
\n\"\"<\/p>\n

\"\"<\/p>\n

\u3053\u306e\u72b6\u614b\u3067\u66f4\u306b\u65b0\u3057\u3044feature\u30d6\u30e9\u30f3\u30c1\u3092\u4f5c\u6210\u3057\u305f\u5834\u5408(\u4f8b\uff1afuga<\/code>)\u3001\u3055\u3089\u306b\u65b0\u3057\u3044CodePipeline\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002(\u4f8b\uff1asample-app-fuga<\/code>)<\/p>\n

\u524a\u9664<\/h4>\n

\u6700\u5f8c\u306b\u3001\u5148\u307b\u3069\u4f5c\u6210\u3057\u305ffeature\u30d6\u30e9\u30f3\u30c1\u3092\u30ea\u30e2\u30fc\u30c8\u304b\u3089\u524a\u9664\u3057\u307e\u3059\u3002
\n\"\"<\/p>\n

\u3059\u308b\u3068\u5bfe\u5fdc\u3059\u308bCodePipeline\u3082\u540c\u69d8\u306b\u524a\u9664\u3055\u308c\u307e\u3059\u3002
\n(\u203bPipeline\u524a\u9664\u3092CodeBuild\u3067\u5b9f\u884c\u3057\u3066\u3044\u308b)<\/p>\n

CreatePipelineForFeatureBranchStack (Pipeline-sample-app-hoge): destroying...\n(\u4e2d\u7565)\n \u2705  CreatePipelineForFeatureBranchStack (Pipeline-sample-app-hoge): destroyed<\/code><\/pre>\n

\u53c2\u8003<\/h2>\n

Multi-branch CodePipeline strategy with event-driven architecture<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

\u306f\u3058\u3081\u306b CircleCI\u3084GitHub Actions\u306a\u3069\u3067\u306f\u7c21\u5358\u306a\u8a2d\u5b9a\u3092\u3059\u308b\u3060\u3051\u3067\u4efb\u610f\u306efeature\u30d6\u30e9\u30f3\u30c1\u306b\u5bfe\u3057\u3066\u81ea\u52d5\u3067CI\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002 \u4e00\u65b9\u3067AWS\u306e\u5404\u7a2e\u30b5\u30fc\u30d3\u30b9\u306e\u307f\u3067\u540c\u69d8\u306e\u3053\u3068\u3092\u5b9f\u73fe\u3057\u305f\u3044\u5834\u5408\u3001\u73fe\u72b6\u3067\u306f\u5e7e\u3064\u304b\u306e\u30de\u30cd\u30fc\u30b8\u30c9\u30b5\u30fc\u30d3\u30b9\u3092\u4f75\u305b\u3066\u4f5c\u308a\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\/\u6848\u4ef6\u306e\u90fd\u5408\u6b21\u7b2c\u3067\u306f\u3069\u3046\u3057\u3066\u3082AWS\u306e\u307f\u3057\u304b\u4f7f\u3048\u306a\u3044\u5834\u5408\u3082\u3042\u308a\u5f97\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3001\u4eca\u56de\u306fAWS\u306e\u5404\u7a2e […]<\/p>\n","protected":false},"author":10,"featured_media":4106,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[475,307,473,476,474],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/4063"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=4063"}],"version-history":[{"count":20,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/4063\/revisions"}],"predecessor-version":[{"id":4116,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/4063\/revisions\/4116"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media\/4106"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=4063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=4063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=4063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}