Skip to content

Commit 29bdd6c

Browse files
authored
refactor(cloudfront): replace instanceOf into Role.isRole() methodd (#24448)
Closes #24447 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e8e5cdc commit 29bdd6c

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/@aws-cdk/aws-cloudfront/lib/experimental/edge-function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ interface FunctionConfig {
250250
}
251251

252252
function addEdgeLambdaToRoleTrustStatement(role: iam.IRole) {
253-
if (role instanceof iam.Role && role.assumeRolePolicy) {
253+
if (iam.Role.isRole(role) && role.assumeRolePolicy) {
254254
const statement = new iam.PolicyStatement();
255255
const edgeLambdaServicePrincipal = new iam.ServicePrincipal('edgelambda.amazonaws.com');
256256
statement.addPrincipals(edgeLambdaServicePrincipal);

packages/@aws-cdk/aws-cloudfront/lib/private/cache-behavior.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class CacheBehavior {
7575
if (!edgeLambdas || edgeLambdas.length === 0) { return; }
7676
edgeLambdas.forEach((edgeLambda) => {
7777
const role = edgeLambda.functionVersion.role;
78-
if (role && role instanceof iam.Role && role.assumeRolePolicy) {
78+
if (role && iam.Role.isRole(role) && role.assumeRolePolicy) {
7979
role.assumeRolePolicy.addStatements(new iam.PolicyStatement({
8080
actions: ['sts:AssumeRole'],
8181
principals: [new iam.ServicePrincipal('edgelambda.amazonaws.com')],

packages/@aws-cdk/aws-cloudfront/lib/web-distribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ export class CloudFrontWebDistribution extends cdk.Resource implements IDistribu
10531053

10541054
// allow edgelambda.amazonaws.com to assume the functions' execution role.
10551055
for (const a of input.lambdaFunctionAssociations) {
1056-
if (a.lambdaFunction.role && a.lambdaFunction.role instanceof iam.Role && a.lambdaFunction.role.assumeRolePolicy) {
1056+
if (a.lambdaFunction.role && iam.Role.isRole(a.lambdaFunction.role) && a.lambdaFunction.role.assumeRolePolicy) {
10571057
a.lambdaFunction.role.assumeRolePolicy.addStatements(new iam.PolicyStatement({
10581058
actions: ['sts:AssumeRole'],
10591059
principals: [new iam.ServicePrincipal('edgelambda.amazonaws.com')],

packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ export class Pipeline extends PipelineBase {
764764
// because the role might be from a different environment),
765765
// but _only_ if it's a new Role -
766766
// an imported Role should not add the dependency
767-
if (action.actionProperties.role instanceof iam.Role) {
767+
if (iam.Role.isRole(action.actionProperties.role)) {
768768
const roleStack = Stack.of(action.actionProperties.role);
769769
pipelineStack.addDependency(roleStack);
770770
}

0 commit comments

Comments
 (0)