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: allow to register an existing record created manually as an alias ARecord target #29565

Merged
merged 12 commits into from
Apr 26, 2024

Conversation

shikha372
Copy link
Contributor

@shikha372 shikha372 commented Mar 21, 2024

Issue # (if applicable)

Closes #23048.

Reason for this change

Currently an existing A record created outside of CDK cannot be registered as an Alias Target under a new A record, while this is possible through AWS console.

Description of changes

Introduces new function under class Arecord which will take input as existing record DNS name and then register it as an alias target under new Arecord. This way user will be able to alias an existing record (for type ARecord only).

Description of how you validated changes

  • Added Unit tests to validate new A record is created with an alias target passed through new function
  • Added Integration test for the alias target validation in template and after deployment to account.

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 bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Mar 21, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team March 21, 2024 01:25
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 21, 2024
@shikha372 shikha372 marked this pull request as ready for review April 1, 2024 17:21
@paulhcsun paulhcsun self-assigned this Apr 23, 2024
packages/aws-cdk-lib/aws-route53/README.md Show resolved Hide resolved
constructor(private readonly ArecordAttrs: ARecordAttrs) {
}

public bind(_record: IRecordSet, _zone?: IHostedZone | undefined): AliasRecordTargetConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this bind method for and where is it used?

Copy link
Contributor Author

@shikha372 shikha372 Apr 26, 2024

Choose a reason for hiding this comment

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

this bind method is used by class RecordSet to set aliasTarget here
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-route53/lib/record-set.ts#L336
We use similar mechanism to set target like apigw etc. here
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-route53-targets/lib/api-gatewayv2-domain-name.ts

In this case, what will happen this piece of code target.aliasTarget.bind(this,hostedzone) will bind new Arecord with target DNS name set to input DNS name as we have defined in this public bind
dnsName: this.aRrecordAttrs.targetDNS

* Use to import given A record DNS name created outside CDK and return it as AliasRecordTarget
*/
class ImportARecordAsTarget implements IAliasRecordTarget {
constructor(private readonly ArecordAttrs: ARecordAttrs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
constructor(private readonly ArecordAttrs: ARecordAttrs) {
constructor(private readonly aRecordAttrs: ARecordAttrs) {

packages/aws-cdk-lib/aws-route53/lib/record-set.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-route53/lib/record-set.ts Outdated Show resolved Hide resolved
shikha372 and others added 2 commits April 26, 2024 10:25
Co-authored-by: paulhcsun <47882901+paulhcsun@users.noreply.github.com>
Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

Looks good, nice work!!

@paulhcsun
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Apr 26, 2024

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: af27ed7
  • 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 Apr 26, 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).

@mergify mergify bot merged commit 4f8b7db into aws:main Apr 26, 2024
9 checks passed
@shikha372 shikha372 deleted the import_a_record branch May 17, 2024 21:04
@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

route53: No way to alias an existing record
3 participants