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

feat(redshift): execute resource action #31995

Merged
merged 7 commits into from
Dec 2, 2024

Conversation

badmintoncryer
Copy link
Contributor

Issue # (if applicable)

None

Reason for this change

We can perform various Redshift operation by specifying ResourceAction prop but AWS CDK cannot do this.

https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-redshift-cluster.html#cfn-redshift-cluster-resourceaction

Description of changes

  • Define ResourceAction enum
  • Add resourceAction prop to ClusterProps

Description of how you validated changes

Add both unit and integ tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Nov 2, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team November 2, 2024 16:05
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Nov 2, 2024
Comment on lines 616 to 618
if (props.resourceAction === ResourceAction.FAILOVER_PRIMARY_COMPUTE && !props.multiAz) {
throw new Error('ResourceAction.FAILOVER_PRIMARY_COMPUTE can only be used with multi-AZ clusters.');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to execute failover for the single AZ cluster but I got a deployment error.

    const singleAzCluster = new redshiftAlpha.Cluster(this, 'SingleAzCluster', {
      vpc,
      vpcSubnets: {
        subnetType: ec2.SubnetType.PUBLIC,
      },
      masterUser: {
        masterUsername: 'admin',
      },
      nodeType: redshiftAlpha.NodeType.RA3_XLPLUS,
      publiclyAccessible: true,
    });

    const cfnSingleAzCluster = singleAzCluster.node.defaultChild as redshift.CfnCluster;
    cfnSingleAzCluster.addPropertyOverride('ResourceAction', 'failover-primary-compute');

Results:

8:50:18 | UPDATE_FAILED        | AWS::Redshift::Cluster                      | SingleAzCluster885C9BDD
Resource handler returned message: "Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "software.amazon.redshift
.cluster.ResourceModel.getMultiAZ()" is null" (RequestToken: d865c8ea-217c-ff00-0c71-1b659fdf6233, HandlerErrorCode: InternalFailure)

I also confirmed we can execute failover operation for a multi-AZ cluster.

@badmintoncryer badmintoncryer marked this pull request as ready for review November 3, 2024 00:04
if (props.resourceAction === ResourceAction.FAILOVER_PRIMARY_COMPUTE && !props.multiAz) {
throw new Error('ResourceAction.FAILOVER_PRIMARY_COMPUTE can only be used with multi-AZ clusters.');
}

this.cluster = new CfnCluster(this, 'Resource', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Ensure that user activity logging is enabled for the Redshift cluster. This feature logs each query before it is executed on the cluster's database. To activate this, associate a Redshift Cluster Parameter Group with the enable_user_activity_logging parameter set to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this feedback is inappropriate. This implementation is for existing L2 code, and to avoid breaking changes, we should not forcefully enable enable_user_activity_logging.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 4, 2024
@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Nov 8, 2024
GavinZZ
GavinZZ previously approved these changes Nov 29, 2024
Copy link
Contributor

mergify bot commented Nov 29, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@GavinZZ
Copy link
Contributor

GavinZZ commented Nov 29, 2024

@badmintoncryer There's some conflicts. Would you mind fixing the conflicts. I think this PR is good to merge!

@mergify mergify bot dismissed GavinZZ’s stale review December 2, 2024 13:41

Pull request has been modified.

@badmintoncryer
Copy link
Contributor Author

@GavinZZ Thanks for your review! I've resolved conflicts.

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.42%. Comparing base (24adca3) to head (eecaac9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #31995      +/-   ##
==========================================
- Coverage   78.46%   78.42%   -0.05%     
==========================================
  Files         106      106              
  Lines        7208     7208              
  Branches     1323     1323              
==========================================
- Hits         5656     5653       -3     
- Misses       1364     1368       +4     
+ Partials      188      187       -1     
Flag Coverage Δ
suite.unit 78.42% <ø> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 78.42% <ø> (-0.05%) ⬇️

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: eecaac9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Dec 2, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 2, 2024
Copy link
Contributor

mergify bot commented Dec 2, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@GavinZZ GavinZZ merged commit 40835a0 into aws:main Dec 2, 2024
18 of 20 checks passed
Copy link

github-actions bot commented Dec 2, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2024
@badmintoncryer badmintoncryer deleted the resource-action branch December 3, 2024 00:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants