Skip to content

Commit 5d7282c

Browse files
authored
fix: ECR Endpoints Not Functional #809 (#810)
* add logic for endpoints with . in name * add logic for endpoints with . in name * eslint fix * prettier fix
1 parent f084f57 commit 5d7282c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/deployments/cdk/src/common/interface-endpoints.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ export class InterfaceEndpoint extends cdk.Construct {
9494

9595
this._hostedZone.addDependsOn(endpoint);
9696

97+
const recordSetName = recordSetNameForRegionAndEndpointName(vpcRegion, serviceName);
9798
const recordSet = new route53.CfnRecordSet(this, 'RecordSet', {
9899
type: 'A',
99-
name: hostedZoneName,
100+
name: recordSetName,
100101
hostedZoneId: this._hostedZone.ref,
101102
aliasTarget: aliasTargetForServiceNameAndEndpoint(serviceName, endpoint),
102103
});
@@ -121,13 +122,18 @@ function interfaceVpcEndpointForRegionAndEndpointName(region: string, name: stri
121122
if (name === 'notebook') {
122123
return `aws.sagemaker.${region}.${name}`;
123124
}
125+
124126
return `com.amazonaws.${region}.${name}`;
125127
}
126128

127129
function zoneNameForRegionAndEndpointName(region: string, name: string) {
128130
if (name === 'notebook') {
129131
return `notebook.${region}.sagemaker.aws.`;
130132
}
133+
if (name.indexOf('.') > 0) {
134+
const tmp = name.split('.').reverse().join('.');
135+
return `${tmp}.${region}.amazonaws.com.`;
136+
}
131137
return `${name}.${region}.amazonaws.com.`;
132138
}
133139

@@ -139,3 +145,13 @@ function getZoneAliasTargetIndex(name: string): number {
139145
}
140146
return 0;
141147
}
148+
149+
function recordSetNameForRegionAndEndpointName(region: string, name: string) {
150+
const hostedZoneName = zoneNameForRegionAndEndpointName(region, name);
151+
152+
if (name === 'ecr.dkr') {
153+
return `*.${hostedZoneName}`;
154+
}
155+
156+
return hostedZoneName;
157+
}

0 commit comments

Comments
 (0)