-
Notifications
You must be signed in to change notification settings - Fork 0
Added BackendDefaults to Virtual Node #3
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
5326284
e476ae7
dbc5870
5b4c97b
b4b7f95
ce35692
4aea038
25208a4
5b260be
a55a305
7ca64da
01be91b
7e2ddbc
49824b1
0306a36
045d2a7
2cad882
20c0e96
d36fc42
4e07587
da25261
41d2c12
d18fdc4
4ec4b21
8b0b863
bd2d85e
8b707ce
de939c3
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 |
|---|---|---|
|
|
@@ -113,39 +113,135 @@ export interface VirtualNodeBaseProps { | |
| } | ||
|
|
||
| /** | ||
| * Default Configuration for Virtual Nodes | ||
| * Default configuration that is applied to all backends for the virtual node. | ||
| * Any configuration defined will be overwritten by configurations specified for a particular backend. | ||
| */ | ||
| export interface BackendDefaults { | ||
| /** | ||
| * Client policy for TLS | ||
| */ | ||
| readonly tlsClientPolicy: TLSClientPolicyProps; | ||
| } | ||
|
|
||
| /** | ||
| * Properties with respect to TLS backend default. | ||
| */ | ||
| export interface TLSClientPolicyProps { | ||
| /** | ||
| * TLS enforced if True. | ||
|
||
| * | ||
| * @default - none | ||
| * @default - True | ||
| */ | ||
| readonly enforce?: boolean | ||
| readonly enforce?: boolean; | ||
|
|
||
| /** | ||
| * TLS enforced on these ports. If not specified it is enforced on all ports. | ||
| * | ||
| * @default - none | ||
| */ | ||
| readonly ports?: number[] | ||
| readonly ports?: number[]; | ||
|
|
||
| /** | ||
| * Certificate discovery method, ACM-PCA or Local file hosting. | ||
| * To enforce the trust is one of file, acmpca, or sds. | ||
|
||
| * | ||
| * @default - none | ||
| */ | ||
| readonly certificateType: string; | ||
| readonly validation: TLSClientValidation; | ||
|
||
| } | ||
|
|
||
| /** | ||
| * Defines the TLS validation context trust. | ||
| */ | ||
| export abstract class TLSClientValidation { | ||
| /** | ||
| * Certificate File path or Certificate ARN. | ||
| * | ||
| * @default - none | ||
| * TLS validation context trust for a local file | ||
| */ | ||
| public static fileTrustValidation(props: FileTrustProps): TLSClientValidation { | ||
|
||
| return new FileTrust(props); | ||
| } | ||
|
|
||
| /** | ||
| * TLS validation context trust for AWS Certicate Manager (ACM) certificate. | ||
|
||
| */ | ||
| public static acmTrustValidation(props: ACMTrustProps): TLSClientValidation { | ||
| return new ACMTrust(props); | ||
| } | ||
|
|
||
| /** | ||
| * Returns Trust context based on trust type. | ||
| */ | ||
| public abstract bind(scope: cdk.Construct): CfnVirtualNode.TlsValidationContextProperty; | ||
|
||
| } | ||
|
|
||
| /** | ||
| * ACM Trust Properties | ||
| */ | ||
| export interface ACMTrustProps { | ||
| /** | ||
| * Amazon Resource Name of the Certificates | ||
|
||
| */ | ||
| readonly certificateAuthorityArns: string[]; | ||
|
||
| } | ||
|
|
||
| /** | ||
| * File Trust Properties | ||
| */ | ||
| export interface FileTrustProps { | ||
| /** | ||
| * Path to the Certificate Chain file on the file system where the Envoy is deployed. | ||
| */ | ||
| readonly certificate: string[]; | ||
| readonly certificateChain: string; | ||
| } | ||
|
|
||
| /** | ||
| * Represents a Transport Layer Security (TLS) validation context trust for a local file | ||
| */ | ||
| export class FileTrust extends TLSClientValidation { | ||
| /** | ||
| * Path to the Certificate Chain file on the file system where the Envoy is deployed. | ||
| */ | ||
| readonly certificateChain: string; | ||
|
|
||
| constructor(props: FileTrustProps) { | ||
| super(); | ||
| this.certificateChain = props.certificateChain; | ||
| } | ||
|
|
||
| public bind(_scope: cdk.Construct): CfnVirtualNode.TlsValidationContextProperty { | ||
| return { | ||
| trust: { | ||
| file: { | ||
| certificateChain: this.certificateChain, | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Represents a TLS validation context trust for an AWS Certicate Manager (ACM) certificate. | ||
| */ | ||
| export class ACMTrust extends TLSClientValidation { | ||
|
||
| /** | ||
| * Amazon Resource Name of the Certificates | ||
| */ | ||
| readonly certificateAuthorityArns: string[]; | ||
|
|
||
| constructor(props: ACMTrustProps) { | ||
| super(); | ||
| this.certificateAuthorityArns = props.certificateAuthorityArns; | ||
| } | ||
|
|
||
| public bind(_scope: cdk.Construct): CfnVirtualNode.TlsValidationContextProperty { | ||
| return { | ||
| trust: { | ||
| acm: { | ||
| certificateAuthorityArns: this.certificateAuthorityArns, | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The properties used when creating a new VirtualNode | ||
|
|
@@ -189,31 +285,17 @@ abstract class VirtualNodeBase extends cdk.Resource implements IVirtualNode { | |
| * Adds Default Backend Configuration for virtual node to communicate with Virtual Services. | ||
| */ | ||
| public addBackendDefaults(backendDefaults: BackendDefaults) { | ||
| if (Object.keys(backendDefaults).length!==0) { | ||
| const enforce = backendDefaults.enforce || false; | ||
| const ports = backendDefaults.ports || undefined; | ||
| const certificateType = backendDefaults.certificateType || 'acm'; | ||
| const certificate = backendDefaults.certificate || []; | ||
| this.backendDefaults.push({ | ||
| clientPolicy: { | ||
| tls: { | ||
| enforce: enforce, | ||
| ports: ports, | ||
| validation: { | ||
| trust: certificateType === 'acm' ? { | ||
| acm: { | ||
| certificateAuthorityArns: certificate, | ||
| }, | ||
| } : { | ||
| file: { | ||
| certificateChain: certificate[0], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| // eslint-disable-next-line no-console | ||
| console.log(backendDefaults.tlsClientPolicy.enforce); | ||
| this.backendDefaults.push({ | ||
| clientPolicy: { | ||
| tls: { | ||
| enforce: backendDefaults.tlsClientPolicy.enforce === undefined ? true : backendDefaults.tlsClientPolicy.enforce, | ||
|
||
| validation: backendDefaults.tlsClientPolicy.validation.bind(this), | ||
| ports: backendDefaults.tlsClientPolicy.ports ? backendDefaults.tlsClientPolicy.ports : undefined, | ||
|
||
| }, | ||
| }); | ||
| } | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
So the
Propsname is reserved for class constructors. (Found this out in a PR I have out now)Let's have this named
TLSClientPolicyOptions