"use strict";
/*
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable no-new */
const fs_1 = __importDefault(require("fs"));
const path_1 = require("path");
const aws_cdk_lib_1 = require("aws-cdk-lib");
const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
const js_yaml_1 = __importDefault(require("js-yaml"));
const constants_1 = require("../constants");
class Workflow {
    constructor(stack) {
        this._stack = stack;
    }
    createSSMDocuments() {
        const { SSM_DOC_OUTPUT_KEY_SUFFIX } = (0, constants_1.getConstants)();
        // Add your new environment type here. The name should exactly match the folder name of the new environment type in the environment folder
        const envTypes = ['sagemakerNotebook'];
        envTypes.forEach((envType) => {
            const docTypes = ['Launch', 'Terminate'];
            docTypes.forEach((docType) => {
                const ssmDoc = js_yaml_1.default.load(
                // eslint-disable-next-line security/detect-non-literal-fs-filename
                fs_1.default.readFileSync((0, path_1.join)(__dirname, `../../../src/environment/${envType}/${envType}${docType}SSM.yaml`), 'utf8'));
                const cfnDoc = new aws_ssm_1.CfnDocument(this._stack, `${this._capitalizeFirstLetter(envType)}${docType}`, {
                    content: ssmDoc,
                    documentType: 'Automation',
                    updateMethod: 'NewVersion'
                });
                new aws_cdk_lib_1.CfnOutput(this._stack, `${this._capitalizeFirstLetter(envType)}${docType}${SSM_DOC_OUTPUT_KEY_SUFFIX}`, {
                    value: this._stack.formatArn({
                        service: 'ssm',
                        resource: 'document',
                        resourceName: cfnDoc.ref
                    })
                });
            });
        });
    }
    _capitalizeFirstLetter(word) {
        return word.charAt(0).toUpperCase() + word.slice(1);
    }
}
exports.default = Workflow;
//# sourceMappingURL=workflow.js.map