Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(scope: cdk.Construct, id: string, props: VirtualRouterAttributes) {
super(scope, id);
if (props.mesh) {
this._mesh = props.mesh;
}
if (props.meshName) {
if (props.mesh) {
throw new Error(`Supply either 'mesh' or 'meshName', but not both`);
}
this._mesh = Mesh.fromMeshName(this, 'Mesh', props.meshName);
}
if (props.virtualRouterArn) {
this.virtualRouterArn = props.virtualRouterArn;
this.virtualRouterName = cdk.Fn.select(2, cdk.Fn.split('/', cdk.Stack.of(scope).parseArn(props.virtualRouterArn).resourceName!));
} else if (props.virtualRouterName && props.meshName) {
this.virtualRouterName = props.virtualRouterName;
this.virtualRouterArn = cdk.Stack.of(this).formatArn({
service: 'appmesh',
resource: `mesh/${props.meshName}/virtualRouter`,
resourceName: this.virtualRouterName,
});
} else {
throw new Error('Need either arn or both names');
}
}
constructor(scope: cdk.Construct, id: string, props: RouteAttributes) {
super(scope, id);
if (props.routeArn) {
this.routeArn = props.routeArn;
this.routeName = cdk.Fn.select(4, cdk.Fn.split('/', cdk.Stack.of(scope).parseArn(props.routeArn).resourceName!));
} else if (props.routeName && props.meshName && props.virtualRouterName) {
this.routeName = props.routeName;
this.routeArn = cdk.Stack.of(this).formatArn({
service: 'appmesh',
resource: `mesh/${props.meshName}/virtualRouter/${props.virtualRouterName}/route`,
resourceName: this.routeName,
});
} else {
throw new Error('Need either arn or three names');
}
}
}
export function loadBalancerNameFromListenerArn(listenerArn: string) {
const arnParts = cdk.Fn.split('/', listenerArn);
return `${cdk.Fn.select(1, arnParts)}/${cdk.Fn.select(2, arnParts)}/${cdk.Fn.select(3, arnParts)}`;
}
constructor(scope: cdk.Construct, id: string, props: VirtualNodeAttributes) {
super(scope, id);
if (props.virtualNodeArn) {
this.virtualNodeArn = props.virtualNodeArn;
this.virtualNodeName = cdk.Fn.select(2, cdk.Fn.split('/', cdk.Stack.of(scope).parseArn(props.virtualNodeArn).resourceName!));
} else if (props.virtualNodeName && props.meshName) {
this.virtualNodeName = props.virtualNodeName;
this.virtualNodeArn = cdk.Stack.of(this).formatArn({
service: 'appmesh',
resource: `mesh/${props.meshName}/virtualNode`,
resourceName: this.virtualNodeName,
});
} else {
throw new Error('Need either arn or both names');
}
}
}
constructor(scope: cdk.Construct, id: string, props: VirtualServiceAttributes) {
super(scope, id);
if (props.virtualServiceArn) {
this.virtualServiceArn = props.virtualServiceArn;
this.virtualServiceName = cdk.Fn.select(2, cdk.Fn.split('/', cdk.Stack.of(scope).parseArn(props.virtualServiceArn).resourceName!));
} else if (props.virtualServiceName && props.meshName) {
this.virtualServiceName = props.virtualServiceName;
this.virtualServiceArn = cdk.Stack.of(this).formatArn({
service: 'appmesh',
resource: `mesh/${props.meshName}/virtualService`,
resourceName: this.virtualServiceName,
});
} else {
throw new Error('Need either arn or both names');
}
}
}
export function loadBalancerNameFromListenerArn(listenerArn: string) {
const arnParts = cdk.Fn.split('/', listenerArn);
return `${cdk.Fn.select(1, arnParts)}/${cdk.Fn.select(2, arnParts)}/${cdk.Fn.select(3, arnParts)}`;
}