This message was deleted.
# typescript
s
This message was deleted.
e
Have you got some example code of what exactly your trying to do?
a
@echoing-dinner-19531
Copy code
export async function manageRedisCache(config) {
  try {
    const subnetGroup = new aws.elasticache.SubnetGroup(config.name, {
      name: config.name,
      subnetIds: config.subnetIds,
      description: `Subnet group for ${config.name} Cache Cluster`,
      tags: {
        Name: config.name,
      },
    });
    const redisInstance = await new aws.elasticache.Cluster(config.name, {
      engine: "redis",
      nodeType: config.size,
      numCacheNodes: 1,
      subnetGroupName: subnetGroup.name,
      securityGroupIds: config.securityGroupIds,
      securityGroupNames: config.securityGroupNames,
      tags: {
        Name: config.name,
      },
    });
    return {
      instance: redisInstance,
      data: {
        address: redisInstance.clusterAddress.apply((v) => v),
        port: redisInstance.port.apply((v) => v) as unknown as string,
      },
    };
  } catch (e) {
    throw e;
  }
}

I'm then passing the value from the function into a function to create my Fargate services
I've tried using the apply, both at source, when creating the resource, as well as on the function readying the values.
e
Ah right, yes once values are "Outputs" they need to stay Outputs. There is no way to go from
Output<string>
to just
string
except via resources (and they will just return more outputs)
a
The instance is being created fine, I'm having a problem reading the values for the output
e
Change your "data.address" and "data.port" to be
Output<string>
b
@abundant-window-12532 redis elasticache instances don't return a
clusterAddress
, only memcached based ones. You need
redisInstance.cacheNodes[0].address
which is an array You don't need to do an
apply
if you're just returning an
Output
example: https://github.com/jaxxstorm/brig.gs/blob/main/index.ts#L55
a
@billowy-army-68599 thanks for that, helped. I'm also seeing vpc under awsx, which has much more functionality that in aws