Skip to content

Commit

Permalink
Merge branch 'main' into njwe-2618/etpl-add-local-indemand-passaic-co…
Browse files Browse the repository at this point in the history
…unty
  • Loading branch information
ChelseaKR authored Jan 22, 2025
2 parents 989ddc2 + 423d4f9 commit aaf1d1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion backend/src/contentful/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { GraphQLClient } from "graphql-request";
import dotenv from "dotenv"

dotenv.config()

export const contentfulClient = ({
query,
variables,
Expand Down Expand Up @@ -26,8 +30,9 @@ export const contentfulClient = ({
if (excludeInvalid) {
headers["X-Exclude-Invalid"] = "true";
}
const environment = process.env.ENVIRONMENT || "master";
const client = new GraphQLClient(
`https://${process.env.BASE_URL}/${process.env.SPACE_ID}`,
`https://${process.env.BASE_URL}/${process.env.SPACE_ID}/environments/${environment}`,
{
headers,
},
Expand Down
12 changes: 8 additions & 4 deletions backend/src/utils/secretManager.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import AWS from 'aws-sdk';
import dotenv from 'dotenv';

dotenv.config();

// Configure AWS SDK and create SecretsManager instance
AWS.config.update({ region: 'us-east-1' });
const secretsManager = new AWS.SecretsManager();

export async function getContentfulAccessToken(): Promise<string> {
console.log('Retrieving secret for Contentful access token...');

const environment = process.env.ENVIRONMENT || 'master'; // Default to 'master'
const secretEnvironment = environment === 'master' ? 'prod' : environment;
const secretId = `mycareernj-contentful-token-${secretEnvironment}`;
try {
// Log the request details for debugging
console.log(`Requesting secret value for ID: 'mycareernj-contentful-token-prod'`);
console.log(`Requesting secret value for ID: '${secretId}'`);

const data = await secretsManager.getSecretValue({ SecretId: 'mycareernj-contentful-token-prod' }).promise();
const data = await secretsManager.getSecretValue({ SecretId: secretId }).promise();

if (data.SecretString) {
console.log('Secret string found, returning the secret value.');
Expand Down

0 comments on commit aaf1d1a

Please sign in to comment.