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

如何在CloudFormation输出中为实例公网域名追加端口:8888?

CloudFormation输出拼接端口的正确写法

你当前的配置错误是因为在!Sub中错误嵌套了!GetAtt语法,!Sub本身支持直接引用资源属性,不需要额外嵌套!GetAtt。下面是两种正确实现方式:

方式一:直接在Sub字符串中引用资源属性

Outputs:
  thisInstance:
    Value: !Sub "${MySpotInstance.PublicDnsName}:8888"
    Description: Jupyter Notebook on port 8888

方式二:通过Variables定义变量引用GetAtt结果

如果需要更清晰的变量管理(比如复杂场景),可以用这种方式:

Outputs:
  thisInstance:
    Value: !Sub "${InstanceDNS}:8888"
    Description: Jupyter Notebook on port 8888
    Variables:
      InstanceDNS: !GetAtt MySpotInstance.PublicDnsName

两种方式都能正确将实例的公共DNS名称与:8888端口拼接,输出完整的Jupyter访问URL。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 12:55:02