async function fetchConfig()

in lambdas/src/MembershipSub-PromoCode-View-Dynamo-to-Salesforce.js [224:240]


async function fetchConfig(stage) {
    const client = new SecretsManagerClient({
        region: "eu-west-1",
    });

    const SecretId = `${stage}/Salesforce/User/PromoCodeLambda`;

    return client.send(new GetSecretValueCommand({
        SecretId,
    })).then(response => {
        const config = JSON.parse(response.SecretString)
        console.log('Fetched config from Secrets Manager');
        return config;
    }).catch(err => {
        return Promise.reject(`Failed to fetch config with ID: ${SecretId}. Error was: ${err}`);
    });
}