Skip to content

Commit 0f8f6c5

Browse files
committed
chore(stepfunctions): reference interfaces
Reference interfaces for L2s, like #35271. "chore" because I plan to make a lot of these PRs and they're not adding value to the changelog. (Generated with AI)
1 parent 8e9f730 commit 0f8f6c5

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/invoke-activity.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as sfn from '../../aws-stepfunctions';
22
import { Duration } from '../../core';
3+
import { IActivityRef } from '../../interfaces/generated/aws-stepfunctions-interfaces.generated';
34

45
/**
56
* Properties for FunctionTask
@@ -24,13 +25,13 @@ export interface InvokeActivityProps {
2425
* @deprecated use `StepFunctionsInvokeActivity`
2526
*/
2627
export class InvokeActivity implements sfn.IStepFunctionsTask {
27-
constructor(private readonly activity: sfn.IActivity, private readonly props: InvokeActivityProps = {}) {
28+
constructor(private readonly activity: IActivityRef, private readonly props: InvokeActivityProps = {}) {
2829
}
2930

3031
public bind(_task: sfn.Task): sfn.StepFunctionsTaskConfig {
3132
return {
32-
resourceArn: this.activity.activityArn,
33-
metricDimensions: { ActivityArn: this.activity.activityArn },
33+
resourceArn: this.activity.activityRef.activityArn,
34+
metricDimensions: { ActivityArn: this.activity.activityRef.activityArn },
3435
heartbeat: this.props.heartbeat,
3536
// No IAM permissions necessary, execution role implicitly has Activity permissions.
3637
metricPrefixSingular: 'Activity',

packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/start-execution.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getResourceArn } from './resource-arn-suffix';
22
import * as iam from '../../aws-iam';
33
import * as sfn from '../../aws-stepfunctions';
44
import { ArnFormat, Stack, ValidationError } from '../../core';
5+
import { IStateMachineRef } from '../../interfaces/generated/aws-stepfunctions-interfaces.generated';
56

67
/**
78
* Properties for StartExecution
@@ -47,7 +48,7 @@ export interface StartExecutionProps {
4748
export class StartExecution implements sfn.IStepFunctionsTask {
4849
private readonly integrationPattern: sfn.ServiceIntegrationPattern;
4950

50-
constructor(private readonly stateMachine: sfn.IStateMachine, private readonly props: StartExecutionProps = {}) {
51+
constructor(private readonly stateMachine: IStateMachineRef, private readonly props: StartExecutionProps = {}) {
5152
this.integrationPattern = props.integrationPattern || sfn.ServiceIntegrationPattern.FIRE_AND_FORGET;
5253

5354
const supportedPatterns = [
@@ -72,7 +73,7 @@ export class StartExecution implements sfn.IStepFunctionsTask {
7273
policyStatements: this.createScopedAccessPolicy(task),
7374
parameters: {
7475
Input: this.props.input,
75-
StateMachineArn: this.stateMachine.stateMachineArn,
76+
StateMachineArn: this.stateMachine.stateMachineRef.stateMachineArn,
7677
Name: this.props.name,
7778
},
7879
};
@@ -91,7 +92,7 @@ export class StartExecution implements sfn.IStepFunctionsTask {
9192
const policyStatements = [
9293
new iam.PolicyStatement({
9394
actions: ['states:StartExecution'],
94-
resources: [this.stateMachine.stateMachineArn],
95+
resources: [this.stateMachine.stateMachineRef.stateMachineArn],
9596
}),
9697
];
9798

@@ -104,7 +105,7 @@ export class StartExecution implements sfn.IStepFunctionsTask {
104105
service: 'states',
105106
resource: 'execution',
106107
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
107-
resourceName: `${stack.splitArn(this.stateMachine.stateMachineArn, ArnFormat.COLON_RESOURCE_NAME).resourceName}*`,
108+
resourceName: `${stack.splitArn(this.stateMachine.stateMachineRef.stateMachineArn, ArnFormat.COLON_RESOURCE_NAME).resourceName}*`,
108109
})],
109110
}));
110111

packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/stepfunctions/start-execution.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { Construct } from 'constructs';
22
import * as iam from '../../../aws-iam';
33
import * as sfn from '../../../aws-stepfunctions';
44
import { ArnFormat, Stack, ValidationError } from '../../../core';
5+
import { IStateMachineRef } from '../../../interfaces/generated/aws-stepfunctions-interfaces.generated';
56
import { integrationResourceArn, validatePatternSupported } from '../private/task-utils';
67

78
interface StepFunctionsStartExecutionOptions {
89
/**
910
* The Step Functions state machine to start the execution on.
1011
*/
11-
readonly stateMachine: sfn.IStateMachine;
12+
readonly stateMachine: IStateMachineRef;
1213

1314
/**
1415
* The JSON input for the execution, same as that of StartExecution.
@@ -136,7 +137,7 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase {
136137
Resource: `${integrationResourceArn('states', 'startExecution', this.integrationPattern)}${suffix}`,
137138
...this._renderParametersOrArguments({
138139
Input: input,
139-
StateMachineArn: this.props.stateMachine.stateMachineArn,
140+
StateMachineArn: this.props.stateMachine.stateMachineRef.stateMachineArn,
140141
Name: this.props.name,
141142
}, queryLanguage),
142143
};
@@ -155,7 +156,7 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase {
155156
const policyStatements = [
156157
new iam.PolicyStatement({
157158
actions: ['states:StartExecution'],
158-
resources: [this.props.stateMachine.stateMachineArn],
159+
resources: [this.props.stateMachine.stateMachineRef.stateMachineArn],
159160
}),
160161
];
161162

@@ -170,7 +171,7 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase {
170171
service: 'states',
171172
resource: 'execution',
172173
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
173-
resourceName: `${stack.splitArn(this.props.stateMachine.stateMachineArn, ArnFormat.COLON_RESOURCE_NAME).resourceName}*`,
174+
resourceName: `${stack.splitArn(this.props.stateMachine.stateMachineRef.stateMachineArn, ArnFormat.COLON_RESOURCE_NAME).resourceName}*`,
174175
}),
175176
],
176177
}),

packages/aws-cdk-lib/aws-stepfunctions/lib/activity.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as iam from '../../aws-iam';
99
import { ArnFormat, IResource, Lazy, Names, Resource, Stack } from '../../core';
1010
import { addConstructMetadata, MethodMetadata } from '../../core/lib/metadata-resource';
1111
import { propertyInjectable } from '../../core/lib/prop-injectable';
12+
import { IActivityRef } from '../../interfaces/generated/aws-stepfunctions-interfaces.generated';
1213

1314
/**
1415
* Properties for defining a new Step Functions Activity
@@ -46,6 +47,11 @@ export class Activity extends Resource implements IActivity {
4647
public get activityName() {
4748
return Stack.of(this).splitArn(activityArn, ArnFormat.COLON_RESOURCE_NAME).resourceName || '';
4849
}
50+
public get activityRef() {
51+
return {
52+
activityArn: this.activityArn,
53+
};
54+
}
4955
}
5056

5157
return new Imported(scope, id);
@@ -78,6 +84,12 @@ export class Activity extends Resource implements IActivity {
7884
*/
7985
public readonly encryptionConfiguration?: EncryptionConfiguration;
8086

87+
public get activityRef() {
88+
return {
89+
activityArn: this.activityArn,
90+
};
91+
}
92+
8193
constructor(scope: Construct, id: string, props: ActivityProps = {}) {
8294
super(scope, id, {
8395
physicalName: props.activityName ||
@@ -263,7 +275,7 @@ export class Activity extends Resource implements IActivity {
263275
* Represents a Step Functions Activity
264276
* https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html
265277
*/
266-
export interface IActivity extends IResource {
278+
export interface IActivity extends IResource, IActivityRef {
267279
/**
268280
* The ARN of the activity
269281
*

0 commit comments

Comments
 (0)