File tree 2 files changed +30
-2
lines changed
packages/@aws-cdk/aws-codepipeline
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,8 @@ export interface PipelineProps {
103
103
}
104
104
105
105
abstract class PipelineBase extends Resource implements IPipeline {
106
- public abstract pipelineName : string ;
107
- public abstract pipelineArn : string ;
106
+ public abstract readonly pipelineName : string ;
107
+ public abstract readonly pipelineArn : string ;
108
108
109
109
/**
110
110
* Defines an event rule triggered by this CodePipeline.
@@ -159,6 +159,22 @@ abstract class PipelineBase extends Resource implements IPipeline {
159
159
* // ... add more stages
160
160
*/
161
161
export class Pipeline extends PipelineBase {
162
+ /**
163
+ * Import a pipeline into this app.
164
+ *
165
+ * @param scope the scope into which to import this pipeline
166
+ * @param id the logical ID of the returned pipeline construct
167
+ * @param pipelineArn The ARN of the pipeline (e.g. `arn:aws:codepipeline:us-east-1:123456789012:MyDemoPipeline`)
168
+ */
169
+ public static fromPipelineArn ( scope : Construct , id : string , pipelineArn : string ) : IPipeline {
170
+ class Import extends PipelineBase {
171
+ public readonly pipelineName = Stack . of ( scope ) . parseArn ( pipelineArn ) . resource ;
172
+ public readonly pipelineArn = pipelineArn ;
173
+ }
174
+
175
+ return new Import ( scope , id ) ;
176
+ }
177
+
162
178
/**
163
179
* The IAM role AWS CodePipeline will use to perform actions or assume roles for actions with
164
180
* a more specific IAM role.
Original file line number Diff line number Diff line change @@ -28,5 +28,17 @@ export = {
28
28
29
29
test . done ( ) ;
30
30
} ,
31
+
32
+ 'can be imported by ARN' ( test : Test ) {
33
+ const stack = new cdk . Stack ( ) ;
34
+
35
+ const pipeline = codepipeline . Pipeline . fromPipelineArn ( stack , 'Pipeline' ,
36
+ 'arn:aws:codepipeline:us-east-1:123456789012:MyPipeline' ) ;
37
+
38
+ test . equal ( pipeline . pipelineArn , 'arn:aws:codepipeline:us-east-1:123456789012:MyPipeline' ) ;
39
+ test . equal ( pipeline . pipelineName , 'MyPipeline' ) ;
40
+
41
+ test . done ( ) ;
42
+ } ,
31
43
} ,
32
44
} ;
You can’t perform that action at this time.
0 commit comments