-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add source & target details to CDK #949
Add source & target details to CDK #949
Conversation
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #949 +/- ##
============================================
- Coverage 78.83% 78.62% -0.21%
- Complexity 2430 2520 +90
============================================
Files 372 387 +15
Lines 14489 15012 +523
Branches 875 923 +48
============================================
+ Hits 11422 11803 +381
- Misses 2531 2644 +113
- Partials 536 565 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
deployment/cdk/opensearch-service-migration/lib/migration-services-yaml.ts
Outdated
Show resolved
Hide resolved
const osContainerServiceEnabled = this.getContextForType('osContainerServiceEnabled', 'boolean', defaultValues, contextJSON) | ||
const otelCollectorEnabled = this.getContextForType('otelCollectorEnabled', 'boolean', defaultValues, contextJSON) | ||
const reindexFromSnapshotServiceEnabled = this.getContextForType('reindexFromSnapshotServiceEnabled', 'boolean', defaultValues, contextJSON) | ||
const reindexFromSnapshotExtraArgs = this.getContextForType('reindexFromSnapshotExtraArgs', 'string', defaultValues, contextJSON) | ||
const albAcmCertArn = this.getContextForType('albAcmCertArn', 'string', defaultValues, contextJSON); | ||
|
||
const sourceClusterDisabled = this.getContextForType('sourceClusterDisabled', 'boolean', defaultValues, contextJSON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all top level fields, what would be the level of effort to consolidate it into an object/nested object like we have in sourceClusterAuth.
e.g.
{
"sourceCluster": {
"auth": {
"type": "sigv4"
"region": "us-west-2"
"serviceSigningName": "es"
},
"endpoint": "https://source-cluster:9200",
"version" : "ES_7.10"
"disabled": false // optional/inferred
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this for parsing:
interface BasicAuth {
type: 'basic';
username: string;
password?: string;
passwordFromArn?: string;
}
interface SigV4Auth {
type: 'sigv4';
region: string;
serviceSigningName: string;
}
interface NoAuth {
type: 'none';
}
// Union type for all auth types
type Auth = BasicAuth | SigV4Auth | NoAuth;
// Function to parse and validate auth object
function parseAuth(json: any): Auth | null {
if (json.type === 'basic' && typeof json.username === 'string' && (typeof json.password === 'string' || typeof json.passwordFromArn === 'string') && !(typeof json.password === 'string' && typeof json.passwordFromArn === 'string')) {
return json as BasicAuth;
} else if (json.type === 'sigv4' && typeof json.region === 'string' && typeof json.serviceSigningName === 'string') {
return json as SigV4Auth;
} else if (json.type === 'none') {
return json as NoAuth;
} else {
return null; // Invalid auth type
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mikayla's comments:
I actually went the opposite way of having a single nested object because of your feedback in the previous version of this PR, but I'm happy to flip that. I like the single object more, and I like keeping the format here consistent with the services.yaml (but json).
Down the line, I'd love to pull all of the generate-a-target-cluster fields into a single object as well so it become super clear which approach is being used and which parameters contraindicate each other.
Offline Discussion
Discussed how we can address both concerns with keeping this as a single object while not immediately removing the flattened fields from the cdk.context.json to retain some compatibility with both ways of specifying for a short period.
throw new Error("The `engineVersion` can only be used when a domain is being provisioned by this tooling, which is contraindicated " + | ||
"by the `targetClusterEndpoint` being provided.") | ||
} | ||
const targetVersion = this.getEngineVersion(targetClusterEndpoint ? targetClusterVersion : engineVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using getEngineVersion
will probably be limiting for newer releases of opensearch or unsupported versions of elasticsearch: https://docs.aws.amazon.com/cdk/api/v2/java/software/amazon/awscdk/services/opensearchservice/EngineVersion.html. We may just want to enforce a format here for now
deployment/cdk/opensearch-service-migration/lib/stack-composer.ts
Outdated
Show resolved
Hide resolved
@@ -151,10 +151,6 @@ export class MigrationConsoleStack extends MigrationServiceCore { | |||
...props, | |||
parameter: MigrationSSMParameter.OS_CLUSTER_ENDPOINT, | |||
}); | |||
const sourceClusterEndpoint = props.sourceClusterDisabled ? null : getMigrationStringParameterValue(this, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General observation: Whenever we make the change to use the source cluster details that are provided by the user in constructing the commands for RFS,Fetch,Capture Proxy, etc. it seems like we can remove this SSM Parameter from being needed at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm hoping so! I'll do a more comprehensive look at whether we can pull it out of all of them.
deployment/cdk/opensearch-service-migration/lib/migration-services-yaml.ts
Show resolved
Hide resolved
deployment/cdk/opensearch-service-migration/lib/stack-composer.ts
Outdated
Show resolved
Hide resolved
@@ -151,10 +151,6 @@ export class MigrationConsoleStack extends MigrationServiceCore { | |||
...props, | |||
parameter: MigrationSSMParameter.OS_CLUSTER_ENDPOINT, | |||
}); | |||
const sourceClusterEndpoint = props.sourceClusterDisabled ? null : getMigrationStringParameterValue(this, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm hoping so! I'll do a more comprehensive look at whether we can pull it out of all of them.
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
deployment/cdk/opensearch-service-migration/lib/migration-services-yaml.ts
Show resolved
Hide resolved
deployment/cdk/opensearch-service-migration/lib/service-stacks/reindex-from-snapshot-stack.ts
Outdated
Show resolved
Hide resolved
}); | ||
replayerCommand = replayerCommand.concat(` --auth-header-user-and-secret ${osUserAndSecret}`) | ||
if (props.clusterAuthDetails.basicAuth) { | ||
replayerCommand = replayerCommand.concat(` --auth-header-user-and-secret ${props.clusterAuthDetails.basicAuth.username} ${props.clusterAuthDetails.basicAuth.password_from_secret_arn}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happened automatically with the string parameter, but we need to add "
around the value here for it to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks
} else if (targetClusterEndpoint || osContainerServiceEnabled) { | ||
targetEndpoint = targetClusterEndpoint ? targetClusterEndpoint : "https://opensearch:9200" | ||
let preexistingOrContainerTargetEndpoint | ||
if (targetCluster && osContainerServiceEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: reads strange that this block specifies targetCluster, but then uses targetClusterEndpoint instead of targetCluster?.endpoint
deployment/cdk/opensearch-service-migration/lib/stack-composer.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
a145cb6
to
7f7b686
Compare
deployment/cdk/opensearch-service-migration/lib/service-stacks/reindex-from-snapshot-stack.ts
Show resolved
Hide resolved
Signed-off-by: Mikayla Thompson <[email protected]>
Description
What it does:
Provides a mechanism for users to specify source & target cluster auth and version. Right now, the version is passed around internally but not added to any ECS commands or put into the services.yaml.
For the auth: it is passed around to all the necessary places and it is added to the services.yaml.
I focused on creating clear usage for the public case -- BYO Clusters -- at the expense of some overlapping fields in the non-public use case (creating a target cluster). I tried to integrate error checks to make it clear when two overlapping fields were being provided, so those cases should be clear to internal users.
Issues Resolved
MIGRATIONS-1909
Testing
[Please provide details of testing done: unit testing, integration testing and manual testing]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.