KubernetesObjectValue

class aws_cdk.aws_eks.KubernetesObjectValue(scope, id, *, cluster, json_path, object_name, object_type, object_namespace=None, timeout=None)

Bases: aws_cdk.core.Construct

Represents a value of a specific object deployed in the cluster.

Use this to fetch any information available by the kubectl get command.

Example:

# cluster is of type Cluster

# query the load balancer address
my_service_address = eks.KubernetesObjectValue(self, "LoadBalancerAttribute",
    cluster=cluster,
    object_type="service",
    object_name="my-service",
    json_path=".status.loadBalancer.ingress[0].hostname"
)

# pass the address to a lambda function
proxy_function = lambda_.Function(self, "ProxyFunction",
    handler="index.handler",
    code=lambda_.Code.from_inline("my-code"),
    runtime=lambda_.Runtime.NODEJS_14_X,
    environment={
        "my_service_address": my_service_address.value
    }
)
Parameters
  • scope (Construct) –

  • id (str) –

  • cluster (ICluster) – The EKS cluster to fetch attributes from. [disable-awslint:ref-via-interface]

  • json_path (str) – JSONPath to the specific value.

  • object_name (str) – The name of the object to query.

  • object_type (str) – The object type to query. (e.g ‘service’, ‘pod’…)

  • object_namespace (Optional[str]) – The namespace the object belongs to. Default: ‘default’

  • timeout (Optional[Duration]) – Timeout for waiting on a value. Default: Duration.minutes(5)

Methods

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

RESOURCE_TYPE = 'Custom::AWSCDK-EKS-KubernetesObjectValue'
node

The construct tree node associated with this construct.

Return type

ConstructNode

value

The value as a string token.

Return type

str

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool