-
Notifications
You must be signed in to change notification settings - Fork 4k
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(appmesh): allow the virtualServiceName field for virtual node backends to be supplied as a string #17736
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -215,6 +215,13 @@ export abstract class Backend { | |||||||||||||||||||||
return new VirtualServiceBackend(virtualService, props.tlsClientPolicy); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* Construct a Virtual Service backend via a Virtual Service name | ||||||||||||||||||||||
*/ | ||||||||||||||||||||||
public static virtualServiceName(virtualServiceName: string, props: VirtualServiceBackendOptions = {}): Backend { | ||||||||||||||||||||||
return new VirtualServiceNameBackend(virtualServiceName, props.tlsClientPolicy); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+221
to
+223
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love this API. In my opinion, it's kind of confusing, easy to misuse (for example, what if I do I'd prefer if we added a new property to Let's also make sure to explain in the JSDocs of this method how is it different than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe using Won't the token value still be needed if the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, it would not work (which makes sense, because
I was a little imprecise with my wording. What I meant is that |
||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* Return backend config | ||||||||||||||||||||||
*/ | ||||||||||||||||||||||
|
@@ -250,6 +257,35 @@ class VirtualServiceBackend extends Backend { | |||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* Represents the properties needed to define a Virtual Service backend via a Virtual Service name | ||||||||||||||||||||||
*/ | ||||||||||||||||||||||
class VirtualServiceNameBackend extends Backend { | ||||||||||||||||||||||
|
||||||||||||||||||||||
constructor (private readonly virtualServiceName: string, | ||||||||||||||||||||||
private readonly tlsClientPolicy: TlsClientPolicy | undefined) { | ||||||||||||||||||||||
super(); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+265
to
+268
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* Return config for a Virtual Service backend | ||||||||||||||||||||||
*/ | ||||||||||||||||||||||
public bind(scope: Construct): BackendConfig { | ||||||||||||||||||||||
return { | ||||||||||||||||||||||
virtualServiceBackend: { | ||||||||||||||||||||||
virtualService: { | ||||||||||||||||||||||
virtualServiceName: this.virtualServiceName, | ||||||||||||||||||||||
clientPolicy: this.tlsClientPolicy | ||||||||||||||||||||||
? { | ||||||||||||||||||||||
tls: renderTlsClientPolicy(scope, this.tlsClientPolicy), | ||||||||||||||||||||||
} | ||||||||||||||||||||||
: undefined, | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* Connection pool properties for HTTP listeners | ||||||||||||||||||||||
*/ | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,53 @@ describe('virtual node', () => { | |
}, | ||
MeshOwner: ABSENT, | ||
}); | ||
}); | ||
|
||
test('should add resource with service backends via virtual service names', () => { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
|
||
// WHEN | ||
const mesh = new appmesh.Mesh(stack, 'mesh', { | ||
meshName: 'test-mesh', | ||
}); | ||
|
||
const service1Name = 'service1.domain.local'; | ||
new appmesh.VirtualService(stack, 'service-1', { | ||
virtualServiceName: service1Name, | ||
virtualServiceProvider: appmesh.VirtualServiceProvider.none(mesh), | ||
}); | ||
const service2Name = 'service2.domain.local'; | ||
new appmesh.VirtualService(stack, 'service-2', { | ||
virtualServiceName: service2Name, | ||
virtualServiceProvider: appmesh.VirtualServiceProvider.none(mesh), | ||
}); | ||
|
||
const node = new appmesh.VirtualNode(stack, 'test-node', { | ||
mesh, | ||
serviceDiscovery: appmesh.ServiceDiscovery.dns('test'), | ||
backends: [appmesh.Backend.virtualServiceName(service1Name)], | ||
}); | ||
|
||
node.addBackend(appmesh.Backend.virtualServiceName(service2Name)); | ||
|
||
// THEN | ||
expect(stack).toHaveResourceLike('AWS::AppMesh::VirtualNode', { | ||
Spec: { | ||
Backends: [ | ||
{ | ||
VirtualService: { | ||
VirtualServiceName: service1Name, | ||
}, | ||
}, | ||
{ | ||
VirtualService: { | ||
VirtualServiceName: service2Name, | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this unit test correctly reflects the problem we're trying to solve here (the cycle between |
||
}); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you actually create a separate example, explaining what problem does the new method in
Backend
solve? It probably deserves its own section, honestly. Let's leave this example unchanged.