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(route53-targets): deprecated method for dns name is used in userpool domain target (under feature flag) #31403

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Sep 11, 2024

Reason for this change

The PR created a new method to get CloudFront DNS name in Cognito user pool domain. A custom resource is created in the old method, but is not in the new method.

However, the UserPoolDomainTarget in the route53-targets module continues to use the old method. So we should change to use the new method.

Description of changes

The bind method in the UserPoolDomainTarget implements IAliasRecordTarget interface, so a new method instead of the bind cannot be created.

Therefore, I take it using a feature flag.

Description of how you validated changes

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

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

mergify bot pushed a commit that referenced this pull request Nov 27, 2024
…ithout custom resource (#31402)

### Issue # (if applicable)

Closes #31342.

### Reason for this change



`UserPoolDomain` creates a custom resource to get CloudFront endpoint. However, CFn exposes the attribute natively now (see the issue). No custom resource is better if it is not needed.

### Description of changes



I propose a new method `cloudFrontEndpoint` without a custom resource.

Three ways were originally considered. This method was chosen as it was the most reasonable of all.

#### 1. Create a new method

This is the method submitted in this PR.

#### 2. Rewrite an existing method directly

This causes destructive changes. Custom resources are not directly used in the user's application. However, this change will result in resource deletion in the user's CDK stack. This causes confusion for users and should be avoided.

Also, the existing integ tests that use the method will fail because the changes are considered as destructive changes.

```
Tests:    1 failed, 1 total
Failed: /aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-domain-cfdist.js
!!! This test contains destructive changes !!!
    Stack: integ-user-pool-domain-cfdist - Resource: UserPoolDomainCloudFrontDomainNameE213E594 - Impact: WILL_DESTROY
    Stack: integ-user-pool-domain-cfdist - Resource: UserPoolDomainCloudFrontDomainNameCustomResourcePolicy7DE54188 - Impact: WILL_DESTROY
    Stack: integ-user-pool-domain-cfdist - Resource: AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2 - Impact: WILL_DESTROY
    Stack: integ-user-pool-domain-cfdist - Resource: AWS679f53fac002430cb0da5b7982bd22872D164C4C - Impact: WILL_DESTROY
!!! If these destructive changes are necessary, please indicate this on the PR !!!
Error: Some changes were destructive!
    at main (/aws-cdk/packages/@aws-cdk/integ-runner/lib/cli.js:183:15)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

#### 3. Rewrite an existing method with a feature flag

An alternative to way 2, but a feature flag was avoided in this case as it leads to complexity. The [design guidelines](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md#dealing-with-breaking-behavior-changes) also recommend a new method.

### Additional information

I avoided the feature flag in this PR, but there are situations where there are constructs that use an existing method, but cannot provide a new method for the constructs because it is used by a method implemented in the interface. 

https://github.com/go-to-k/aws-cdk/blob/fcbdc769e681f1f915cdc8cd7aa3a565d807884d/packages/aws-cdk-lib/aws-route53-targets/lib/userpool-domain.ts#L14

I will make changes to those cases using a feature flag in a separate PR.

#31403

### Description of how you validated changes



Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@go-to-k go-to-k marked this pull request as ready for review November 27, 2024 02:41
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.66%. Comparing base (06cdaac) to head (3d846ad).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #31403   +/-   ##
=======================================
  Coverage   78.66%   78.66%           
=======================================
  Files         107      107           
  Lines        7237     7237           
  Branches     1329     1329           
=======================================
  Hits         5693     5693           
  Misses       1358     1358           
  Partials      186      186           
Flag Coverage Δ
suite.unit 78.66% <ø> (ø)

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

Components Coverage Δ
packages/aws-cdk 78.66% <ø> (ø)

@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 27, 2024
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

1 similar comment
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@nmussy
Copy link
Contributor

nmussy commented Dec 10, 2024

I didn't have a long enough look to give a meaningful review, but I'm not sure "new method" is descriptive enough. Not to mention that we might add "newer" method flags in the future

@go-to-k
Copy link
Contributor Author

go-to-k commented Dec 10, 2024

@nmussy

You're absolutely right (I hadn't really thought about it properly...). I have corrected it as such.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

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

LGTM. It might be better to rename the feature flag to say what it does vs what it doesn't do anymore, ie. attribute referencing vs CR lookup, but I'll let maintainers weigh in on this

Comment on lines +32 to +34
new IntegTest(app, 'userpool-domain-alias-target-integ', {
testCases: [stack],
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to ask to add a test to make sure the CR wasn't created, but you're already checking for it in the unit test, so it might be overkill

https://github.com/aws/aws-cdk/pull/31403/files#diff-d39a13fcbdb9a308f6017d9800b5f4244d21103d76b708c68d84226d0172faeaR78-R79

@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 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants