Reputation: 10349
How can I get endpoint for an aws_elasticache_serverless_cache resource? I want to pass this endpoint as an env var to one of my k8s deployments like so
{ name: "REDIS_URL", value: config.cache.endpoint.get(0).computeFqn()},
where my config
is of type
export type RpcProxy2Config = {
// ...other stuff
cache: ElasticacheServerlessCache;
};
The above example gets the following error:
[2024-06-05T09:49:29.747] [ERROR] default - ╷
│ Error: Incorrect attribute value type
│
│ on cdk.tf.json line 5699, in resource.kubernetes_deployment.rpc-proxy-2_D64F493D.spec.template.spec.container[0].env[2]:
│ 5699: "value": "${aws_elasticache_serverless_cache.rpc-proxy-2-cache.endpoint[0]}"
│ ├────────────────
│ │ aws_elasticache_serverless_cache.rpc-proxy-2-cache.endpoint[0] is a object
│
│ Inappropriate value for attribute "value": string required.
goldsky-infra-dev ╷
│ Error: Incorrect attribute value type
│
│ on cdk.tf.json line 5699, in resource.kubernetes_deployment.rpc-proxy-2_D64F493D (rpc-proxy-2/rpc-proxy-2).spec.template.spec.container[0].env[2]:
│ 5699: "value": "${aws_elasticache_serverless_cache.rpc-proxy-2-cache (rpc-proxy-2-cache).endpoint[0]}"
│ ├────────────────
│ │ aws_elasticache_serverless_cache.rpc-proxy-2-cache.endpoint[0] is a object
│
│ Inappropriate value for attribute "value": string required.
╵
⠦ Processing
I've tried using config.cache.endpoint.get(0).fqn
as well and config.cache.endpoint.get(0).address
but they have the same issue. It seems that I can't get properties on the object returned after the .get
call.
Here are my dependencies
"dependencies": {
"@cdktf/provider-aws": "^19.21.0",
"@cdktf/provider-kubernetes": "^11.5.0",
"@eryldor/cidr": "^1.0.5",
"cdktf": "^0.20.7",
"cdktf-cli": "^0.20.7",
"constructs": "^10.0.9",
"ejs": "^3.1.6",
"pg": "^8.10.0"
},
Upvotes: 2
Views: 202
Reputation: 10349
Turns out I have to use Fn.lookup
like so Fn.lookup(config.serverlessElasticCache.endpoint.get(0),"address")
Upvotes: 0