Skip to content

Commit

Permalink
chore: migrate from deprecated CDK api (#12297)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolk authored Mar 23, 2023
1 parent 0aba514 commit 9f53e82
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
}

if (configureSMS) {
this.userPool.addDependsOn(this.snsRole!);
this.userPool.addDependency(this.snsRole!);
}

// updating Lambda Config when FF is (break circular dependency : false)
Expand Down Expand Up @@ -464,7 +464,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
this.userPoolClientWeb.writeAttributes = this._cfnParameterMap.get('userpoolClientWriteAttributes')?.valueAsList;
}
this.userPoolClientWeb.refreshTokenValidity = cdk.Fn.ref('userpoolClientRefreshTokenValidity') as unknown as number;
this.userPoolClientWeb.addDependsOn(this.userPool);
this.userPoolClientWeb.addDependency(this.userPool);

this.userPoolClient = new cognito.CfnUserPoolClient(this, 'UserPoolClient', {
userPoolId: cdk.Fn.ref('UserPool'),
Expand All @@ -479,7 +479,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
}
this.userPoolClient.refreshTokenValidity = cdk.Fn.ref('userpoolClientRefreshTokenValidity') as unknown as number;
this.userPoolClient.generateSecret = cdk.Fn.ref('userpoolClientGenerateSecret') as unknown as boolean;
this.userPoolClient.addDependsOn(this.userPool);
this.userPoolClient.addDependency(this.userPool);

this.createUserPoolClientCustomResource(props);
if (props.hostedUIDomainName) {
Expand Down Expand Up @@ -564,7 +564,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
authenticated: cdk.Fn.ref('authRoleArn'),
},
});
this.identityPoolRoleMap.addDependsOn(this.identityPool);
this.identityPoolRoleMap.addDependency(this.identityPool);
}
};

Expand Down Expand Up @@ -603,7 +603,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
],
},
});
this.userPoolClientRole.addDependsOn(this.userPoolClient!);
this.userPoolClientRole.addDependency(this.userPoolClient!);

// lambda function
this.userPoolClientLambda = new lambda.CfnFunction(this, 'UserPoolClientLambda', {
Expand All @@ -615,7 +615,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
runtime: 'nodejs16.x',
timeout: 300,
});
this.userPoolClientLambda.addDependsOn(this.userPoolClientRole);
this.userPoolClientLambda.addDependency(this.userPoolClientRole);

