Skip to content

Commit

Permalink
restore compatiblity with CDK 2.30.0 (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
udondan committed Jul 3, 2022
1 parent 9053659 commit 559ca47
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG/v0.391.0.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Fix compatibility with CDK.

:warning: Due to changes in AWS CDK, there is no compatible version for CDK 2.29.x.

Starting with CDK 2.30.0 you have to use at least this version! If you use any older version, all statements will be empty!

---

**New actions:**

- wellarchitected:UpdateGlobalSettings
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ There are two different package variants available:

Starting with CDK v1.152.0 you have to use cdk-iam-floyd v0.286.0.<br>
Starting with CDK v2.20.0 you have to use cdk-iam-floyd >= v0.351.0.<br>
Starting with CDK v2.26.0 you have to use cdk-iam-floyd >= v0.377.0.
Starting with CDK v2.26.0 you have to use cdk-iam-floyd >= v0.377.0.<br>
**There is no compatible version available for CDK v2.29.x!**<br>
Starting with CDK v2.30.0 you have to use cdk-iam-floyd >= v0.391.0.

Find them all on [libraries.io].

Expand Down
3 changes: 3 additions & 0 deletions docs/source/packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ There are two different package variants available:

Starting with CDK v2.26.0 you have to use cdk-iam-floyd >= v0.377.0.

**There is no compatible version available for CDK v2.29.x!**<br>
Starting with CDK v2.30.0 you have to use cdk-iam-floyd >= v0.391.0.

Find them all on `libraries.io`_.
9 changes: 9 additions & 0 deletions lib/shared/policy-statement/2-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export class PolicyStatementWithCondition extends PolicyStatementBase {
return super.toStatementJson();
}

public freeze() {
// @ts-ignore only available after swapping 1-base
if (!this.frozen) {
this.cdkApplyConditions();
}
// @ts-ignore only available after swapping 1-base
return super.freeze();
}

private cdkApplyConditions() {
if (this.hasConditions() && !this.cdkConditionsApplied) {
Object.keys(this.floydConditions).forEach((operator) => {
Expand Down
8 changes: 8 additions & 0 deletions lib/shared/policy-statement/3-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export class PolicyStatementWithActions extends PolicyStatementWithCondition {
return super.toStatementJson();
}

public freeze() {
// @ts-ignore only available after swapping 1-base
if (!this.frozen) {
this.cdkApplyActions();
}
return super.freeze();
}

private cdkApplyActions() {
if (!this.cdkActionsApplied) {
const mode = this.useNotAction ? 'addNotActions' : 'addActions';
Expand Down
18 changes: 9 additions & 9 deletions lib/shared/policy-statement/4-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ export class PolicyStatementWithResources extends PolicyStatementWithActions {
return super.toStatementJson();
}

public freeze() {
// @ts-ignore only available after swapping 1-base
if (!this.frozen) {
this.ensureResource();
this.cdkApplyResources();
}
return super.freeze();
}

private cdkApplyResources() {
if (!this.cdkResourcesApplied) {
const mode = this.useNotResource ? 'addNotResources' : 'addResources';
Expand Down Expand Up @@ -113,13 +122,4 @@ export class PolicyStatementWithResources extends PolicyStatementWithActions {
// a statement requires resources. if none was added, we assume the user wants all resources
this.onAllResources();
}

/**
* Dummy method. Will be overridden by 6-principal.ts
*
* We just need it here so we can reference it in method `ensureResource`
*/
public hasPrincipals(): boolean {
return false;
}
}
8 changes: 8 additions & 0 deletions lib/shared/policy-statement/6-principals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export class PolicyStatementWithPrincipal extends PolicyStatementWithEffect {
return super.toStatementJson();
}

public freeze() {
// @ts-ignore only available after swapping 1-base
if (!this.frozen) {
this.cdkApplyPrincipals();
}
return super.freeze();
}

protected cdkApplyPrincipals() {}

/**
Expand Down

0 comments on commit 559ca47

Please sign in to comment.