-
Notifications
You must be signed in to change notification settings - Fork 30
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 option to take a snapshot of a managed service source cluster #1028
Add option to take a snapshot of a managed service source cluster #1028
Conversation
Signed-off-by: Mikayla Thompson <thomika@amazon.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1028 +/- ##
============================================
- Coverage 80.30% 80.28% -0.02%
- Complexity 2727 2728 +1
============================================
Files 366 366
Lines 13617 13617
Branches 942 942
============================================
- Hits 10935 10933 -2
- Misses 2108 2109 +1
- Partials 574 575 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -187,6 +187,31 @@ export function createDefaultECSTaskRole(scope: Construct, serviceName: string): | |||
return serviceTaskRole | |||
} | |||
|
|||
export function createSnapshotOnAOSRole(scope: Construct, artifactS3Arn: string, migrationConsoleTaskRoleArn: string): Role { | |||
const snapshotRole = new Role(scope, `SnapshotRole`, { | |||
assumedBy: new ServicePrincipal('es.amazonaws.com'), |
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.
Note: AOS doesn't support snapshots yet
export function createSnapshotOnAOSRole(scope: Construct, artifactS3Arn: string, migrationConsoleTaskRoleArn: string): Role { | ||
const snapshotRole = new Role(scope, `SnapshotRole`, { | ||
assumedBy: new ServicePrincipal('es.amazonaws.com'), | ||
description: 'Role that grants OpenSearch Service permissions to access S3 to create snapshots', |
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.
Can we add a deterministic name to avoid suffix? OSMigrations-new-cdk-us-east-2-SnapshotRole53D7C789-18fLjvR4jHRc
?
@@ -396,7 +421,7 @@ export function parseClusterDefinition(json: any): ClusterYaml { | |||
} | |||
const auth = parseAuth(json.auth) | |||
if (!auth) { | |||
throw new Error(`Invalid auth type when parsing cluster definition: ${json.auth.type}`) | |||
throw new Error(`Invalid auth type when parsing cluster definition: ${json.auth}`) |
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.
Can we hold on this change until the plaintext password option is removed from this?
@@ -324,6 +327,10 @@ export class MigrationConsoleStack extends MigrationServiceCore { | |||
...props | |||
}); | |||
|
|||
if (props.managedServiceSourceSnapshotEnabled) { | |||
const consoleServiceRoleName = "migration-console-TaskRole"; |
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.
Where is this used?
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.
Ah, not anymore, removing.
| reindexFromSnapshotServiceEnabled | boolean | true | Create resources for deploying and configuring the RFS ECS service | | ||
| reindexFromSnapshotExtraArgs | string | "--target-aws-region us-east-1 --target-aws-service-signing-name es" | Extra arguments to provide to the Document Migration command with space separation. See [RFS Arguments](../../../DocumentsFromSnapshotMigration/README.md#Arguments). [^1] | | ||
| sourceClusterEndpoint | string | `"https://source-cluster.elb.us-east-1.endpoint.com"` | The endpoint for the source cluster from which RFS will take a snapshot | | ||
| managedServiceSourceSnapshotEnabled | boolean | true | Create the necessary roles and trust relationships to take a snapshot of a managed service source cluster. This is only compatible with SigV4 auth. | |
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.
Do we want to make this a top level argument instead of within source cluster?
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.
I went back and forth on this--it's a combo of RFS-related and source-cluster related, so it didn't fit perfectly anywhere. Would you prefer in the source object?
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.
I'm good with this for now
Signed-off-by: Mikayla Thompson <thomika@amazon.com>
@@ -7,7 +7,7 @@ | |||
"type": "none | basic | sigv4", | |||
"// basic auth documentation": "The next two lines are releavant for basic auth only", | |||
"username": "<USERNAME>", | |||
"password_from_secret_arn": "<ARN_OF_SECRET_CONTAINING_PASSWORD>", | |||
"passwordFromSecretArn": "<ARN_OF_SECRET_CONTAINING_PASSWORD>", |
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.
Thanks for this, this could have really tripped up a customer
Description
We discovered that our existing CDK is not sufficient for taking a snapshot of a managed service source cluster. A specific snapshot role must be created, and there needs to be a trust relationship between the console task role and this snapshot role that allows it to be passed.
With this PR, if
managedServiceSourceSnapshotEnabled
is added to thecdk.context
astrue
, it sets up these roles and relationships.In this PR, it does not handle adding the relevant role arn to the services.yaml and passing it through automatically. That would be an excellent follow-up, but in this case I'm trying to focus on unblocking the particularly time-confusing and messy parts instead of making this a fully supported experience.
One of the caveats is that, to pass in the snapshot role, the source cluster must use sigv4 auth. I added a check for this in the CDK.
Manually tested:
Before:
With this enabled:
Issues Resolved
#2001
I also fix a dumb mistake I made in the sample
cdk.context.json
and make the logic aroundtargetVersion
vsengineVersion
cleaner. It was still requiring anengineVersion
in some cases where it really wasn't relevant.Testing
Manual.
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.