How to use the @aws-cdk/core.Fn function in @aws-cdk/core

To help you get started, we’ve selected a few @aws-cdk/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / @aws-cdk / aws-appmesh / lib / virtual-router.ts View on Github external
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');
    }
  }
github aws / aws-cdk / packages / @aws-cdk / aws-appmesh / lib / route.ts View on Github external
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');
    }
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-elasticloadbalancingv2 / lib / shared / base-target-group.ts View on Github external
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)}`;
}
github aws / aws-cdk / packages / @aws-cdk / aws-appmesh / lib / virtual-node.ts View on Github external
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');
    }
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-appmesh / lib / virtual-service.ts View on Github external
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');
    }
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-elasticloadbalancingv2 / lib / shared / base-target-group.ts View on Github external
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)}`;
}