File tree 2 files changed +34
-1
lines changed
packages/@aws-cdk/aws-stepfunctions
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,9 @@ abstract class StateMachineBase extends Resource implements IStateMachine {
142
142
public readonly stateMachineArn = stateMachineArn ;
143
143
public readonly grantPrincipal = new iam . UnknownPrincipal ( { resource : this } ) ;
144
144
}
145
- return new Import ( scope , id ) ;
145
+ return new Import ( scope , id , {
146
+ environmentFromArn : stateMachineArn ,
147
+ } ) ;
146
148
}
147
149
148
150
public abstract readonly stateMachineArn : string ;
Original file line number Diff line number Diff line change @@ -277,4 +277,35 @@ describe('State Machine', () => {
277
277
] ,
278
278
} ) ;
279
279
} ) ;
280
+
281
+ describe ( 'StateMachine.fromStateMachineArn()' , ( ) => {
282
+ let stack : cdk . Stack ;
283
+
284
+ beforeEach ( ( ) => {
285
+ const app = new cdk . App ( ) ;
286
+ stack = new cdk . Stack ( app , 'Base' , {
287
+ env : { account : '111111111111' , region : 'stack-region' } ,
288
+ } ) ;
289
+ } ) ;
290
+
291
+ describe ( 'for a state machine in a different account and region' , ( ) => {
292
+ let mach : stepfunctions . IStateMachine ;
293
+
294
+ beforeEach ( ( ) => {
295
+ mach = stepfunctions . StateMachine . fromStateMachineArn (
296
+ stack ,
297
+ 'iMach' ,
298
+ 'arn:aws:states:machine-region:222222222222:stateMachine:machine-name' ,
299
+ ) ;
300
+ } ) ;
301
+
302
+ test ( "the state machine's region is taken from the ARN" , ( ) => {
303
+ expect ( mach . env . region ) . toBe ( 'machine-region' ) ;
304
+ } ) ;
305
+
306
+ test ( "the state machine's account is taken from the ARN" , ( ) => {
307
+ expect ( mach . env . account ) . toBe ( '222222222222' ) ;
308
+ } ) ;
309
+ } ) ;
310
+ } ) ;
280
311
} ) ;
You can’t perform that action at this time.
0 commit comments