"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const resource_policy_1 = require("./resource-policy");
var RemovalPolicy;
(function (RemovalPolicy) {
    /**
     * This is the default removal policy for most resources. It means that when the resource
     * is removed from the app, it will be physically destroyed.
     */
    RemovalPolicy[RemovalPolicy["Destroy"] = 0] = "Destroy";
    /**
     * This uses the 'Retain' DeletionPolicy, which will cause the resource to be retained
     * in the account, but orphaned from the stack.
     */
    RemovalPolicy[RemovalPolicy["Orphan"] = 1] = "Orphan";
    /**
     * This will apply the 'Retain' DeletionPolicy and also add metadata for the toolkit
     * to apply a CloudFormation stack policy which forbids the deletion of resource.
     */
    RemovalPolicy[RemovalPolicy["Forbid"] = 2] = "Forbid";
})(RemovalPolicy = exports.RemovalPolicy || (exports.RemovalPolicy = {}));
function applyRemovalPolicy(resource, removalPolicy) {
    if (removalPolicy === RemovalPolicy.Orphan || removalPolicy === RemovalPolicy.Forbid) {
        resource.options.deletionPolicy = resource_policy_1.DeletionPolicy.Retain;
    }
    // attach metadata that will tell the toolkit to protect this resource by
    // applying an appropriate stack update policy.
    if (removalPolicy === RemovalPolicy.Forbid) {
        resource.addMetadata('aws:cdk:protected', true);
    }
}
exports.applyRemovalPolicy = applyRemovalPolicy;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtb3ZhbC1wb2xpY3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJyZW1vdmFsLXBvbGljeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLHVEQUFtRDtBQUVuRCxJQUFZLGFBa0JYO0FBbEJELFdBQVksYUFBYTtJQUNyQjs7O09BR0c7SUFDSCx1REFBVyxDQUFBO0lBRVg7OztPQUdHO0lBQ0gscURBQU0sQ0FBQTtJQUVOOzs7T0FHRztJQUNILHFEQUFNLENBQUE7QUFDVixDQUFDLEVBbEJXLGFBQWEsR0FBYixxQkFBYSxLQUFiLHFCQUFhLFFBa0J4QjtBQUVELFNBQWdCLGtCQUFrQixDQUFDLFFBQWtCLEVBQUUsYUFBd0M7SUFDM0YsSUFBSSxhQUFhLEtBQUssYUFBYSxDQUFDLE1BQU0sSUFBSSxhQUFhLEtBQUssYUFBYSxDQUFDLE1BQU0sRUFBRTtRQUNsRixRQUFRLENBQUMsT0FBTyxDQUFDLGNBQWMsR0FBRyxnQ0FBYyxDQUFDLE1BQU0sQ0FBQztLQUMzRDtJQUVELHlFQUF5RTtJQUN6RSwrQ0FBK0M7SUFDL0MsSUFBSSxhQUFhLEtBQUssYUFBYSxDQUFDLE1BQU0sRUFBRTtRQUN4QyxRQUFRLENBQUMsV0FBVyxDQUFDLG1CQUFtQixFQUFFLElBQUksQ0FBQyxDQUFDO0tBQ25EO0FBQ0wsQ0FBQztBQVZELGdEQVVDIn0=