Skip to content
v2.278.0

KubernetesObjectValueProps Struct ​

Properties for KubernetesObjectValue.

Example ​

ts
declare const cluster: eks.Cluster;
// query the load balancer address
const myServiceAddress = new eks.KubernetesObjectValue(this, 'LoadBalancerAttribute', {
  cluster: cluster,
  objectType: 'service',
  objectName: 'my-service',
  jsonPath: '.status.loadBalancer.ingress[0].hostname', // https://kubernetes.io/docs/reference/kubectl/jsonpath/
});

// pass the address to a lambda function
const proxyFunction = new lambda.Function(this, 'ProxyFunction', {
  handler: 'index.handler',
  code: lambda.Code.fromInline('my-code'),
  runtime: lambda.Runtime.NODEJS_LATEST,
  environment: {
    myServiceAddress: myServiceAddress.value,
  },
})
python
# cluster: eks.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_LATEST,
    environment={
        "my_service_address": my_service_address.value
    }
)
java
Cluster cluster;

// query the load balancer address
KubernetesObjectValue myServiceAddress = KubernetesObjectValue.Builder.create(this, "LoadBalancerAttribute")
        .cluster(cluster)
        .objectType("service")
        .objectName("my-service")
        .jsonPath(".status.loadBalancer.ingress[0].hostname")
        .build();

// pass the address to a lambda function
Function proxyFunction = Function.Builder.create(this, "ProxyFunction")
        .handler("index.handler")
        .code(Code.fromInline("my-code"))
        .runtime(Runtime.NODEJS_LATEST)
        .environment(Map.of(
                "myServiceAddress", myServiceAddress.getValue()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;

// query the load balancer address
var myServiceAddress = new KubernetesObjectValue(this, "LoadBalancerAttribute", new KubernetesObjectValueProps {
    Cluster = cluster,
    ObjectType = "service",
    ObjectName = "my-service",
    JsonPath = ".status.loadBalancer.ingress[0].hostname"
});

// pass the address to a lambda function
var proxyFunction = new Function(this, "ProxyFunction", new FunctionProps {
    Handler = "index.handler",
    Code = Code.FromInline("my-code"),
    Runtime = Runtime.NODEJS_LATEST,
    Environment = new Dictionary<string, string> {
        { "myServiceAddress", myServiceAddress.Value }
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster

// query the load balancer address
myServiceAddress := eks.NewKubernetesObjectValue(this, jsii.String("LoadBalancerAttribute"), &KubernetesObjectValueProps{
	Cluster: cluster,
	ObjectType: jsii.String("service"),
	ObjectName: jsii.String("my-service"),
	JsonPath: jsii.String(".status.loadBalancer.ingress[0].hostname"),
})

// pass the address to a lambda function
proxyFunction := lambda.NewFunction(this, jsii.String("ProxyFunction"), &FunctionProps{
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromInline(jsii.String("my-code")),
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Environment: map[string]*string{
		"myServiceAddress": myServiceAddress.value,
	},
})

Properties ​

clusterIClusterclusterIClusterclusterIClusterClusterIClusterClusterICluster required #
The EKS cluster to fetch attributes from.

[disable-awslint:ref-via-interface]

jsonPathstringjson_pathstrjsonPathStringJsonPathstringJsonPath*string required #
JSONPath to the specific value.
objectNamestringobject_namestrobjectNameStringObjectNamestringObjectName*string required #
The name of the object to query.
objectNamespaceoptionalstringobject_namespaceoptionalstrobjectNamespaceoptionalStringObjectNamespaceoptionalstringObjectNamespaceoptional*string = 'default' #
The namespace the object belongs to.
objectTypestringobject_typestrobjectTypeStringObjectTypestringObjectType*string required #
The object type to query.

(e.g 'service', 'pod'...)

removalPolicyoptionalRemovalPolicyremoval_policyoptionalRemovalPolicyremovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicy = RemovalPolicy.DESTROY #
The removal policy applied to the custom resource that manages the Kubernetes object value.
notes

The removal policy controls what happens to the resource if it stops being managed by CloudFormation. This can happen in one of three situations:

  • The resource is removed from the template, so CloudFormation stops managing it
  • A change to the resource is made that requires it to be replaced, so CloudFormation stops managing it
  • The stack is deleted, so CloudFormation stops managing all resources in it
timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration = Duration.minutes(5) #
Timeout for waiting on a value.