AWS Cloudformation:为未命名的 ECS 服务输出 ServiceName
AWS Cloudformation: Outputs ServiceName for Unnamed ECS Service
我通过 cloudformation 创建 ECS 堆栈。一切正常。
由于某些原因,我在定义中没有为ECS服务(名称:Service)指定ServiceName。
但是,我想在 Cloudformation 创建堆栈后将其包含在输出中。
因此,为此目的,我定义了这样的输出:
Outputs:
ECSServiceName:
Description: Service Name I want to see
Value: !GetAtt Service.ServiceName
当我 运行 更新 CF 堆栈时,我收到来自 AWS 的错误消息:
Requested attribute ServiceName must be a readonly property in schema for AWS::ECS::Service
如果之前没有严格指定,这是否意味着我无法在输出中接收它?或者我在输出定义的某个地方犯了错误?
您必须 export ECSServiceName
从您的模板。另外,获取 ECS 服务名称的正确方法是 !GetAtt Service.Name
:
Outputs:
ECSServiceName:
Description: Service Name I want to see
Value: !GetAtt Service.Name
Export:
Name: ECSServiceName
然后,在其他模板中,您可以使用ImportValue来引用导出的输出:
!ImportValue ECSClusterName
我通过 cloudformation 创建 ECS 堆栈。一切正常。 由于某些原因,我在定义中没有为ECS服务(名称:Service)指定ServiceName。 但是,我想在 Cloudformation 创建堆栈后将其包含在输出中。 因此,为此目的,我定义了这样的输出:
Outputs:
ECSServiceName:
Description: Service Name I want to see
Value: !GetAtt Service.ServiceName
当我 运行 更新 CF 堆栈时,我收到来自 AWS 的错误消息:
Requested attribute ServiceName must be a readonly property in schema for AWS::ECS::Service
如果之前没有严格指定,这是否意味着我无法在输出中接收它?或者我在输出定义的某个地方犯了错误?
您必须 export ECSServiceName
从您的模板。另外,获取 ECS 服务名称的正确方法是 !GetAtt Service.Name
:
Outputs:
ECSServiceName:
Description: Service Name I want to see
Value: !GetAtt Service.Name
Export:
Name: ECSServiceName
然后,在其他模板中,您可以使用ImportValue来引用导出的输出:
!ImportValue ECSClusterName