-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to register an existing record created manually as an ali…
…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*
- Loading branch information
Showing
12 changed files
with
1,273 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...s-target.js.snapshot/AwsCdkARecordDnsIntegTestDefaultTestDeployAssert5618DC96.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...target.js.snapshot/AwsCdkARecordDnsIntegTestDefaultTestDeployAssert5618DC96.template.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...test/integ.import-existing-record-as-target.js.snapshot/aws-cdk-route53-integ.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
301 changes: 301 additions & 0 deletions
301
...st/integ.import-existing-record-as-target.js.snapshot/aws-cdk-route53-integ.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
{ | ||
"Resources": { | ||
"VPCB9E5F0B4": { | ||
"Type": "AWS::EC2::VPC", | ||
"Properties": { | ||
"CidrBlock": "10.0.0.0/16", | ||
"EnableDnsHostnames": true, | ||
"EnableDnsSupport": true, | ||
"InstanceTenancy": "default", | ||
"Tags": [ | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC" | ||
} | ||
] | ||
} | ||
}, | ||
"VPCPublicSubnet1SubnetB4246D30": { | ||
"Type": "AWS::EC2::Subnet", | ||
"Properties": { | ||
"AvailabilityZone": { | ||
"Fn::Select": [ | ||
0, | ||
{ | ||
"Fn::GetAZs": "" | ||
} | ||
] | ||
}, | ||
"CidrBlock": "10.0.0.0/17", | ||
"MapPublicIpOnLaunch": true, | ||
"Tags": [ | ||
{ | ||
"Key": "aws-cdk:subnet-name", | ||
"Value": "Public" | ||
}, | ||
{ | ||
"Key": "aws-cdk:subnet-type", | ||
"Value": "Public" | ||
}, | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1" | ||
} | ||
], | ||
"VpcId": { | ||
"Ref": "VPCB9E5F0B4" | ||
} | ||
} | ||
}, | ||
"VPCPublicSubnet1RouteTableFEE4B781": { | ||
"Type": "AWS::EC2::RouteTable", | ||
"Properties": { | ||
"Tags": [ | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1" | ||
} | ||
], | ||
"VpcId": { | ||
"Ref": "VPCB9E5F0B4" | ||
} | ||
} | ||
}, | ||
"VPCPublicSubnet1RouteTableAssociation0B0896DC": { | ||
"Type": "AWS::EC2::SubnetRouteTableAssociation", | ||
"Properties": { | ||
"RouteTableId": { | ||
"Ref": "VPCPublicSubnet1RouteTableFEE4B781" | ||
}, | ||
"SubnetId": { | ||
"Ref": "VPCPublicSubnet1SubnetB4246D30" | ||
} | ||
} | ||
}, | ||
"VPCPublicSubnet1DefaultRoute91CEF279": { | ||
"Type": "AWS::EC2::Route", | ||
"Properties": { | ||
"DestinationCidrBlock": "0.0.0.0/0", | ||
"GatewayId": { | ||
"Ref": "VPCIGWB7E252D3" | ||
}, | ||
"RouteTableId": { | ||
"Ref": "VPCPublicSubnet1RouteTableFEE4B781" | ||
} | ||
}, | ||
"DependsOn": [ | ||
"VPCVPCGW99B986DC" | ||
] | ||
}, | ||
"VPCPublicSubnet1EIP6AD938E8": { | ||
"Type": "AWS::EC2::EIP", | ||
"Properties": { | ||
"Domain": "vpc", | ||
"Tags": [ | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1" | ||
} | ||
] | ||
} | ||
}, | ||
"VPCPublicSubnet1NATGatewayE0556630": { | ||
"Type": "AWS::EC2::NatGateway", | ||
"Properties": { | ||
"AllocationId": { | ||
"Fn::GetAtt": [ | ||
"VPCPublicSubnet1EIP6AD938E8", | ||
"AllocationId" | ||
] | ||
}, | ||
"SubnetId": { | ||
"Ref": "VPCPublicSubnet1SubnetB4246D30" | ||
}, | ||
"Tags": [ | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1" | ||
} | ||
] | ||
}, | ||
"DependsOn": [ | ||
"VPCPublicSubnet1DefaultRoute91CEF279", | ||
"VPCPublicSubnet1RouteTableAssociation0B0896DC" | ||
] | ||
}, | ||
"VPCPrivateSubnet1Subnet8BCA10E0": { | ||
"Type": "AWS::EC2::Subnet", | ||
"Properties": { | ||
"AvailabilityZone": { | ||
"Fn::Select": [ | ||
0, | ||
{ | ||
"Fn::GetAZs": "" | ||
} | ||
] | ||
}, | ||
"CidrBlock": "10.0.128.0/17", | ||
"MapPublicIpOnLaunch": false, | ||
"Tags": [ | ||
{ | ||
"Key": "aws-cdk:subnet-name", | ||
"Value": "Private" | ||
}, | ||
{ | ||
"Key": "aws-cdk:subnet-type", | ||
"Value": "Private" | ||
}, | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1" | ||
} | ||
], | ||
"VpcId": { | ||
"Ref": "VPCB9E5F0B4" | ||
} | ||
} | ||
}, | ||
"VPCPrivateSubnet1RouteTableBE8A6027": { | ||
"Type": "AWS::EC2::RouteTable", | ||
"Properties": { | ||
"Tags": [ | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1" | ||
} | ||
], | ||
"VpcId": { | ||
"Ref": "VPCB9E5F0B4" | ||
} | ||
} | ||
}, | ||
"VPCPrivateSubnet1RouteTableAssociation347902D1": { | ||
"Type": "AWS::EC2::SubnetRouteTableAssociation", | ||
"Properties": { | ||
"RouteTableId": { | ||
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027" | ||
}, | ||
"SubnetId": { | ||
"Ref": "VPCPrivateSubnet1Subnet8BCA10E0" | ||
} | ||
} | ||
}, | ||
"VPCPrivateSubnet1DefaultRouteAE1D6490": { | ||
"Type": "AWS::EC2::Route", | ||
"Properties": { | ||
"DestinationCidrBlock": "0.0.0.0/0", | ||
"NatGatewayId": { | ||
"Ref": "VPCPublicSubnet1NATGatewayE0556630" | ||
}, | ||
"RouteTableId": { | ||
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027" | ||
} | ||
} | ||
}, | ||
"VPCIGWB7E252D3": { | ||
"Type": "AWS::EC2::InternetGateway", | ||
"Properties": { | ||
"Tags": [ | ||
{ | ||
"Key": "Name", | ||
"Value": "aws-cdk-route53-integ/VPC" | ||
} | ||
] | ||
} | ||
}, | ||
"VPCVPCGW99B986DC": { | ||
"Type": "AWS::EC2::VPCGatewayAttachment", | ||
"Properties": { | ||
"InternetGatewayId": { | ||
"Ref": "VPCIGWB7E252D3" | ||
}, | ||
"VpcId": { | ||
"Ref": "VPCB9E5F0B4" | ||
} | ||
} | ||
}, | ||
"PrivateZone27242E85": { | ||
"Type": "AWS::Route53::HostedZone", | ||
"Properties": { | ||
"Name": "cdk.local.", | ||
"VPCs": [ | ||
{ | ||
"VPCId": { | ||
"Ref": "VPCB9E5F0B4" | ||
}, | ||
"VPCRegion": { | ||
"Ref": "AWS::Region" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"AManualAC0F29BE": { | ||
"Type": "AWS::Route53::RecordSet", | ||
"Properties": { | ||
"HostedZoneId": { | ||
"Ref": "PrivateZone27242E85" | ||
}, | ||
"Name": "existing.test.record.cdk.local.", | ||
"ResourceRecords": [ | ||
"192.0.1.1" | ||
], | ||
"TTL": "1800", | ||
"Type": "A" | ||
} | ||
}, | ||
"ACCC8ACD5": { | ||
"Type": "AWS::Route53::RecordSet", | ||
"Properties": { | ||
"AliasTarget": { | ||
"DNSName": "existing.test.record.cdk.local", | ||
"HostedZoneId": { | ||
"Ref": "PrivateZone27242E85" | ||
} | ||
}, | ||
"HostedZoneId": { | ||
"Ref": "PrivateZone27242E85" | ||
}, | ||
"Name": "r53-integ-test.cdk.local.", | ||
"Type": "A" | ||
}, | ||
"DependsOn": [ | ||
"AManualAC0F29BE" | ||
] | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...rk-integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.