Previously, I was able to retrieve data from appConfig by using the variables that were hardcoded in config.ts.
Here is part of the config.ts:
//Used for appConfig
export const APP_CONFIG_APP_NAME = 'tableName';
export const APP_CONFIG_APP_IDENTIFIER = 'actual Identifier was written here';
export const APP_CONFIG_ENV_IDENTIFIER = 'actual Identifier was written here';
export const APP_CONFIG_PROFILE_IDENTIFIER = 'actual Identifier was written here';
And in my app-config-client.ts, I was passing in those variables in the StartConfigurationSessionCommand:
import { AppConfigDataClient, StartConfigurationSessionCommand,GetLatestConfigurationCommand } from '@aws-sdk/client-appconfigdata';
import { APP_CONFIG_APP_IDENTIFIER, APP_CONFIG_ENV_IDENTIFIER, APP_CONFIG_PROFILE_IDENTIFIER, APP_REGION } from '../../../config';
const client = new AppConfigDataClient({ region: APP_REGION });
export async function getToken(): Promise<string> {
try{
const getSession = new StartConfigurationSessionCommand ({
ApplicationIdentifier: APP_CONFIG_APP_IDENTIFIER,
EnvironmentIdentifier: APP_CONFIG_ENV_IDENTIFIER,
ConfigurationProfileIdentifier: APP_CONFIG_PROFILE_IDENTIFIER,
});
//console.log('Seding getSession command...');
const sessionToken = await client.send(getSession);
//console.log('Received session token: ', sessionToken);
const initialConfigurationToken = sessionToken.InitialConfigurationToken;
//console.log(initialConfigurationToken);
return initialConfigurationToken || "";
// return sessionToken.InitialConfigurationToken || "";
} catch (err) {
console.error('Error retrieving session token: ', err);
throw err;
}
}
What I want to do is instead of using those variables, I want to retrieve the identifiers dynamically, straight from appConfig. This is because When I run in staging or prod environments, the identifiers will be newly created in the infrastructure which will cause error eventually.
I am thinking maybe using arn might work but I'm not sure how do implement it. If there is a different/better way, would love to know.