Skip to content

Commit 5e4f603

Browse files
authored
fix: compilation failure in Go (#35871)
This is a revert of #35770; `jsii-pacmak` doesn't generate correct Go code for cross-module type intersections. Fixes #35862.
1 parent 8ee5d4b commit 5e4f603

File tree

5 files changed

+18
-41
lines changed

5 files changed

+18
-41
lines changed

allowed-breaking-changes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,3 +966,6 @@ removed:aws-cdk-lib.lambda_layer_kubectl.KubectlLayer
966966
# Fixing the JsonSchema interface to be consistent with JSON Schema spec
967967
changed-type:aws-cdk-lib.aws_apigateway.JsonSchema.additionalItems
968968
strengthened:aws-cdk-lib.aws_apigateway.JsonSchema
969+
970+
# Revert a failing change
971+
strengthened:aws-cdk-lib.aws_stepfunctions.StateMachineProps

packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export interface StateMachineProps {
117117
*
118118
* @default A role is automatically created
119119
*/
120-
readonly role?: iam.IRoleRef & iam.IGrantable;
120+
readonly role?: iam.IRole;
121121

122122
/**
123123
* Maximum run time for this state machine
@@ -427,6 +427,11 @@ export class StateMachine extends StateMachineBase {
427427
*/
428428
public static readonly PROPERTY_INJECTION_ID: string = 'aws-cdk-lib.aws-stepfunctions.StateMachine';
429429

430+
/**
431+
* Execution role of this state machine
432+
*/
433+
public readonly role: iam.IRole;
434+
430435
/**
431436
* The name of the state machine
432437
* @attribute
@@ -450,11 +455,6 @@ export class StateMachine extends StateMachineBase {
450455
*/
451456
public readonly stateMachineRevisionId: string;
452457

453-
/**
454-
* Execution role of this state machine
455-
*/
456-
private readonly _role: iam.IRoleRef & iam.IGrantable;
457-
458458
constructor(scope: Construct, id: string, props: StateMachineProps) {
459459
super(scope, id, {
460460
physicalName: props.stateMachineName,
@@ -476,7 +476,7 @@ export class StateMachine extends StateMachineBase {
476476
this.validateLogOptions(props.logs);
477477
}
478478

479-
this._role = props.role || new iam.Role(this, 'Role', {
479+
this.role = props.role || new iam.Role(this, 'Role', {
480480
assumedBy: new iam.ServicePrincipal('states.amazonaws.com'),
481481
});
482482

@@ -494,7 +494,7 @@ export class StateMachine extends StateMachineBase {
494494
}
495495

496496
if (props.encryptionConfiguration instanceof CustomerManagedEncryptionConfiguration) {
497-
this._role.grantPrincipal.addToPrincipalPolicy(new iam.PolicyStatement({
497+
this.role.addToPrincipalPolicy(new iam.PolicyStatement({
498498
effect: iam.Effect.ALLOW,
499499
actions: [
500500
'kms:Decrypt', 'kms:GenerateDataKey',
@@ -513,7 +513,7 @@ export class StateMachine extends StateMachineBase {
513513
}));
514514

515515
if (props.logs && props.logs.level !== LogLevel.OFF) {
516-
this._role.grantPrincipal.addToPrincipalPolicy(new iam.PolicyStatement({
516+
this.role.addToPrincipalPolicy(new iam.PolicyStatement({
517517
effect: iam.Effect.ALLOW,
518518
actions: [
519519
'kms:GenerateDataKey',
@@ -540,10 +540,10 @@ export class StateMachine extends StateMachineBase {
540540
const resource = new CfnStateMachine(this, 'Resource', {
541541
stateMachineName: this.physicalName,
542542
stateMachineType: props.stateMachineType ?? undefined,
543-
roleArn: this._role.roleRef.roleArn,
543+
roleArn: this.role.roleArn,
544544
loggingConfiguration: props.logs ? this.buildLoggingConfiguration(props.logs) : undefined,
545545
tracingConfiguration: this.buildTracingConfiguration(props.tracingEnabled),
546-
...definitionBody.bind(this, this._role.grantPrincipal, props, graph),
546+
...definitionBody.bind(this, this.role, props, graph),
547547
definitionSubstitutions: props.definitionSubstitutions,
548548
encryptionConfiguration: buildEncryptionConfiguration(props.encryptionConfiguration),
549549
});
@@ -569,27 +569,15 @@ export class StateMachine extends StateMachineBase {
569569
* The principal this state machine is running as
570570
*/
571571
public get grantPrincipal() {
572-
return this._role.grantPrincipal;
573-
}
574-
575-
/**
576-
* Execution role of this state machine
577-
*
578-
* Will throw if the Role object that was given does not implement IRole
579-
*/
580-
public get role(): iam.IRole {
581-
if (!isIRole(this._role)) {
582-
throw new ValidationError(`The role given to this StateMachine is not an IRole, but ${this._role.constructor.name}`, this);
583-
}
584-
return this._role;
572+
return this.role.grantPrincipal;
585573
}
586574

587575
/**
588576
* Add the given statement to the role's policy
589577
*/
590578
@MethodMetadata()
591579
public addToRolePolicy(statement: iam.PolicyStatement) {
592-
this._role.grantPrincipal.addToPrincipalPolicy(statement);
580+
this.role.addToPrincipalPolicy(statement);
593581
}
594582

595583
private validateStateMachineName(stateMachineName: string) {
@@ -858,9 +846,3 @@ export class ChainDefinitionBody extends DefinitionBody {
858846
};
859847
}
860848
}
861-
862-
function isIRole(x: iam.IRoleRef): x is iam.IRole {
863-
const xx = x as iam.IRole;
864-
return (!!xx.addManagedPolicy && !!xx.addToPrincipalPolicy && !!xx.assumeRoleAction && !!xx.attachInlinePolicy
865-
&& !!xx.grant && !!xx.policyFragment);
866-
}

packages/awslint/bin/awslint.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
/* eslint-disable no-console */
33
import * as child_process from 'child_process';
44
import * as path from 'path';
5-
import { JsiiFeature } from '@jsii/spec';
65
import * as chalk from 'chalk';
76
import * as fs from 'fs-extra';
87
import * as reflect from 'jsii-reflect';
98
import * as yargs from 'yargs';
109
import { ALL_RULES_LINTER, DiagnosticLevel, RuleFilterSet } from '../lib';
1110

12-
const FEATURES: JsiiFeature[] = ['intersection-types'];
13-
1411
let stackTrace = false;
1512

1613
async function main() {
@@ -250,7 +247,7 @@ main().catch(e => {
250247

251248
async function loadModule(dir: string) {
252249
const ts = new reflect.TypeSystem();
253-
await ts.load(dir, { validate: false, supportedFeatures: FEATURES }); // Don't validate to save 66% of execution time (20s vs 1min).
250+
await ts.load(dir, { validate: false }); // Don't validate to save 66% of execution time (20s vs 1min).
254251
// We run 'awslint' during build time, assemblies are guaranteed to be ok.
255252

256253
// We won't load any more assemblies. Lock the typesystem to benefit from performance improvements.

packages/awslint/lib/rules/api.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ apiLinter.add({
139139
return;
140140
}
141141

142-
if (type.intersectionOfTypes) {
143-
// Type intersections are okay
144-
return;
145-
}
146-
147142
throw new Error(`invalid type reference: ${type.toString()}`);
148143
}
149144
},

scripts/run-rosetta.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ time $ROSETTA extract \
7373

7474
if $infuse; then
7575
echo "💎 Generating synthetic examples for the remainder" >&2
76-
time npx cdk-generate-synthetic-examples \
76+
time npx cdk-generate-synthetic-examples@^0.1.292 \
7777
$(cat $jsii_pkgs_file)
7878

7979
time $ROSETTA extract \

0 commit comments

Comments
 (0)