Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: queue service name and secret name #118

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { EventSourceProps } from '../lib/workload/stateful/event_source/componen
const regName = 'OrcaBusSchemaRegistry';
const eventBusName = 'OrcaBusMain';
const lambdaSecurityGroupName = 'OrcaBusLambdaSecurityGroup';
const rdsMasterSecretName = 'orcabus/rds-master'; // pragma: allowlist secret

// Note, this should not end with a hyphen and 6 characters, otherwise secrets manager won't be
// able to find the secret using a partial ARN.
const rdsMasterSecretName = 'orcabus/master-rds'; // pragma: allowlist secret

const orcaBusStatefulConfig = {
schemaRegistryProps: {
Expand Down Expand Up @@ -90,12 +93,25 @@ interface EnvironmentConfig {
orcaBusStatelessConfig: OrcaBusStatelessConfig;
};
}

/**
* Validate the secret name so that it doesn't end with 6 characters and a hyphen.
*/
export const validateSecretName = (secretName: string) => {
// If there are more config validation requirements like this it might be good to use
// a dedicated library like zod.
if (/-(.){6}$/.test(secretName)) {
throw new Error('the secret name should not end with a hyphen and 6 characters');
}
};

export const getEnvironmentConfig = (
accountName: 'beta' | 'gamma' | 'prod'
): EnvironmentConfig | null => {
let config = null;
switch (accountName) {
case 'beta':
return {
config = {
name: 'beta',
accountId: '843407916570', // umccr_development
stackProps: {
Expand Down Expand Up @@ -126,9 +142,10 @@ export const getEnvironmentConfig = (
},
},
};
break;

case 'gamma':
return {
config = {
name: 'gamma',
accountId: '455634345446', // umccr_staging
stackProps: {
Expand All @@ -155,9 +172,10 @@ export const getEnvironmentConfig = (
orcaBusStatelessConfig: orcaBusStatelessConfig,
},
};
break;

case 'prod':
return {
config = {
name: 'prod',
accountId: '472057503814', // umccr_production
stackProps: {
Expand All @@ -182,8 +200,10 @@ export const getEnvironmentConfig = (
orcaBusStatelessConfig: orcaBusStatelessConfig,
},
};

default:
return null;
break;
}

validateSecretName(config.stackProps.orcaBusStatefulConfig.databaseProps.masterSecretName);

return config;
};
2 changes: 1 addition & 1 deletion lib/workload/orcabus-stateless-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class OrcaBusStatelessStack extends cdk.Stack {
Arn.format(
{
resource: dependencies.eventSourceQueueName,
service: 'Queue',
service: 'sqs',
},
this
)
Expand Down
Loading