@fjall/components-infrastructure 2.7.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,7 +12,8 @@ export interface DisasterRecoveryProps {
|
|
|
12
12
|
customBackupPlans?: CustomBackupPlanConfig[];
|
|
13
13
|
}
|
|
14
14
|
export declare class DisasterRecovery extends Construct {
|
|
15
|
-
readonly backupVault
|
|
15
|
+
readonly backupVault?: BackupVault;
|
|
16
|
+
private readonly vaultRef;
|
|
16
17
|
readonly backupPlans: {
|
|
17
18
|
standard: BackupPlan;
|
|
18
19
|
resilient: BackupPlan;
|
|
@@ -29,7 +29,10 @@ const VAULT_LOCK = {
|
|
|
29
29
|
GRACE_PERIOD: Duration.days(3)
|
|
30
30
|
};
|
|
31
31
|
export class DisasterRecovery extends Construct {
|
|
32
|
+
// Set in create-mode only; in adopt-mode the existing vault is referenced, not created.
|
|
32
33
|
backupVault;
|
|
34
|
+
// Vault the plans write to: created vault (create-mode) or imported handle (adopt-mode).
|
|
35
|
+
vaultRef;
|
|
33
36
|
backupPlans;
|
|
34
37
|
customBackupPlans;
|
|
35
38
|
constructor(scope, id, props) {
|
|
@@ -38,6 +41,9 @@ export class DisasterRecovery extends Construct {
|
|
|
38
41
|
const providerAccounts = config.providerAccounts;
|
|
39
42
|
const account = providerAccounts.find((pa) => pa.id === props.accountId);
|
|
40
43
|
const isComplianceAccount = account?.environment === "compliance";
|
|
44
|
+
// Set by the deploy orchestration after probing DescribeBackupVault: adopt the
|
|
45
|
+
// retained fixed-name vault by reference rather than re-CREATE it (which collides).
|
|
46
|
+
const adoptExistingVault = this.node.tryGetContext("fjallAdoptBackupVault") === "true";
|
|
41
47
|
const disasterRecoveryRegion = config.disasterRecoveryRegion;
|
|
42
48
|
// Look up compliance account for cross-account replication
|
|
43
49
|
// Skip if the compliance account (prevent self-replication)
|
|
@@ -56,14 +62,20 @@ export class DisasterRecovery extends Construct {
|
|
|
56
62
|
changeableFor: VAULT_LOCK.GRACE_PERIOD
|
|
57
63
|
}
|
|
58
64
|
: undefined;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (adoptExistingVault) {
|
|
66
|
+
this.vaultRef = Vault.fromBackupVaultName(this, "BackupVault", BACKUP_VAULT_NAME);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.backupVault = new BackupVault(this, "BackupVault", {
|
|
70
|
+
vaultName: BACKUP_VAULT_NAME,
|
|
71
|
+
removalPolicy: RemovalPolicy.RETAIN,
|
|
72
|
+
lockConfiguration: lockConfiguration
|
|
73
|
+
});
|
|
74
|
+
this.vaultRef = this.backupVault.vault;
|
|
75
|
+
}
|
|
76
|
+
// Cross-account access policy — create-mode only. addToAccessPolicy is unavailable
|
|
77
|
+
// on an imported vault, and a live (locked) vault retains the grant written at creation.
|
|
78
|
+
if (this.backupVault && isComplianceAccount) {
|
|
67
79
|
const allAccounts = providerAccounts;
|
|
68
80
|
const productionAccounts = allAccounts.filter((acc) => acc.environment === "production");
|
|
69
81
|
if (productionAccounts.length > 0) {
|
|
@@ -87,19 +99,19 @@ export class DisasterRecovery extends Construct {
|
|
|
87
99
|
planName: "standard",
|
|
88
100
|
rules: this.createStandardBackupRules("standard"),
|
|
89
101
|
tagValue: "default",
|
|
90
|
-
backupVault: this.
|
|
102
|
+
backupVault: this.vaultRef
|
|
91
103
|
}),
|
|
92
104
|
resilient: new BackupPlan(this, "ResilientBackupPlan", {
|
|
93
105
|
planName: "resilient",
|
|
94
106
|
rules: this.createResilientBackupRules("resilient", replicationVaultArn),
|
|
95
107
|
tagValue: "resilient",
|
|
96
|
-
backupVault: this.
|
|
108
|
+
backupVault: this.vaultRef
|
|
97
109
|
}),
|
|
98
110
|
enterprise: new BackupPlan(this, "EnterpriseBackupPlan", {
|
|
99
111
|
planName: "enterprise",
|
|
100
112
|
rules: this.createEnterpriseBackupRules("enterprise", replicationVaultArn, disasterRecoveryVaultArn),
|
|
101
113
|
tagValue: "enterprise",
|
|
102
|
-
backupVault: this.
|
|
114
|
+
backupVault: this.vaultRef
|
|
103
115
|
})
|
|
104
116
|
};
|
|
105
117
|
// Create custom backup plans if provided
|
|
@@ -109,7 +121,7 @@ export class DisasterRecovery extends Construct {
|
|
|
109
121
|
planName: config.planName,
|
|
110
122
|
rules: config.rules,
|
|
111
123
|
tagValue: config.tagValue,
|
|
112
|
-
backupVault: this.
|
|
124
|
+
backupVault: this.vaultRef
|
|
113
125
|
});
|
|
114
126
|
});
|
|
115
127
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { CfnOutput } from "aws-cdk-lib";
|
|
3
|
-
import { BackupPlan as Plan, BackupSelection, type BackupPlanRule } from "aws-cdk-lib/aws-backup";
|
|
4
|
-
import { type BackupVault } from "./backupVault.js";
|
|
3
|
+
import { BackupPlan as Plan, BackupSelection, type BackupPlanRule, type IBackupVault } from "aws-cdk-lib/aws-backup";
|
|
5
4
|
export interface BackupPlanProps {
|
|
6
5
|
planName: string;
|
|
7
6
|
rules: BackupPlanRule[];
|
|
8
|
-
backupVault:
|
|
7
|
+
backupVault: IBackupVault;
|
|
9
8
|
tagValue: string;
|
|
10
9
|
tagKey?: string;
|
|
11
10
|
}
|
|
@@ -12,7 +12,7 @@ export class BackupPlan extends Construct {
|
|
|
12
12
|
const tagKey = props.tagKey || BACKUP_TIER_TAG_KEY;
|
|
13
13
|
this.plan = new Plan(this, `${props.planName}Plan`, {
|
|
14
14
|
backupPlanName: props.planName,
|
|
15
|
-
backupVault: props.backupVault
|
|
15
|
+
backupVault: props.backupVault,
|
|
16
16
|
backupPlanRules: props.rules
|
|
17
17
|
});
|
|
18
18
|
this.selection = new BackupSelection(this, `${props.planName}Selection`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjall/components-infrastructure",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@aws-sdk/client-organizations": "^3.1038.0",
|
|
66
|
-
"@fjall/generator": "^2.
|
|
67
|
-
"@fjall/util": "^2.
|
|
66
|
+
"@fjall/generator": "^2.9.0",
|
|
67
|
+
"@fjall/util": "^2.9.0",
|
|
68
68
|
"constructs": "^10.0.0",
|
|
69
69
|
"uuid": "^14.0.0"
|
|
70
70
|
},
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=18.0.0"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "72c4668ef5ead59c0b981eca8037620875bcd1ba"
|
|
83
83
|
}
|