-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
route53: No way to alias an existing record #23048
route53: No way to alias an existing record #23048
Comments
Please check out my sample below. At this moment it is possible to create an Alias ARecord to an existing route53 record set as long as the existing one is created by CDK. However, if the existing record set is created outsides of CDK, it seems not possible at this moment. Are you trying to create an alias to an existing target record set created outsides of CDK(e.g. manually created)? const zone = new route53.HostedZone(stack, 'Zone', {
zoneName: 'demo.com',
});
const record = new route53.RecordSet(stack, 'target', {
zone,
recordName: 'target.demo.com',
recordType: route53.RecordType.A,
target: route53.RecordTarget.fromIpAddresses('1.2.3.4'),
});
// alias test.demo.com to the record set of 'target.demo.com'
new route53.ARecord(stack, 'Alias', {
zone,
recordName: 'test.demo.com',
target: route53.RecordTarget.fromAlias(new targets.Route53RecordTarget(record)),
}); |
Hi @pahud, yes the existing record has been created manually, so I need to somehow load it into my CDK stack, in order to pass it to |
I think we probably need a construct method like route53.ARecord.fromAttributes(...) to import existing ARecords. I am making this as P2 but any PRs from the community would be highly appreciated! |
I need this functionality too. |
+1 |
please help us 👍 on the original issue post rather than +1 in the comments. According to the contributing guide, any P2 issue with 20 or more +1s will be automatically upgraded from P2 to P1. |
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
…as ARecord target (#29565) ### 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 - [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*
|
Describe the bug
I am trying to create a Route53 alias to an existing record.
The test code demonstrates how to do this if you create the target record in the same stack.
However if you haven't created the target record and instead need to load an existing record, there does not appear to be a way of doing so.
You could try
fromValues()
but it only accepts IP addresses:It seems it is not possible to create an alias in one stack to a Route53 record from another stack, even if both are in the same hosted zone. It can only be done via the AWS Console.
Expected Behavior
I expected
fromValues()
to allow me to look up a Route53 record by name, or for there to be some other way to load a Route53 record so it can be used as a target.Current Behavior
The only current way that might work to do this - with
fromValues()
- only accepts IP addresses, not hostnames.Reproduction Steps
Use the test code but have it load an existing Route53 record to use as the alias target, instead of targeting the record it just created.
Possible Solution
Either allow
fromValues()
to look up via hostname, or add lookup methods toRoute53.ARecord
and the other record classes to allow existing records to be retrieved.I did find a workaround online, which is to pass a
bind()
function in instead:However this seems a bit hacky.
Additional Information/Context
I have the target DNS entry created in a primary CDK stack, and I want to make an alias for it in a few secondary CDK stacks for other projects. This way if the IP address ever changes in the primary stack, the alias in the secondary stacks won't need to be updated, and I won't have to hard-code any IP addresses from the primary's resources in the secondary stacks.
CDK CLI Version
2.51.1 (latest docs online)
Framework Version
No response
Node.js Version
N/A (just looking at the docs, no code yet)
OS
Linux
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: