【发布时间】:2022-08-16 03:35:28
【问题描述】:
使用Pulumi,我试图从elasticache 集群中获取主端点,因此我可以将它作为环境变量传递给aws 上的fargate 服务。出于某种原因,适用于RDS 的相同过程不适用于ElastiCache。
pulumi version
v3.23.0
\"@pulumi/aws\": \"^4.36.0\",
\"@pulumi/awsx\": \"^0.32.0\",
\"@pulumi/pulumi\": \"^3.23.0\",
以下适用于RDS:
super(\"backend:portalInfrastructure:rds\", name, {}, opts)
let securityGroupIds = cluster.securityGroups.map((g:any) => g.id)
let dbSubnets = new aws.rds.SubnetGroup(`${name}-rds-subnets-${ENV_LOWER}`, {
subnetIds: vpc.publicSubnetIds,
})
//Extra dash on the name here because pulumi doesn\'t add one for RDS
let db = new aws.rds.Instance(`${name}-postgres-${ENV_LOWER}-`, {
engine: \'postgres\',
instanceClass: \'db.t3.micro\',
allocatedStorage: 20,
dbSubnetGroupName: dbSubnets.id,
vpcSecurityGroupIds: securityGroupIds,
// TODO only needs to be publicly accessible
// to run migrations from external host
publiclyAccessible: true,
...DB_CONN,
tags: {
\'env\':ENV_LOWER
},
skipFinalSnapshot: true
})
this.DBSetupOutput = {
dbhost : db.endpoint.apply(e => e.split(\":\")[0]),
db: db
}
// For dependency tracking, register output properties for this component
this.registerOutputs({
DBSetupOutput: this.DBSetupOutput
})
但是,当我为ElastiCache/Redis 尝试此操作时:
super(\"backend:portalInfrastructure:redis\", name, {}, opts)
let securityGroupIds = cluster.securityGroups.map((g:any) => g.id)
let redisSubnets = new aws.elasticache.SubnetGroup(`${name}-redis-subnets-${ENV_LOWER}`, {
subnetIds: vpc.publicSubnetIds,
})
let redis = new aws.elasticache.Cluster(`${name}-redis-${ENV_LOWER}`, {
engine: \"redis\",
engineVersion: \"3.2.10\",
nodeType: \"cache.t3.micro\",
numCacheNodes: 1,
parameterGroupName: \"default.redis3.2\",
port: 6379,
subnetGroupName: redisSubnets.id,
securityGroupIds: securityGroupIds
}, {parent: this});
redis.clusterAddress.apply(address => {
console.log(address)
})
this.RedisSetupOutput = {
redishost : redis.clusterAddress.apply(a => a),
redis: redis
}
// For dependency tracking, register output properties for this component
this.registerOutputs({
RedisSetupOutput: this.RedisSetupOutput
})
我的变量redishost 得到以下输出
\"Calling [toString] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output<T> as an Output<string> consider either:\\n1: o.apply(v => `prefix${v}suffix`)\\n2: pulumi.interpolate `prefix${v}suffix`\\n\\nSee https://pulumi.io/help/outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.\"
我不明白,因为我正在调用 apply 到 pulumi 输出。尝试获取 ElastiCache clusterAddress 或 cacheNodes 时也会发生同样的事情。如果有人了解如何获得ElastiCache 主要端点,或者可以告诉我我在这里做错了什么,将不胜感激。
-
我遇到了完全相同的问题。你能想出解决办法吗?据我所知,这个输出似乎被破坏了......
-
我什至尝试使用 getter 稍后在代码中获取创建的弹性缓存资源,并且发生了同样的问题。这个问题似乎影响了
aws.elasticache类中的所有端点输出。
标签: typescript amazon-web-services redis pulumi