Skip to content

Commit

Permalink
update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
gracelu0 committed Oct 25, 2024
1 parent dadf688 commit 1419e41
Show file tree
Hide file tree
Showing 105 changed files with 246,874 additions and 224,759 deletions.
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-scheduler-targets-alpha/lib/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export abstract class ScheduleTargetBase {
},
});
if (existingRole) {
existingRole.assumeRolePolicy?.addStatements(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
principals: [principal],
actions: ['sts:AssumeRole'],
}));
return existingRole;
}
const role = new iam.Role(stack, id, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('codebuild start build', () => {
const codebuildArnRef = { 'Fn::GetAtt': ['ProjectC78D97AD', 'Arn'] };
const codebuildAction = 'codebuild:StartBuild';
const expr = ScheduleExpression.at(new Date(Date.UTC(1991, 2, 24, 0, 0, 0)));
const roleId = 'SchedulerRoleForTarget27bd47517CF0F8';

beforeEach(() => {
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
Expand All @@ -36,7 +37,7 @@ describe('codebuild start build', () => {
Properties: {
Target: {
Arn: codebuildArnRef,
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {},
},
},
Expand All @@ -52,7 +53,7 @@ describe('codebuild start build', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
});

template.hasResourceProperties('AWS::IAM::Role', {
Expand Down Expand Up @@ -113,7 +114,7 @@ describe('codebuild start build', () => {
});
});

test('reuses IAM role and IAM policy for two schedules from the same account', () => {
test('reuses IAM role and IAM policy for two schedules with the same target from the same account', () => {
const codeBuildTarget = new CodeBuildStartBuild(codebuildProject, {});

new Schedule(stack, 'MyScheduleDummy1', {
Expand Down Expand Up @@ -154,7 +155,7 @@ describe('codebuild start build', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
}, 1);
});

Expand Down Expand Up @@ -411,7 +412,7 @@ describe('codebuild start build', () => {
Properties: {
Target: {
Arn: codebuildArnRef,
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {
MaximumEventAgeInSeconds: 10800,
MaximumRetryAttempts: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('codepipeline start execution', () => {
],
};
const expr = ScheduleExpression.at(new Date(Date.UTC(1991, 2, 24, 0, 0, 0)));
const roleId = 'SchedulerRoleForTarget1b3000F5862F75';

beforeEach(() => {
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
Expand All @@ -48,7 +49,7 @@ describe('codepipeline start execution', () => {
Properties: {
Target: {
Arn: pipelineArn,
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {},
},
},
Expand All @@ -64,7 +65,7 @@ describe('codepipeline start execution', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
});

template.hasResourceProperties('AWS::IAM::Role', {
Expand Down Expand Up @@ -123,7 +124,7 @@ describe('codepipeline start execution', () => {
});
});

test('reuses IAM role and IAM policy for two schedules from the same account', () => {
test('reuses IAM role and IAM policy for two schedules with the same target from the same account', () => {
const codepipelineTarget = new CodePipelineStartPipelineExecution(codepipeline, {});

new Schedule(stack, 'MyScheduleDummy1', {
Expand Down Expand Up @@ -164,7 +165,7 @@ describe('codepipeline start execution', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
}, 1);
});

Expand Down Expand Up @@ -431,7 +432,7 @@ describe('codepipeline start execution', () => {
Properties: {
Target: {
Arn: pipelineArn,
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {
MaximumEventAgeInSeconds: 10800,
MaximumRetryAttempts: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('eventBridge put events', () => {
let eventBus: events.EventBus;
let eventBusEventEntry: EventBridgePutEventsEntry;
const expr = ScheduleExpression.at(new Date(Date.UTC(1991, 2, 24, 0, 0, 0)));
const roleId = 'SchedulerRoleForTarget1e6d0e3BE2318C';

beforeEach(() => {
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
Expand Down Expand Up @@ -48,7 +49,7 @@ describe('eventBridge put events', () => {
Source: 'service',
},
Input: JSON.stringify({ foo: 'bar' }),
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {},
},
},
Expand All @@ -69,7 +70,7 @@ describe('eventBridge put events', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
});

template.hasResourceProperties('AWS::IAM::Role', {
Expand Down Expand Up @@ -144,7 +145,7 @@ describe('eventBridge put events', () => {
});
});

test('reuses IAM role and IAM policy for two schedules from the same account', () => {
test('reuses IAM role and IAM policy for two schedules with the same target from the same account', () => {
const eventBusTarget = new EventBridgePutEvents(eventBusEventEntry, {});

new Schedule(stack, 'MyScheduleDummy1', {
Expand Down Expand Up @@ -190,7 +191,7 @@ describe('eventBridge put events', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
}, 1);
});

Expand Down Expand Up @@ -513,7 +514,7 @@ describe('eventBridge put events', () => {
Source: 'service',
},
Input: JSON.stringify({ foo: 'bar' }),
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {
MaximumEventAgeInSeconds: 10800,
MaximumRetryAttempts: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('schedule target', () => {
let stack: Stack;
let template: CfnAssessmentTemplate;
const expr = ScheduleExpression.at(new Date(Date.UTC(1969, 10, 20, 0, 0, 0)));
const roleId = 'SchedulerRoleForTarget78b2d848BF7444';

beforeEach(() => {
app = new App({ context: { '@aws-cdk/aws-iam:minimizePolicies': true } });
Expand All @@ -37,7 +38,7 @@ describe('schedule target', () => {
Arn: {
'Fn::GetAtt': ['MyTemplate', 'Arn'],
},
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {},
},
},
Expand All @@ -53,7 +54,7 @@ describe('schedule target', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
});

Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', {
Expand Down Expand Up @@ -113,7 +114,7 @@ describe('schedule target', () => {
});
});

test('reuses IAM role and IAM policy for two schedules from the same account', () => {
test('reuses IAM role and IAM policy for two schedules with the same target from the same account', () => {
const inspectorTarget = new InspectorStartAssessmentRun(template);

new Schedule(stack, 'MyScheduleDummy1', {
Expand Down Expand Up @@ -152,7 +153,7 @@ describe('schedule target', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: roleId }],
}, 1);
});

Expand Down Expand Up @@ -183,7 +184,7 @@ describe('schedule target', () => {
Arn: {
'Fn::ImportValue': 'Stack2:ExportsOutputFnGetAttAnotherTemplateArn9F673A62',
},
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTargetea46910831E154', 'Arn'] },
RetryPolicy: {},
},
},
Expand All @@ -199,7 +200,7 @@ describe('schedule target', () => {
},
],
},
Roles: [{ Ref: 'SchedulerRoleForTarget1441a743A31888' }],
Roles: [{ Ref: 'SchedulerRoleForTargetea46910831E154' }],
});
});

Expand Down Expand Up @@ -461,7 +462,7 @@ describe('schedule target', () => {
Arn: {
'Fn::GetAtt': ['MyTemplate', 'Arn'],
},
RoleArn: { 'Fn::GetAtt': ['SchedulerRoleForTarget1441a743A31888', 'Arn'] },
RoleArn: { 'Fn::GetAtt': [roleId, 'Arn'] },
RetryPolicy: {
MaximumEventAgeInSeconds: 10800,
MaximumRetryAttempts: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ parameter.grantWrite(role);
const integrationTest = new IntegTest(app, 'integrationtest-codebuild-start-build', {
testCases: [stack],
stackUpdateWorkflow: false, // this would cause the schedule to trigger with the old code
allowDestroy: ['AWS::IAM::Role', 'AWS::IAM::Policy'],
});

const getParameter = integrationTest.assertions.awsApiCall('SSM', 'getParameter', {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1084,14 +1084,14 @@
},
"RoleArn": {
"Fn::GetAtt": [
"SchedulerRoleForTarget1441a743A31888",
"SchedulerRoleForTarget5411029AC19639",
"Arn"
]
}
}
}
},
"SchedulerRoleForTarget1441a743A31888": {
"SchedulerRoleForTarget5411029AC19639": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand All @@ -1115,7 +1115,7 @@
}
}
},
"SchedulerRoleForTarget1441a7DefaultPolicy885B6BFD": {
"SchedulerRoleForTarget541102DefaultPolicy9F008348": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -1150,10 +1150,10 @@
],
"Version": "2012-10-17"
},
"PolicyName": "SchedulerRoleForTarget1441a7DefaultPolicy885B6BFD",
"PolicyName": "SchedulerRoleForTarget541102DefaultPolicy9F008348",
"Roles": [
{
"Ref": "SchedulerRoleForTarget1441a743A31888"
"Ref": "SchedulerRoleForTarget5411029AC19639"
}
]
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1419e41

Please sign in to comment.