(aws-backup): Resolution error: stack.regionalFact is not a function
See original GitHub issueWhat is the problem?
Trying to follow the guide in https://docs.aws.amazon.com/cdk/api/v1/docs/aws-backup-readme.html to setup backups for tables.
Reproduction Steps
Here’s the simple stack file I tried to reproduce from given the backup guide mentioned above:
import * as cdk from "@aws-cdk/core";
import * as dynamodb from "@aws-cdk/aws-dynamodb";
import * as backup from "@aws-cdk/aws-backup";
export class DynamoTestStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id);
const plan = backup.BackupPlan.dailyWeeklyMonthly5YearRetention(
this,
"Plan"
);
const myTable = dynamodb.Table.fromTableName(this, 'Table', 'testtable');
plan.addSelection("Selection", {
resources: [backup.BackupResource.fromDynamoDbTable(myTable)]
});
}
}
What did you expect to happen?
cdk should have synthesized a template that has logic to backup the table.
What actually happened?
It errors out saying stack.regionalFact
isn’t a function although going through the source code shows it is here https://github.com/aws/aws-cdk/blob/77144f5a1072feea7409b4222fbc80bd2bc86e71/packages/%40aws-cdk/core/lib/stack.ts#L825 Tracing the issue, it may lie in aws-iam
rather than aws-backup
.
Stack trace (censored out identifying information from paths):
infra/cdk/node_modules/@aws-cdk/aws-backup/node_modules/@aws-cdk/aws-iam/lib/principals.ts:540
return stack.regionalFact(
^
TypeError: Resolution error: Resolution error: Resolution error: Resolution error: stack.regionalFact is not a function.
Object creation stack:
at stack traces disabled.
Object creation stack:
at stack traces disabled..
at ServicePrincipalToken.resolve (infra/cdk/node_modules/@aws-cdk/aws-backup/node_modules/@aws-cdk/aws-iam/lib/principals.ts:540:18)
at RememberingTokenResolver.resolveToken (infra/cdk/node_modules/@aws-cdk/core/lib/resolvable.ts:80:24)
at RememberingTokenResolver.resolveToken (infra/cdk/node_modules/@aws-cdk/core/lib/private/resolve.ts:286:18)
at resolve (infra/cdk/node_modules/@aws-cdk/core/lib/private/resolve.ts:212:51)
at Object.resolve [as mapToken] (infra/cdk/node_modules/@aws-cdk/core/lib/private/resolve.ts:119:77)
at TokenizedStringFragments.mapTokens (infra/cdk/node_modules/@aws-cdk/core/lib/string-fragments.ts:65:33)
at RememberingTokenResolver.resolveString (infra/cdk/node_modules/@aws-cdk/core/lib/resolvable.ts:99:22)
at RememberingTokenResolver.resolveString (infra/cdk/node_modules/@aws-cdk/core/lib/private/resolve.ts:290:23)
at resolve (infra/cdk/node_modules/@aws-cdk/core/lib/private/resolve.ts:170:48)
at Object.resolve (infra/cdk/node_modules/@aws-cdk/core/lib/private/resolve.ts:119:77)
CDK CLI Version
1.134.0 (build dd5e12d)
Framework Version
No response
Node.js Version
v16.13.0
OS
macOS Catalina
Language
Typescript
Language Version
3.9.7
Other information
Something interesting is that I looked around for other examples of this and came across this repository https://github.com/boostercloud/rocket-backup-aws-infrastructure I downgraded all of my aws-cdk packages to 1.67.0
to match their versions and cdk synth worked afterward. However, it’s unideal to be on version 1.67.0 due to other stacks.
Initially, my dependencies were 1.137.0
for aws-backup, aws-dynamodb, and aws-core.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
I am able to
cdk synth
the stack you provided successfully both on the latest v1 version (1.137).It’s likely that the issue is that your dependencies were not aligned.
stack.regionalFact
was added 20 days ago, and released in v 1.137. I was able to reproduce the error you are describing by forcing myaws-backup
dependency to1.137
while keepingcore
at1.136
. backup is searching for a function added in 1.137 but it only has 1.136 available.Please update
@aws-cdk/core
to1.137
. I’m almost certain that that will solve the issue.Something to note - if you use CDK v2, all the libraries are condensed into one package, and you won’t be able to run into these types of errors anymore!