我最近在 CDK github 帐户上提出了一个功能请求,并被指向 Core.Token 的方向,因为它几乎是我正在寻找的确切功能。我现在在实现它时遇到了一些问题并遇到了类似的错误,这是我之前提出的功能请求:https ://github.com/aws/aws-cdk/issues/3800
所以我当前的代码看起来像这样:
fargate_service = ecs_patterns.LoadBalancedFargateService(
self, "Fargate",
cluster = cluster,
memory_limit_mib = core.Token.as_number(ssm.StringParameter.value_from_lookup(self, parameter_name='template-service-memory_limit')),
execution_role=fargate_iam_role,
container_port=core.Token.as_number(ssm.StringParameter.value_from_lookup(self, parameter_name='port')),
cpu = core.Token.as_number(ssm.StringParameter.value_from_lookup(self, parameter_name='template-service-container_cpu')),
image=ecs.ContainerImage.from_registry(ecrRepo)
)
当我尝试合成此代码时,出现以下错误:
jsii.errors.JavaScriptError:
Error: Resolution error: Supplied properties not correct for "CfnSecurityGroupEgressProps"
fromPort: "dummy-value-for-template-service-container_port" should be a number
toPort: "dummy-value-for-template-service-container_port" should be a number.
Object creation stack:
对我来说,它似乎已经通过了需要将数字传递到 FargateService 验证的验证,但是当它尝试在此之后创建资源(“CfnSecurityGroupEgressProps”)时,它无法将虚拟字符串解析为数字。对于解决此问题或替代从 AWS 系统参数传递值的建议,我将不胜感激(我认为可以通过在构建管道期间从 S3 提取的文件或类似的东西将值解析到此处,但这似乎很老套)。
浮云间
相关分类