You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在AWS CDK TypeScript中获取Parameter Store字符串的ARN?

解决AWS CDK TypeScript中fromStringParameterAttributes不存在的错误

你遇到的错误是因为调用方式有误:fromStringParameterAttributes是StringParameter类的静态方法,并非SSM模块的顶级导出方法。

修正后的代码如下:

import * as ssm from 'aws-cdk-lib/aws-ssm';

const apikey = ssm.StringParameter.fromStringParameterAttributes(this, 'api-key', {
    simpleName: false,
    parameterName: '/apikey',
});

补充说明

  • 若要将该参数ARN用于ECS机密引用,可直接通过apikey.parameterArn获取其ARN值。
  • 你之前查阅的StringListParameter文档对应列表型参数,而你需要的是字符串型参数,应使用StringParameter的相关方法。

内容的提问来源于stack exchange,提问作者Dennis Brouwer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 19:57:36