@@ -43,6 +43,7 @@ export class PipelineStack extends cdk.Stack {
4343
4444 const sourceOutput = new codepipeline . Artifact ( ) ;
4545 const buildOutput = new codepipeline . Artifact ( ) ;
46+ const secureBuildOutput = new codepipeline . Artifact ( ) ;
4647 const sourceAction = createSourceAction ( scope , props , sourceOutput ) ;
4748
4849 pipeline . addStage ( {
@@ -62,6 +63,33 @@ export class PipelineStack extends cdk.Stack {
6263 ENVIRONMENT : {
6364 value : "Gamma" ,
6465 } ,
66+ LANGUAGE : {
67+ value : "english" ,
68+ } ,
69+ AUTH : {
70+ value : "false" ,
71+ } ,
72+ } ,
73+ } ) ;
74+
75+ const buildSecure = new codebuild . PipelineProject ( this , "Build-Secure" , {
76+ environment : {
77+ buildImage : codebuild . LinuxBuildImage . AMAZON_LINUX_2_2 ,
78+ computeType : codebuild . ComputeType . LARGE ,
79+ } ,
80+ environmentVariables : {
81+ CDK_ADMIN_EMAIL : {
82+ value : "johndoe@example.com" ,
83+ } ,
84+ ENVIRONMENT : {
85+ value : "GammaSecure" ,
86+ } ,
87+ LANGUAGE : {
88+ value : "english" ,
89+ } ,
90+ AUTH : {
91+ value : "true" ,
92+ } ,
6593 } ,
6694 } ) ;
6795
@@ -72,6 +100,13 @@ export class PipelineStack extends cdk.Stack {
72100 resources : [ "*" ] ,
73101 } )
74102 ) ;
103+ buildSecure . addToRolePolicy (
104+ new iam . PolicyStatement ( {
105+ effect : iam . Effect . ALLOW ,
106+ actions : [ "*" ] ,
107+ resources : [ "*" ] ,
108+ } )
109+ ) ;
75110
76111 pipeline . addStage ( {
77112 stageName : "Gamma" ,
@@ -83,6 +118,13 @@ export class PipelineStack extends cdk.Stack {
83118 outputs : [ buildOutput ] ,
84119 runOrder : 1 ,
85120 } ) ,
121+ new CodeBuildAction ( {
122+ actionName : "Build.and.Deploy.Secure" ,
123+ project : buildSecure ,
124+ input : sourceOutput ,
125+ outputs : [ secureBuildOutput ] ,
126+ runOrder : 2 ,
127+ } ) ,
86128 ] ,
87129 } ) ;
88130
@@ -106,6 +148,22 @@ export class PipelineStack extends cdk.Stack {
106148 ] ,
107149 }
108150 ) ;
151+ new codestarnotifications . CfnNotificationRule (
152+ this ,
153+ "BuildNotificationRuleSecure" ,
154+ {
155+ detailType : "BASIC" ,
156+ resource : buildSecure . projectArn ,
157+ name : "BuildNotificationsSecure" ,
158+ eventTypeIds : [ "codebuild-project-build-state-failed" ] ,
159+ targets : [
160+ {
161+ targetType : "SNS" ,
162+ targetAddress : notificationsTopic . topicArn ,
163+ } ,
164+ ] ,
165+ }
166+ ) ;
109167 }
110168}
111169
0 commit comments