Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scheduler-targetes-alpha): multiple schedules cause resolution error during synth #30634

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/@aws-cdk/aws-scheduler-targets-alpha/lib/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ export abstract class ScheduleTargetBase {
const id = 'SchedulerRoleForTarget-' + hash;
const existingRole = stack.node.tryFindChild(id) as iam.Role;

const principal = new iam.PrincipalWithConditions(new iam.ServicePrincipal('scheduler.amazonaws.com'), {
StringEquals: {
'aws:SourceAccount': schedule.env.account,
const principal = new iam.ServicePrincipal('scheduler.amazonaws.com', {
conditions: {
StringEquals: {
'aws:SourceAccount': schedule.env.account,
},
},
});
if (existingRole) {
Expand Down Expand Up @@ -192,4 +194,4 @@ export abstract class ScheduleTargetBase {
maximumRetryAttempts: maxAttempts,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('codebuild start build', () => {
const expr = ScheduleExpression.at(new Date(Date.UTC(1991, 2, 24, 0, 0, 0)));

beforeEach(() => {
app = new App();
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
stack = new Stack(app, 'Stack', { env: { region: 'us-east-1', account: '123456789012' } });
codebuildProject = new Project(stack, 'Project', {
buildSpec: BuildSpec.fromObject({}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('codepipeline start execution', () => {
const expr = ScheduleExpression.at(new Date(Date.UTC(1991, 2, 24, 0, 0, 0)));

beforeEach(() => {
app = new App();
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
stack = new Stack(app, 'Stack', { env: { region: 'us-east-1', account: '123456789012' } });
codepipeline = createMinimalPipeline(stack);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('eventBridge put events', () => {
const expr = ScheduleExpression.at(new Date(Date.UTC(1991, 2, 24, 0, 0, 0)));

beforeEach(() => {
app = new App();
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
stack = new Stack(app, 'Stack', { env: { region: 'us-east-1', account: '123456789012' } });
eventBus = new events.EventBus(stack, 'MyEventBus', { eventBusName: 'MyEventBus' });
eventBusEventEntry = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('schedule target', () => {
const expr = ScheduleExpression.at(new Date(Date.UTC(1969, 10, 20, 0, 0, 0)));

beforeEach(() => {
app = new App();
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
stack = new Stack(app, 'Stack', { env: { region: 'us-east-1', account: '123456789012' } });
const assessmentTarget = new CfnAssessmentTarget(stack, 'MyAssessmentTarget');
template = new CfnAssessmentTemplate(stack, 'MyTemplate', {
Expand Down Expand Up @@ -506,4 +506,4 @@ describe('schedule target', () => {
target: inspectorTarget,
})).toThrow(/Number of retry attempts should be less or equal than 185/);
});
});
});
Loading