Skip to content

Commit

Permalink
Allow user agent from env (opensearch-project#435)
Browse files Browse the repository at this point in the history
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
  • Loading branch information
lewijacn authored Nov 16, 2023
1 parent f8dcf96 commit bc3f775
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions deployment/cdk/opensearch-service-migration/bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const migrationsAppRegistryARN = process.env.MIGRATIONS_APP_REGISTRY_ARN
if (migrationsAppRegistryARN) {
console.info(`App Registry mode is enabled for CFN stack tracking. Will attempt to import the App Registry application from the MIGRATIONS_APP_REGISTRY_ARN env variable of ${migrationsAppRegistryARN} and looking in the configured region of ${region}`)
}
const customReplayerUserAgent = process.env.CUSTOM_REPLAYER_USER_AGENT

new StackComposer(app, {
migrationsAppRegistryARN: migrationsAppRegistryARN,
customReplayerUserAgent: customReplayerUserAgent,
env: { account: account, region: region }
});
15 changes: 12 additions & 3 deletions deployment/cdk/opensearch-service-migration/lib/stack-composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import {Application} from "@aws-cdk/aws-servicecatalogappregistry-alpha";

export interface StackPropsExt extends StackProps {
readonly stage: string,
readonly defaultDeployId: string
readonly defaultDeployId: string,
readonly addOnMigrationDeployId?: string
}

export interface StackComposerProps extends StackProps {
readonly migrationsAppRegistryARN?: string
readonly migrationsAppRegistryARN?: string,
readonly customReplayerUserAgent?: string
}

export class StackComposer {
Expand Down Expand Up @@ -192,6 +193,14 @@ export class StackComposer {
throw new Error("Provided domainRemovalPolicy does not match a selectable option, for reference https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html")
}

let trafficReplayerCustomUserAgent
if (props.customReplayerUserAgent && trafficReplayerUserAgentSuffix) {
trafficReplayerCustomUserAgent = `${props.customReplayerUserAgent};${trafficReplayerUserAgentSuffix}`
}
else {
trafficReplayerCustomUserAgent = trafficReplayerUserAgentSuffix ? trafficReplayerUserAgentSuffix : props.customReplayerUserAgent
}

const deployId = addOnMigrationDeployId ? addOnMigrationDeployId : defaultDeployId

// If enabled re-use existing VPC and/or associated resources or create new
Expand Down Expand Up @@ -398,7 +407,7 @@ export class StackComposer {
enableClusterFGACAuth: trafficReplayerEnableClusterFGACAuth,
addOnMigrationDeployId: addOnMigrationDeployId,
customKafkaGroupId: trafficReplayerGroupId,
userAgentSuffix: trafficReplayerUserAgentSuffix,
userAgentSuffix: trafficReplayerCustomUserAgent,
extraArgs: trafficReplayerExtraArgs,
analyticsServiceEnabled: migrationAnalyticsServiceEnabled,
stackName: `OSMigrations-${stage}-${region}-${deployId}-TrafficReplayer`,
Expand Down

0 comments on commit bc3f775

Please sign in to comment.