// userPool client lambda policy
/**
Expand All @@ -638,7 +638,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.userPoolClientLambdaPolicy.addDependsOn(this.userPoolClientLambda);
this.userPoolClientLambdaPolicy.addDependency(this.userPoolClientLambda);

// userPool Client Log policy

Expand All @@ -661,7 +661,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.userPoolClientLogPolicy.addDependsOn(this.userPoolClientLambdaPolicy);
this.userPoolClientLogPolicy.addDependency(this.userPoolClientLambdaPolicy);

// userPoolClient Custom Resource
this.userPoolClientInputs = new cdk.CustomResource(this, 'UserPoolClientInputs', {
Expand Down Expand Up @@ -689,7 +689,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
runtime: 'nodejs16.x',
timeout: 300,
});
this.hostedUICustomResource.addDependsOn(this.userPoolClientRole!);
this.hostedUICustomResource.addDependency(this.userPoolClientRole!);

// userPool client lambda policy
/**
Expand All @@ -716,7 +716,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.hostedUICustomResourcePolicy.addDependsOn(this.hostedUICustomResource);
this.hostedUICustomResourcePolicy.addDependency(this.hostedUICustomResource);

// userPool Client Log policy

Expand All @@ -738,7 +738,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.hostedUICustomResourceLogPolicy.addDependsOn(this.hostedUICustomResourcePolicy);
this.hostedUICustomResourceLogPolicy.addDependency(this.hostedUICustomResourcePolicy);

// userPoolClient Custom Resource
this.hostedUICustomResourceInputs = new cdk.CustomResource(this, 'HostedUICustomResourceInputs', {
Expand Down Expand Up @@ -770,7 +770,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
runtime: 'nodejs16.x',
timeout: 300,
});
this.hostedUIProvidersCustomResource.addDependsOn(this.userPoolClientRole!);
this.hostedUIProvidersCustomResource.addDependency(this.userPoolClientRole!);

// userPool client lambda policy
/**
Expand Down Expand Up @@ -802,7 +802,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.hostedUIProvidersCustomResourcePolicy.addDependsOn(this.hostedUIProvidersCustomResource);
this.hostedUIProvidersCustomResourcePolicy.addDependency(this.hostedUIProvidersCustomResource);

// userPool Client Log policy

Expand All @@ -824,7 +824,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.hostedUIProvidersCustomResourceLogPolicy.addDependsOn(this.hostedUIProvidersCustomResourcePolicy);
this.hostedUIProvidersCustomResourceLogPolicy.addDependency(this.hostedUIProvidersCustomResourcePolicy);

// userPoolClient Custom Resource
this.hostedUIProvidersCustomResourceInputs = new cdk.CustomResource(this, 'HostedUIProvidersCustomResourceInputs', {
Expand Down Expand Up @@ -877,7 +877,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.oAuthCustomResourcePolicy.addDependsOn(this.oAuthCustomResource);
this.oAuthCustomResourcePolicy.addDependency(this.oAuthCustomResource);

// Oauth Log policy

Expand All @@ -899,7 +899,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
roles: [cdk.Fn.ref('UserPoolClientRole')],
});
this.oAuthCustomResourceLogPolicy.addDependsOn(this.oAuthCustomResourcePolicy);
this.oAuthCustomResourceLogPolicy.addDependency(this.oAuthCustomResourcePolicy);

// oAuth Custom Resource
this.oAuthCustomResourceInputs = new cdk.CustomResource(this, 'OAuthCustomResourceInputs', {
Expand Down Expand Up @@ -972,7 +972,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
},
],
});
this.mfaLambdaRole.addDependsOn(this.snsRole!);
this.mfaLambdaRole.addDependency(this.snsRole!);
// lambda function
/**
* Lambda which sets MFA config values
Expand All @@ -987,7 +987,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
runtime: 'nodejs16.x',
timeout: 300,
});
this.mfaLambda.addDependsOn(this.mfaLambdaRole);
this.mfaLambda.addDependency(this.mfaLambdaRole);

// MFA lambda policy
/**
Expand Down Expand Up @@ -1015,7 +1015,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
).toString(),
],
});
this.mfaLambdaPolicy.addDependsOn(this.mfaLambda);
this.mfaLambdaPolicy.addDependency(this.mfaLambda);

// mfa Log policy

Expand Down Expand Up @@ -1043,7 +1043,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
).toString(),
],
});
this.mfaLogPolicy.addDependsOn(this.mfaLambdaPolicy);
this.mfaLogPolicy.addDependency(this.mfaLambdaPolicy);

// mfa Custom Resource
/**
Expand Down Expand Up @@ -1130,7 +1130,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
runtime: 'nodejs16.x',
timeout: 300,
});
this.openIdLambda.addDependsOn(this.openIdLambdaRole);
this.openIdLambda.addDependency(this.openIdLambdaRole);

// OPenId lambda policy
/**
Expand Down Expand Up @@ -1168,7 +1168,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
).toString(),
],
});
this.openIdLambdaIAMPolicy.addDependsOn(this.openIdLambda);
this.openIdLambdaIAMPolicy.addDependency(this.openIdLambda);

// openId Log policy
/**
Expand Down Expand Up @@ -1201,7 +1201,7 @@ export class AmplifyAuthCognitoStack extends cdk.Stack implements AmplifyAuthCog
).toString(),
],
});
this.openIdLogPolicy.addDependsOn(this.openIdLambdaIAMPolicy);
this.openIdLogPolicy.addDependency(this.openIdLambdaIAMPolicy);

// openId Custom Resource
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const cdkV1PrepareAppShim = (root: IConstruct): void => {

for (const target of targetCfnResources) {
for (const source of sourceCfnResources) {
source.addDependsOn(target);
source.addDependency(target);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
const newLambdaConfigurations = this.buildLambdaConfigFromTriggerParams(triggerLambdaFunctionParams);
this._addNotificationsLambdaConfigurations(newLambdaConfigurations);
this.triggerLambdaPermissions = this.createInvokeFunctionS3Permission('TriggerPermissions', this._props.triggerFunction);
this.s3Bucket.addDependsOn(this.triggerLambdaPermissions as lambdaCdk.CfnPermission);
this.s3Bucket.addDependency(this.triggerLambdaPermissions as lambdaCdk.CfnPermission);
/**
* Add Depends On: FUNCTION service
* s3 Dependency on Lambda to Root Stack
Expand All @@ -201,7 +201,7 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
'AdminTriggerPermissions',
this._props.adminTriggerFunction.triggerFunction,
);
this.s3Bucket.addDependsOn(this.adminTriggerLambdaPermissions);
this.s3Bucket.addDependency(this.adminTriggerLambdaPermissions);

/**
* Add Depends On: FUNCTION service
Expand Down Expand Up @@ -1008,7 +1008,7 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
policyL1.Properties.policyDocument.Statement = policyStatements;
const policy = new iamCdk.CfnPolicy(this, policyDefinition.logicalId, policyL1.Properties);
if (policyDefinition.dependsOn) {
policyDefinition.dependsOn.map((dependency) => policy.addDependsOn(dependency));
policyDefinition.dependsOn.map((dependency) => policy.addDependency(dependency));
}
if (policyDefinition.condition) {
policy.cfnOptions.condition = policyDefinition.condition;
Expand All @@ -1027,7 +1027,7 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
};
const policy = new iamCdk.CfnPolicy(this, policyDefinition.logicalId, props); // bind policy to stack
if (policyDefinition.dependsOn) {
policyDefinition.dependsOn.map((dependency) => policy.addDependsOn(dependency));
policyDefinition.dependsOn.map((dependency) => policy.addDependency(dependency));
}
if (policyDefinition.condition) {
policy.cfnOptions.condition = policyDefinition.condition;
Expand Down

0 comments on commit 9f53e82

Please sign in to comment.